mirror of
https://github.com/italicsjenga/winit-sonoma-fix.git
synced 2025-01-23 10:26:34 +11:00
On Wayland, fix hiding cursors on GNOME
`wl_pointer::set_cursor` expects a serial number of the last `wl_pointer::enter` event. However other calls expect latest observed pointer serial, so this commit tracks both and use them as required by specification. Fixes #2273.
This commit is contained in:
parent
ea09d1d10e
commit
0728105b2b
4 changed files with 19 additions and 3 deletions
|
@ -8,6 +8,7 @@ And please only add new entries to the top of this list, right below the `# Unre
|
||||||
|
|
||||||
# Unreleased
|
# Unreleased
|
||||||
|
|
||||||
|
- On Wayland, fix bug where the cursor wouldn't hide in GNOME.
|
||||||
- On macOS, Windows, and Wayland, add `set_cursor_hittest` to let the window ignore mouse events.
|
- On macOS, Windows, and Wayland, add `set_cursor_hittest` to let the window ignore mouse events.
|
||||||
- On Windows, added `WindowExtWindows::set_skip_taskbar` and `WindowBuilderExtWindows::with_skip_taskbar`.
|
- On Windows, added `WindowExtWindows::set_skip_taskbar` and `WindowBuilderExtWindows::with_skip_taskbar`.
|
||||||
- On Windows, added `EventLoopBuilderExtWindows::with_msg_hook`.
|
- On Windows, added `EventLoopBuilderExtWindows::with_msg_hook`.
|
||||||
|
|
|
@ -26,9 +26,12 @@ pub(super) struct PointerData {
|
||||||
|
|
||||||
pub confined_pointer: Rc<RefCell<Option<ZwpConfinedPointerV1>>>,
|
pub confined_pointer: Rc<RefCell<Option<ZwpConfinedPointerV1>>>,
|
||||||
|
|
||||||
/// A latest event serial.
|
/// Latest observed serial in pointer events.
|
||||||
pub latest_serial: Rc<Cell<u32>>,
|
pub latest_serial: Rc<Cell<u32>>,
|
||||||
|
|
||||||
|
/// Latest observed serial in pointer enter events.
|
||||||
|
pub latest_enter_serial: Rc<Cell<u32>>,
|
||||||
|
|
||||||
/// The currently accumulated axis data on a pointer.
|
/// The currently accumulated axis data on a pointer.
|
||||||
pub axis_data: AxisData,
|
pub axis_data: AxisData,
|
||||||
}
|
}
|
||||||
|
@ -42,6 +45,7 @@ impl PointerData {
|
||||||
Self {
|
Self {
|
||||||
surface: None,
|
surface: None,
|
||||||
latest_serial: Rc::new(Cell::new(0)),
|
latest_serial: Rc::new(Cell::new(0)),
|
||||||
|
latest_enter_serial: Rc::new(Cell::new(0)),
|
||||||
confined_pointer,
|
confined_pointer,
|
||||||
modifiers_state,
|
modifiers_state,
|
||||||
pointer_constraints,
|
pointer_constraints,
|
||||||
|
|
|
@ -42,6 +42,7 @@ pub(super) fn handle_pointer(
|
||||||
..
|
..
|
||||||
} => {
|
} => {
|
||||||
pointer_data.latest_serial.replace(serial);
|
pointer_data.latest_serial.replace(serial);
|
||||||
|
pointer_data.latest_enter_serial.replace(serial);
|
||||||
|
|
||||||
let window_id = wayland::make_wid(&surface);
|
let window_id = wayland::make_wid(&surface);
|
||||||
if !winit_state.window_map.contains_key(&window_id) {
|
if !winit_state.window_map.contains_key(&window_id) {
|
||||||
|
@ -61,6 +62,7 @@ pub(super) fn handle_pointer(
|
||||||
confined_pointer: Rc::downgrade(&pointer_data.confined_pointer),
|
confined_pointer: Rc::downgrade(&pointer_data.confined_pointer),
|
||||||
pointer_constraints: pointer_data.pointer_constraints.clone(),
|
pointer_constraints: pointer_data.pointer_constraints.clone(),
|
||||||
latest_serial: pointer_data.latest_serial.clone(),
|
latest_serial: pointer_data.latest_serial.clone(),
|
||||||
|
latest_enter_serial: pointer_data.latest_enter_serial.clone(),
|
||||||
seat,
|
seat,
|
||||||
};
|
};
|
||||||
window_handle.pointer_entered(winit_pointer);
|
window_handle.pointer_entered(winit_pointer);
|
||||||
|
@ -104,6 +106,7 @@ pub(super) fn handle_pointer(
|
||||||
confined_pointer: Rc::downgrade(&pointer_data.confined_pointer),
|
confined_pointer: Rc::downgrade(&pointer_data.confined_pointer),
|
||||||
pointer_constraints: pointer_data.pointer_constraints.clone(),
|
pointer_constraints: pointer_data.pointer_constraints.clone(),
|
||||||
latest_serial: pointer_data.latest_serial.clone(),
|
latest_serial: pointer_data.latest_serial.clone(),
|
||||||
|
latest_enter_serial: pointer_data.latest_enter_serial.clone(),
|
||||||
seat,
|
seat,
|
||||||
};
|
};
|
||||||
window_handle.pointer_left(winit_pointer);
|
window_handle.pointer_left(winit_pointer);
|
||||||
|
|
|
@ -35,7 +35,11 @@ pub struct WinitPointer {
|
||||||
confined_pointer: Weak<RefCell<Option<ZwpConfinedPointerV1>>>,
|
confined_pointer: Weak<RefCell<Option<ZwpConfinedPointerV1>>>,
|
||||||
|
|
||||||
/// Latest observed serial in pointer events.
|
/// Latest observed serial in pointer events.
|
||||||
|
/// used by Window::start_interactive_move()
|
||||||
latest_serial: Rc<Cell<u32>>,
|
latest_serial: Rc<Cell<u32>>,
|
||||||
|
/// Latest observed serial in pointer enter events.
|
||||||
|
/// used by Window::set_cursor()
|
||||||
|
latest_enter_serial: Rc<Cell<u32>>,
|
||||||
|
|
||||||
/// Seat.
|
/// Seat.
|
||||||
seat: WlSeat,
|
seat: WlSeat,
|
||||||
|
@ -58,7 +62,9 @@ impl WinitPointer {
|
||||||
Some(cursor_icon) => cursor_icon,
|
Some(cursor_icon) => cursor_icon,
|
||||||
None => {
|
None => {
|
||||||
// Hide the cursor.
|
// Hide the cursor.
|
||||||
(*self.pointer).set_cursor(self.latest_serial.get(), None, 0, 0);
|
// WlPointer::set_cursor() expects the serial of the last *enter*
|
||||||
|
// event (compare to to start_interactive_move()).
|
||||||
|
(*self.pointer).set_cursor(self.latest_enter_serial.get(), None, 0, 0);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -106,7 +112,7 @@ impl WinitPointer {
|
||||||
CursorIcon::ZoomOut => &["zoom-out"],
|
CursorIcon::ZoomOut => &["zoom-out"],
|
||||||
};
|
};
|
||||||
|
|
||||||
let serial = Some(self.latest_serial.get());
|
let serial = Some(self.latest_enter_serial.get());
|
||||||
for cursor in cursors {
|
for cursor in cursors {
|
||||||
if self.pointer.set_cursor(cursor, serial).is_ok() {
|
if self.pointer.set_cursor(cursor, serial).is_ok() {
|
||||||
return;
|
return;
|
||||||
|
@ -151,6 +157,8 @@ impl WinitPointer {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn drag_window(&self, window: &Window<FallbackFrame>) {
|
pub fn drag_window(&self, window: &Window<FallbackFrame>) {
|
||||||
|
// WlPointer::setart_interactive_move() expects the last serial of *any*
|
||||||
|
// pointer event (compare to set_cursor()).
|
||||||
window.start_interactive_move(&self.seat, self.latest_serial.get());
|
window.start_interactive_move(&self.seat, self.latest_serial.get());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue