Skip to content

Commit 65a5470

Browse files
m4rch3n1ngDrakulix
authored andcommitted
set cursor shape for resize grabs
1 parent 9a9eddb commit 65a5470

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

src/shell/layout/floating/grabs/resize.rs

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
use std::sync::atomic::{AtomicBool, Ordering};
44

55
use crate::{
6+
backend::render::cursor::CursorState,
67
shell::{
78
element::CosmicMapped,
89
focus::target::PointerFocusTarget,
@@ -15,7 +16,7 @@ use smithay::{
1516
desktop::{space::SpaceElement, WindowSurface},
1617
input::{
1718
pointer::{
18-
AxisFrame, ButtonEvent, GestureHoldBeginEvent, GestureHoldEndEvent,
19+
AxisFrame, ButtonEvent, CursorIcon, GestureHoldBeginEvent, GestureHoldEndEvent,
1920
GesturePinchBeginEvent, GesturePinchEndEvent, GesturePinchUpdateEvent,
2021
GestureSwipeBeginEvent, GestureSwipeEndEvent, GestureSwipeUpdateEvent,
2122
GrabStartData as PointerGrabStartData, MotionEvent, PointerGrab, PointerInnerHandle,
@@ -390,6 +391,22 @@ impl ResizeSurfaceGrab {
390391
.0
391392
.store(true, Ordering::SeqCst);
392393

394+
let shape = match edges {
395+
ResizeEdge::TOP_LEFT => Some(CursorIcon::NwResize),
396+
ResizeEdge::TOP_RIGHT => Some(CursorIcon::NeResize),
397+
ResizeEdge::BOTTOM_LEFT => Some(CursorIcon::SwResize),
398+
ResizeEdge::BOTTOM_RIGHT => Some(CursorIcon::SeResize),
399+
ResizeEdge::TOP => Some(CursorIcon::NResize),
400+
ResizeEdge::RIGHT => Some(CursorIcon::EResize),
401+
ResizeEdge::BOTTOM => Some(CursorIcon::SResize),
402+
ResizeEdge::LEFT => Some(CursorIcon::WResize),
403+
_ => None,
404+
};
405+
if let Some(shape) = shape {
406+
let cursor_state = seat.user_data().get::<CursorState>().unwrap();
407+
cursor_state.lock().unwrap().set_shape(shape);
408+
}
409+
393410
ResizeSurfaceGrab {
394411
start_data,
395412
seat: seat.clone(),
@@ -524,3 +541,10 @@ impl ResizeSurfaceGrab {
524541
}
525542
}
526543
}
544+
545+
impl Drop for ResizeSurfaceGrab {
546+
fn drop(&mut self) {
547+
let cursor_state = self.seat.user_data().get::<CursorState>().unwrap();
548+
cursor_state.lock().unwrap().unset_shape();
549+
}
550+
}

0 commit comments

Comments
 (0)