Remove pointer_grab_ongoing in favor of checking the actual grab
Browse files at this commite0ebf1bdff06c38ae3cc9e3114b41572cb792dc0Parent: 11633ae6 changed files +6 -13
- src/handlers/xdg_shell.rs +0 -2
- src/input/mod.rs +5 -3
- src/input/move_grab.rs +0 -1
- src/input/resize_grab.rs +0 -1
- src/input/spatial_movement_grab.rs +0 -1
- src/niri.rs +1 -5
src/handlers/xdg_shell.rsmodified+0 -2
| @@ -148,7 +148,6 @@ impl XdgShellHandler for State { | |||
| 148 | PointerOrTouchStartData::Pointer(start_data) => { | 148 | PointerOrTouchStartData::Pointer(start_data) => { |
| 149 | let grab = MoveGrab::new(start_data, window); | 149 | let grab = MoveGrab::new(start_data, window); |
| 150 | pointer.set_grab(self, grab, serial, Focus::Clear); | 150 | pointer.set_grab(self, grab, serial, Focus::Clear); |
| 151 | - self.niri.pointer_grab_ongoing = true; | ||
| 152 | } | 151 | } |
| 153 | PointerOrTouchStartData::Touch(start_data) => { | 152 | PointerOrTouchStartData::Touch(start_data) => { |
| 154 | let touch = self.niri.seat.get_touch().unwrap(); | 153 | let touch = self.niri.seat.get_touch().unwrap(); |
| @@ -246,7 +245,6 @@ impl XdgShellHandler for State { | |||
| 246 | PointerOrTouchStartData::Pointer(start_data) => { | 245 | PointerOrTouchStartData::Pointer(start_data) => { |
| 247 | let grab = ResizeGrab::new(start_data, window); | 246 | let grab = ResizeGrab::new(start_data, window); |
| 248 | pointer.set_grab(self, grab, serial, Focus::Clear); | 247 | pointer.set_grab(self, grab, serial, Focus::Clear); |
| 249 | - self.niri.pointer_grab_ongoing = true; | ||
| 250 | } | 248 | } |
| 251 | PointerOrTouchStartData::Touch(start_data) => { | 249 | PointerOrTouchStartData::Touch(start_data) => { |
| 252 | let touch = self.niri.seat.get_touch().unwrap(); | 250 | let touch = self.niri.seat.get_touch().unwrap(); |
src/input/mod.rsmodified+5 -3
| @@ -1320,8 +1320,13 @@ impl State { | |||
| 1320 | self.niri.tablet_cursor_location = None; | 1320 | self.niri.tablet_cursor_location = None; |
| 1321 | 1321 | ||
| 1322 | // Check if we have an active pointer constraint. | 1322 | // Check if we have an active pointer constraint. |
| 1323 | + // | ||
| 1324 | + // FIXME: ideally this should use the pointer focus with up-to-date global location. | ||
| 1323 | let mut pointer_confined = None; | 1325 | let mut pointer_confined = None; |
| 1324 | if let Some(under) = &self.niri.pointer_contents.surface { | 1326 | if let Some(under) = &self.niri.pointer_contents.surface { |
| 1327 | + // No need to check if the pointer focus surface matches, because here we're checking | ||
| 1328 | + // for an already-active constraint, and the constraint is deactivated when the focused | ||
| 1329 | + // surface changes. | ||
| 1325 | let pos_within_surface = pos - under.1; | 1330 | let pos_within_surface = pos - under.1; |
| 1326 | 1331 | ||
| 1327 | let mut pointer_locked = false; | 1332 | let mut pointer_locked = false; |
| @@ -1583,7 +1588,6 @@ impl State { | |||
| 1583 | }; | 1588 | }; |
| 1584 | let grab = MoveGrab::new(start_data, window.clone()); | 1589 | let grab = MoveGrab::new(start_data, window.clone()); |
| 1585 | pointer.set_grab(self, grab, serial, Focus::Clear); | 1590 | pointer.set_grab(self, grab, serial, Focus::Clear); |
| 1586 | - self.niri.pointer_grab_ongoing = true; | ||
| 1587 | self.niri | 1591 | self.niri |
| 1588 | .cursor_manager | 1592 | .cursor_manager |
| 1589 | .set_cursor_image(CursorImageStatus::Named(CursorIcon::Move)); | 1593 | .set_cursor_image(CursorImageStatus::Named(CursorIcon::Move)); |
| @@ -1649,7 +1653,6 @@ impl State { | |||
| 1649 | }; | 1653 | }; |
| 1650 | let grab = ResizeGrab::new(start_data, window.clone()); | 1654 | let grab = ResizeGrab::new(start_data, window.clone()); |
| 1651 | pointer.set_grab(self, grab, serial, Focus::Clear); | 1655 | pointer.set_grab(self, grab, serial, Focus::Clear); |
| 1652 | - self.niri.pointer_grab_ongoing = true; | ||
| 1653 | self.niri.cursor_manager.set_cursor_image( | 1656 | self.niri.cursor_manager.set_cursor_image( |
| 1654 | CursorImageStatus::Named(edges.cursor_icon()), | 1657 | CursorImageStatus::Named(edges.cursor_icon()), |
| 1655 | ); | 1658 | ); |
| @@ -1685,7 +1688,6 @@ impl State { | |||
| 1685 | }; | 1688 | }; |
| 1686 | let grab = SpatialMovementGrab::new(start_data, output); | 1689 | let grab = SpatialMovementGrab::new(start_data, output); |
| 1687 | pointer.set_grab(self, grab, serial, Focus::Clear); | 1690 | pointer.set_grab(self, grab, serial, Focus::Clear); |
| 1688 | - self.niri.pointer_grab_ongoing = true; | ||
| 1689 | self.niri | 1691 | self.niri |
| 1690 | .cursor_manager | 1692 | .cursor_manager |
| 1691 | .set_cursor_image(CursorImageStatus::Named(CursorIcon::AllScroll)); | 1693 | .set_cursor_image(CursorImageStatus::Named(CursorIcon::AllScroll)); |
src/input/move_grab.rsmodified+0 -1
| @@ -34,7 +34,6 @@ impl MoveGrab { | |||
| 34 | state.niri.layout.interactive_move_end(&self.window); | 34 | state.niri.layout.interactive_move_end(&self.window); |
| 35 | // FIXME: only redraw the window output. | 35 | // FIXME: only redraw the window output. |
| 36 | state.niri.queue_redraw_all(); | 36 | state.niri.queue_redraw_all(); |
| 37 | - state.niri.pointer_grab_ongoing = false; | ||
| 38 | state | 37 | state |
| 39 | .niri | 38 | .niri |
| 40 | .cursor_manager | 39 | .cursor_manager |
src/input/resize_grab.rsmodified+0 -1
| @@ -22,7 +22,6 @@ impl ResizeGrab { | |||
| 22 | 22 | ||
| 23 | fn on_ungrab(&mut self, state: &mut State) { | 23 | fn on_ungrab(&mut self, state: &mut State) { |
| 24 | state.niri.layout.interactive_resize_end(&self.window); | 24 | state.niri.layout.interactive_resize_end(&self.window); |
| 25 | - state.niri.pointer_grab_ongoing = false; | ||
| 26 | state | 25 | state |
| 27 | .niri | 26 | .niri |
| 28 | .cursor_manager | 27 | .cursor_manager |
src/input/spatial_movement_grab.rsmodified+0 -1
| @@ -50,7 +50,6 @@ impl SpatialMovementGrab { | |||
| 50 | state.niri.queue_redraw(&output); | 50 | state.niri.queue_redraw(&output); |
| 51 | } | 51 | } |
| 52 | 52 | ||
| 53 | - state.niri.pointer_grab_ongoing = false; | ||
| 54 | state | 53 | state |
| 55 | .niri | 54 | .niri |
| 56 | .cursor_manager | 55 | .cursor_manager |
src/niri.rsmodified+1 -5
| @@ -282,8 +282,6 @@ pub struct Niri { | |||
| 282 | /// various tooltips from sticking around. | 282 | /// various tooltips from sticking around. |
| 283 | pub pointer_hidden: bool, | 283 | pub pointer_hidden: bool, |
| 284 | pub pointer_inactivity_timer: Option<RegistrationToken>, | 284 | pub pointer_inactivity_timer: Option<RegistrationToken>, |
| 285 | - // FIXME: this should be able to be removed once PointerFocus takes grabs into account. | ||
| 286 | - pub pointer_grab_ongoing: bool, | ||
| 287 | pub tablet_cursor_location: Option<Point<f64, Logical>>, | 285 | pub tablet_cursor_location: Option<Point<f64, Logical>>, |
| 288 | pub gesture_swipe_3f_cumulative: Option<(f64, f64)>, | 286 | pub gesture_swipe_3f_cumulative: Option<(f64, f64)>, |
| 289 | pub vertical_wheel_tracker: ScrollTracker, | 287 | pub vertical_wheel_tracker: ScrollTracker, |
| @@ -1877,7 +1875,6 @@ impl Niri { | |||
| 1877 | pointer_contents: PointContents::default(), | 1875 | pointer_contents: PointContents::default(), |
| 1878 | pointer_hidden: false, | 1876 | pointer_hidden: false, |
| 1879 | pointer_inactivity_timer: None, | 1877 | pointer_inactivity_timer: None, |
| 1880 | - pointer_grab_ongoing: false, | ||
| 1881 | tablet_cursor_location: None, | 1878 | tablet_cursor_location: None, |
| 1882 | gesture_swipe_3f_cumulative: None, | 1879 | gesture_swipe_3f_cumulative: None, |
| 1883 | vertical_wheel_tracker: ScrollTracker::new(120), | 1880 | vertical_wheel_tracker: ScrollTracker::new(120), |
| @@ -4526,8 +4523,7 @@ impl Niri { | |||
| 4526 | let Some((surface, surface_loc)) = &self.pointer_contents.surface else { | 4523 | let Some((surface, surface_loc)) = &self.pointer_contents.surface else { |
| 4527 | return; | 4524 | return; |
| 4528 | }; | 4525 | }; |
| 4529 | - | 4526 | + if Some(surface) != pointer.current_focus().as_ref() { |
| 4530 | - if self.pointer_grab_ongoing { | ||
| 4531 | return; | 4527 | return; |
| 4532 | } | 4528 | } |
| 4533 | 4529 | ||