aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorIvan Molodetskikh <yalterz@gmail.com>2024-05-11 10:28:38 +0400
committerIvan Molodetskikh <yalterz@gmail.com>2024-05-11 10:28:38 +0400
commitde0ad857112384dbba0198bbd4481b2fd61204e3 (patch)
treed121d8955c358e17a9a9acd50d4c4bc2150c60e3 /src
parentf091e64b129b09a73d04d7fc757f9930709b6bf8 (diff)
downloadniri-de0ad857112384dbba0198bbd4481b2fd61204e3.tar.gz
niri-de0ad857112384dbba0198bbd4481b2fd61204e3.tar.bz2
niri-de0ad857112384dbba0198bbd4481b2fd61204e3.zip
Set cursor for niri-initiated interactive resize
Diffstat (limited to 'src')
-rw-r--r--src/input.rs3
-rw-r--r--src/resize_grab.rs12
-rw-r--r--src/utils/mod.rs17
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!(
"{} ({})",