fix: UI being unresponsive to mouse events when window is maximized
This commit is contained in:
parent
0968a10fc1
commit
836bc1e9d0
1 changed files with 24 additions and 14 deletions
|
|
@ -49,25 +49,26 @@ pub fn event_func(
|
||||||
position,
|
position,
|
||||||
..
|
..
|
||||||
} => {
|
} => {
|
||||||
let resizable = !window.is_decorated()
|
let location = if is_resizable(window) {
|
||||||
&& !window.is_maximized()
|
cursor_resize_direction(
|
||||||
&& window.fullscreen().is_none();
|
|
||||||
if resizable {
|
|
||||||
let location = cursor_resize_direction(
|
|
||||||
window.surface_size(),
|
window.surface_size(),
|
||||||
*position,
|
*position,
|
||||||
border_size,
|
border_size,
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
};
|
||||||
|
if location != cursor_prev_resize_direction {
|
||||||
|
window.set_cursor(
|
||||||
|
resize_direction_cursor_icon(location).into(),
|
||||||
);
|
);
|
||||||
if location != cursor_prev_resize_direction {
|
cursor_prev_resize_direction = location;
|
||||||
window.set_cursor(
|
return true;
|
||||||
resize_direction_cursor_icon(location)
|
|
||||||
.into(),
|
|
||||||
);
|
|
||||||
cursor_prev_resize_direction = location;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
winit::event::WindowEvent::PointerLeft { .. } => {
|
||||||
|
cursor_prev_resize_direction = None;
|
||||||
|
}
|
||||||
winit::event::WindowEvent::PointerButton {
|
winit::event::WindowEvent::PointerButton {
|
||||||
state: winit::event::ElementState::Pressed,
|
state: winit::event::ElementState::Pressed,
|
||||||
button:
|
button:
|
||||||
|
|
@ -80,7 +81,9 @@ pub fn event_func(
|
||||||
primary: true,
|
primary: true,
|
||||||
..
|
..
|
||||||
} => {
|
} => {
|
||||||
if let Some(direction) = cursor_prev_resize_direction {
|
if let Some(direction) = cursor_prev_resize_direction
|
||||||
|
&& is_resizable(window)
|
||||||
|
{
|
||||||
let _res = window.drag_resize_window(direction);
|
let _res = window.drag_resize_window(direction);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
@ -96,6 +99,13 @@ pub fn event_func(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Whether the window can currently be resized from its border.
|
||||||
|
fn is_resizable(window: &dyn winit::window::Window) -> bool {
|
||||||
|
!window.is_decorated()
|
||||||
|
&& !window.is_maximized()
|
||||||
|
&& window.fullscreen().is_none()
|
||||||
|
}
|
||||||
|
|
||||||
/// Get the cursor icon that corresponds to the resize direction.
|
/// Get the cursor icon that corresponds to the resize direction.
|
||||||
fn resize_direction_cursor_icon(
|
fn resize_direction_cursor_icon(
|
||||||
resize_direction: Option<ResizeDirection>,
|
resize_direction: Option<ResizeDirection>,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue