diff options
| -rw-r--r-- | src/input.rs | 3 | ||||
| -rw-r--r-- | src/resize_grab.rs | 12 | ||||
| -rw-r--r-- | src/utils/mod.rs | 17 |
3 files changed, 28 insertions, 4 deletions
diff --git a/src/input.rs b/src/input.rs index cacbaaca..ccae9397 100644 --- a/src/input.rs +++ b/src/input.rs @@ -1137,6 +1137,9 @@ impl State { let grab = ResizeGrab::new(start_data, window.clone()); pointer.set_grab(self, grab, serial, Focus::Clear); self.niri.interactive_resize_ongoing = true; + self.niri + .cursor_manager + .set_cursor_image(CursorImageStatus::Named(edges.cursor_icon())); } } } diff --git a/src/resize_grab.rs b/src/resize_grab.rs index 21bca859..8c761558 100644 --- a/src/resize_grab.rs +++ b/src/resize_grab.rs @@ -1,9 +1,9 @@ use smithay::desktop::Window; use smithay::input::pointer::{ - AxisFrame, ButtonEvent, GestureHoldBeginEvent, GestureHoldEndEvent, GesturePinchBeginEvent, - GesturePinchEndEvent, GesturePinchUpdateEvent, GestureSwipeBeginEvent, GestureSwipeEndEvent, - GestureSwipeUpdateEvent, GrabStartData as PointerGrabStartData, MotionEvent, PointerGrab, - PointerInnerHandle, RelativeMotionEvent, + AxisFrame, ButtonEvent, CursorImageStatus, GestureHoldBeginEvent, GestureHoldEndEvent, + GesturePinchBeginEvent, GesturePinchEndEvent, GesturePinchUpdateEvent, GestureSwipeBeginEvent, + GestureSwipeEndEvent, GestureSwipeUpdateEvent, GrabStartData as PointerGrabStartData, + MotionEvent, PointerGrab, PointerInnerHandle, RelativeMotionEvent, }; use smithay::input::SeatHandler; use smithay::utils::{IsAlive, Logical, Point}; @@ -23,6 +23,10 @@ impl ResizeGrab { fn on_ungrab(&mut self, state: &mut State) { state.niri.layout.interactive_resize_end(&self.window); state.niri.interactive_resize_ongoing = false; + state + .niri + .cursor_manager + .set_cursor_image(CursorImageStatus::default_named()); } } diff --git a/src/utils/mod.rs b/src/utils/mod.rs index e22bd979..f523d960 100644 --- a/src/utils/mod.rs +++ b/src/utils/mod.rs @@ -11,6 +11,7 @@ use bitflags::bitflags; use directories::UserDirs; use git_version::git_version; use niri_config::Config; +use smithay::input::pointer::CursorIcon; use smithay::output::Output; use smithay::reexports::rustix::time::{clock_gettime, ClockId}; use smithay::reexports::wayland_protocols::xdg::shell::server::xdg_toplevel; @@ -49,6 +50,22 @@ impl From<xdg_toplevel::ResizeEdge> for ResizeEdge { } } +impl ResizeEdge { + pub fn cursor_icon(self) -> CursorIcon { + match self { + Self::LEFT => CursorIcon::WResize, + Self::RIGHT => CursorIcon::EResize, + Self::TOP => CursorIcon::NResize, + Self::BOTTOM => CursorIcon::SResize, + Self::TOP_LEFT => CursorIcon::NwResize, + Self::TOP_RIGHT => CursorIcon::NeResize, + Self::BOTTOM_RIGHT => CursorIcon::SeResize, + Self::BOTTOM_LEFT => CursorIcon::SwResize, + _ => CursorIcon::Default, + } + } +} + pub fn version() -> String { format!( "{} ({})", |
