From e0ebf1bdff06c38ae3cc9e3114b41572cb792dc0 Mon Sep 17 00:00:00 2001 From: Ivan Molodetskikh Date: Sun, 3 Nov 2024 10:14:24 +0300 Subject: Remove pointer_grab_ongoing in favor of checking the actual grab --- src/input/mod.rs | 8 +++++--- src/input/move_grab.rs | 1 - src/input/resize_grab.rs | 1 - src/input/spatial_movement_grab.rs | 1 - 4 files changed, 5 insertions(+), 6 deletions(-) (limited to 'src/input') diff --git a/src/input/mod.rs b/src/input/mod.rs index 888631e2..5800b8a4 100644 --- a/src/input/mod.rs +++ b/src/input/mod.rs @@ -1320,8 +1320,13 @@ impl State { self.niri.tablet_cursor_location = None; // Check if we have an active pointer constraint. + // + // FIXME: ideally this should use the pointer focus with up-to-date global location. let mut pointer_confined = None; if let Some(under) = &self.niri.pointer_contents.surface { + // No need to check if the pointer focus surface matches, because here we're checking + // for an already-active constraint, and the constraint is deactivated when the focused + // surface changes. let pos_within_surface = pos - under.1; let mut pointer_locked = false; @@ -1583,7 +1588,6 @@ impl State { }; let grab = MoveGrab::new(start_data, window.clone()); pointer.set_grab(self, grab, serial, Focus::Clear); - self.niri.pointer_grab_ongoing = true; self.niri .cursor_manager .set_cursor_image(CursorImageStatus::Named(CursorIcon::Move)); @@ -1649,7 +1653,6 @@ impl State { }; let grab = ResizeGrab::new(start_data, window.clone()); pointer.set_grab(self, grab, serial, Focus::Clear); - self.niri.pointer_grab_ongoing = true; self.niri.cursor_manager.set_cursor_image( CursorImageStatus::Named(edges.cursor_icon()), ); @@ -1685,7 +1688,6 @@ impl State { }; let grab = SpatialMovementGrab::new(start_data, output); pointer.set_grab(self, grab, serial, Focus::Clear); - self.niri.pointer_grab_ongoing = true; self.niri .cursor_manager .set_cursor_image(CursorImageStatus::Named(CursorIcon::AllScroll)); diff --git a/src/input/move_grab.rs b/src/input/move_grab.rs index 96230f33..a11a09cf 100644 --- a/src/input/move_grab.rs +++ b/src/input/move_grab.rs @@ -34,7 +34,6 @@ impl MoveGrab { state.niri.layout.interactive_move_end(&self.window); // FIXME: only redraw the window output. state.niri.queue_redraw_all(); - state.niri.pointer_grab_ongoing = false; state .niri .cursor_manager diff --git a/src/input/resize_grab.rs b/src/input/resize_grab.rs index 535bae32..5b58c7b0 100644 --- a/src/input/resize_grab.rs +++ b/src/input/resize_grab.rs @@ -22,7 +22,6 @@ impl ResizeGrab { fn on_ungrab(&mut self, state: &mut State) { state.niri.layout.interactive_resize_end(&self.window); - state.niri.pointer_grab_ongoing = false; state .niri .cursor_manager diff --git a/src/input/spatial_movement_grab.rs b/src/input/spatial_movement_grab.rs index 5a0e6a8a..7e6d81d0 100644 --- a/src/input/spatial_movement_grab.rs +++ b/src/input/spatial_movement_grab.rs @@ -50,7 +50,6 @@ impl SpatialMovementGrab { state.niri.queue_redraw(&output); } - state.niri.pointer_grab_ongoing = false; state .niri .cursor_manager -- cgit