diff --git a/src/handlers/xdg_shell.rs b/src/handlers/xdg_shell.rs index 171b65fd..54fe0b2f 100644 --- a/src/handlers/xdg_shell.rs +++ b/src/handlers/xdg_shell.rs @@ -134,13 +134,13 @@ impl XdgShellHandler for State { match &start_data { PointerOrTouchStartData::Pointer(_) => { - if let Some(grab) = MoveGrab::new(self, start_data, window.clone(), true) { + if let Some(grab) = MoveGrab::new(self, start_data, window.clone(), true, None) { pointer.set_grab(self, grab, serial, Focus::Clear); } } PointerOrTouchStartData::Touch(_) => { let touch = self.niri.seat.get_touch().unwrap(); - if let Some(grab) = MoveGrab::new(self, start_data, window.clone(), true) { + if let Some(grab) = MoveGrab::new(self, start_data, window.clone(), true, None) { touch.set_grab(self, grab, serial); } } diff --git a/src/input/mod.rs b/src/input/mod.rs index 81e5d863..0bbb145d 100644 --- a/src/input/mod.rs +++ b/src/input/mod.rs @@ -2857,8 +2857,22 @@ impl State { location, }; let start_data = PointerOrTouchStartData::Pointer(start_data); - if let Some(grab) = MoveGrab::new(self, start_data, window.clone(), false) { + let icon = CursorIcon::Grabbing; + if let Some(grab) = + MoveGrab::new(self, start_data, window.clone(), false, Some(icon)) + { pointer.set_grab(self, grab, serial, Focus::Clear); + + // Set the cursor to Grabbing right away for Mod+LMB since it doesn't + // do any other gesture. + // + // In the overview, we click to activate window and close the overview, + // in this case setting the cursor right away would be distracting. + if !is_overview_open { + self.niri + .cursor_manager + .set_cursor_image(CursorImageStatus::Named(icon)); + } } } } @@ -4106,7 +4120,8 @@ impl State { location: pos, }; let start_data = PointerOrTouchStartData::Touch(start_data); - if let Some(grab) = MoveGrab::new(self, start_data, window.clone(), true) { + if let Some(grab) = MoveGrab::new(self, start_data, window.clone(), true, None) + { handle.set_grab(self, grab, serial); } } diff --git a/src/input/move_grab.rs b/src/input/move_grab.rs index c78b796e..cca4780f 100644 --- a/src/input/move_grab.rs +++ b/src/input/move_grab.rs @@ -27,6 +27,7 @@ pub struct MoveGrab { window: Window, gesture: GestureState, enable_view_offset: bool, + move_icon: CursorIcon, } #[derive(Debug, Clone, Copy, PartialEq, Eq)] @@ -42,6 +43,7 @@ impl MoveGrab { start_data: PointerOrTouchStartData, window: Window, enable_view_offset: bool, + move_icon: Option, ) -> Option { let (output, pos_within_output) = state.niri.output_under(start_data.location())?; @@ -53,6 +55,8 @@ impl MoveGrab { window, gesture: GestureState::Recognizing, enable_view_offset, + // Moving windows by their titlebars uses the default cursor by default. + move_icon: move_icon.unwrap_or(CursorIcon::Default), }) } @@ -112,7 +116,7 @@ impl MoveGrab { if self.start_data.is_pointer() { data.niri .cursor_manager - .set_cursor_image(CursorImageStatus::Named(CursorIcon::Move)); + .set_cursor_image(CursorImageStatus::Named(self.move_icon)); } true