Set cursor for niri-initiated interactive resize
Browse files at this commitde0ad857112384dbba0198bbd4481b2fd61204e3Parent: f091e643 changed files +28 -4
- src/input.rs +3 -0
- src/resize_grab.rs +8 -4
- src/utils/mod.rs +17 -0
src/input.rsmodified+3 -0
| @@ -1137,6 +1137,9 @@ impl State { | |||
| 1137 | let grab = ResizeGrab::new(start_data, window.clone()); | 1137 | let grab = ResizeGrab::new(start_data, window.clone()); |
| 1138 | pointer.set_grab(self, grab, serial, Focus::Clear); | 1138 | pointer.set_grab(self, grab, serial, Focus::Clear); |
| 1139 | self.niri.interactive_resize_ongoing = true; | 1139 | self.niri.interactive_resize_ongoing = true; |
| 1140 | + self.niri | ||
| 1141 | + .cursor_manager | ||
| 1142 | + .set_cursor_image(CursorImageStatus::Named(edges.cursor_icon())); | ||
| 1140 | } | 1143 | } |
| 1141 | } | 1144 | } |
| 1142 | } | 1145 | } |
src/resize_grab.rsmodified+8 -4
| @@ -1,9 +1,9 @@ | |||
| 1 | use smithay::desktop::Window; | 1 | use smithay::desktop::Window; |
| 2 | use smithay::input::pointer::{ | 2 | use smithay::input::pointer::{ |
| 3 | - AxisFrame, ButtonEvent, GestureHoldBeginEvent, GestureHoldEndEvent, GesturePinchBeginEvent, | 3 | + AxisFrame, ButtonEvent, CursorImageStatus, GestureHoldBeginEvent, GestureHoldEndEvent, |
| 4 | - GesturePinchEndEvent, GesturePinchUpdateEvent, GestureSwipeBeginEvent, GestureSwipeEndEvent, | 4 | + GesturePinchBeginEvent, GesturePinchEndEvent, GesturePinchUpdateEvent, GestureSwipeBeginEvent, |
| 5 | - GestureSwipeUpdateEvent, GrabStartData as PointerGrabStartData, MotionEvent, PointerGrab, | 5 | + GestureSwipeEndEvent, GestureSwipeUpdateEvent, GrabStartData as PointerGrabStartData, |
| 6 | - PointerInnerHandle, RelativeMotionEvent, | 6 | + MotionEvent, PointerGrab, PointerInnerHandle, RelativeMotionEvent, |
| 7 | }; | 7 | }; |
| 8 | use smithay::input::SeatHandler; | 8 | use smithay::input::SeatHandler; |
| 9 | use smithay::utils::{IsAlive, Logical, Point}; | 9 | use smithay::utils::{IsAlive, Logical, Point}; |
| @@ -23,6 +23,10 @@ impl ResizeGrab { | |||
| 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.interactive_resize_ongoing = false; | 25 | state.niri.interactive_resize_ongoing = false; |
| 26 | + state | ||
| 27 | + .niri | ||
| 28 | + .cursor_manager | ||
| 29 | + .set_cursor_image(CursorImageStatus::default_named()); | ||
| 26 | } | 30 | } |
| 27 | } | 31 | } |
| 28 | 32 | ||
src/utils/mod.rsmodified+17 -0
| @@ -11,6 +11,7 @@ use bitflags::bitflags; | |||
| 11 | use directories::UserDirs; | 11 | use directories::UserDirs; |
| 12 | use git_version::git_version; | 12 | use git_version::git_version; |
| 13 | use niri_config::Config; | 13 | use niri_config::Config; |
| 14 | +use smithay::input::pointer::CursorIcon; | ||
| 14 | use smithay::output::Output; | 15 | use smithay::output::Output; |
| 15 | use smithay::reexports::rustix::time::{clock_gettime, ClockId}; | 16 | use smithay::reexports::rustix::time::{clock_gettime, ClockId}; |
| 16 | use smithay::reexports::wayland_protocols::xdg::shell::server::xdg_toplevel; | 17 | use smithay::reexports::wayland_protocols::xdg::shell::server::xdg_toplevel; |
| @@ -49,6 +50,22 @@ impl From<xdg_toplevel::ResizeEdge> for ResizeEdge { | |||
| 49 | } | 50 | } |
| 50 | } | 51 | } |
| 51 | 52 | ||
| 53 | +impl ResizeEdge { | ||
| 54 | + pub fn cursor_icon(self) -> CursorIcon { | ||
| 55 | + match self { | ||
| 56 | + Self::LEFT => CursorIcon::WResize, | ||
| 57 | + Self::RIGHT => CursorIcon::EResize, | ||
| 58 | + Self::TOP => CursorIcon::NResize, | ||
| 59 | + Self::BOTTOM => CursorIcon::SResize, | ||
| 60 | + Self::TOP_LEFT => CursorIcon::NwResize, | ||
| 61 | + Self::TOP_RIGHT => CursorIcon::NeResize, | ||
| 62 | + Self::BOTTOM_RIGHT => CursorIcon::SeResize, | ||
| 63 | + Self::BOTTOM_LEFT => CursorIcon::SwResize, | ||
| 64 | + _ => CursorIcon::Default, | ||
| 65 | + } | ||
| 66 | + } | ||
| 67 | +} | ||
| 68 | + | ||
| 52 | pub fn version() -> String { | 69 | pub fn version() -> String { |
| 53 | format!( | 70 | format!( |
| 54 | "{} ({})", | 71 | "{} ({})", |