Skip to content

Commit

Permalink
set cursor shape for resize grabs
Browse files Browse the repository at this point in the history
  • Loading branch information
m4rch3n1ng authored and Drakulix committed Oct 24, 2024
1 parent 9a9eddb commit 65a5470
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion src/shell/layout/floating/grabs/resize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
use std::sync::atomic::{AtomicBool, Ordering};

use crate::{
backend::render::cursor::CursorState,
shell::{
element::CosmicMapped,
focus::target::PointerFocusTarget,
Expand All @@ -15,7 +16,7 @@ use smithay::{
desktop::{space::SpaceElement, WindowSurface},
input::{
pointer::{
AxisFrame, ButtonEvent, GestureHoldBeginEvent, GestureHoldEndEvent,
AxisFrame, ButtonEvent, CursorIcon, GestureHoldBeginEvent, GestureHoldEndEvent,
GesturePinchBeginEvent, GesturePinchEndEvent, GesturePinchUpdateEvent,
GestureSwipeBeginEvent, GestureSwipeEndEvent, GestureSwipeUpdateEvent,
GrabStartData as PointerGrabStartData, MotionEvent, PointerGrab, PointerInnerHandle,
Expand Down Expand Up @@ -390,6 +391,22 @@ impl ResizeSurfaceGrab {
.0
.store(true, Ordering::SeqCst);

let shape = match edges {
ResizeEdge::TOP_LEFT => Some(CursorIcon::NwResize),
ResizeEdge::TOP_RIGHT => Some(CursorIcon::NeResize),
ResizeEdge::BOTTOM_LEFT => Some(CursorIcon::SwResize),
ResizeEdge::BOTTOM_RIGHT => Some(CursorIcon::SeResize),
ResizeEdge::TOP => Some(CursorIcon::NResize),
ResizeEdge::RIGHT => Some(CursorIcon::EResize),
ResizeEdge::BOTTOM => Some(CursorIcon::SResize),
ResizeEdge::LEFT => Some(CursorIcon::WResize),
_ => None,
};
if let Some(shape) = shape {
let cursor_state = seat.user_data().get::<CursorState>().unwrap();
cursor_state.lock().unwrap().set_shape(shape);
}

ResizeSurfaceGrab {
start_data,
seat: seat.clone(),
Expand Down Expand Up @@ -524,3 +541,10 @@ impl ResizeSurfaceGrab {
}
}
}

impl Drop for ResizeSurfaceGrab {
fn drop(&mut self) {
let cursor_state = self.seat.user_data().get::<CursorState>().unwrap();
cursor_state.lock().unwrap().unset_shape();
}
}

0 comments on commit 65a5470

Please sign in to comment.