wayland: Implement cursor-shape-v1

This commit is contained in:
may 2024-09-09 16:21:27 +02:00 committed by GitHub
parent 79ae56c601
commit 0ffe6ae718
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 92 additions and 161 deletions

View file

@ -1,9 +1,6 @@
use super::{surface::RESIZE_BORDER, window::Focus, CosmicSurface};
use crate::{
backend::render::{
cursor::{CursorShape, CursorState},
SplitRenderElements,
},
backend::render::{cursor::CursorState, SplitRenderElements},
shell::{
focus::target::PointerFocusTarget,
grabs::{ReleaseMode, ResizeEdge},
@ -1331,7 +1328,7 @@ impl PointerTarget<State> for CosmicStack {
.unwrap()
.lock()
.unwrap();
cursor_state.set_shape(CursorShape::Default);
cursor_state.unset_shape();
let _previous = p.swap_focus(None);
});

View file

@ -1,8 +1,5 @@
use crate::{
backend::render::{
cursor::{CursorShape, CursorState},
SplitRenderElements,
},
backend::render::{cursor::CursorState, SplitRenderElements},
shell::{
focus::target::PointerFocusTarget,
grabs::{ReleaseMode, ResizeEdge},
@ -35,10 +32,10 @@ use smithay::{
input::{
keyboard::{KeyboardTarget, KeysymHandle, ModifiersState},
pointer::{
AxisFrame, ButtonEvent, CursorImageStatus, GestureHoldBeginEvent, GestureHoldEndEvent,
GesturePinchBeginEvent, GesturePinchEndEvent, GesturePinchUpdateEvent,
GestureSwipeBeginEvent, GestureSwipeEndEvent, GestureSwipeUpdateEvent, MotionEvent,
PointerTarget, RelativeMotionEvent,
AxisFrame, ButtonEvent, CursorIcon, CursorImageStatus, GestureHoldBeginEvent,
GestureHoldEndEvent, GesturePinchBeginEvent, GesturePinchEndEvent,
GesturePinchUpdateEvent, GestureSwipeBeginEvent, GestureSwipeEndEvent,
GestureSwipeUpdateEvent, MotionEvent, PointerTarget, RelativeMotionEvent,
},
touch::{
DownEvent, MotionEvent as TouchMotionEvent, OrientationEvent, ShapeEvent, TouchTarget,
@ -146,17 +143,17 @@ impl Focus {
}
}
pub fn cursor_shape(&self) -> CursorShape {
pub fn cursor_shape(&self) -> CursorIcon {
match self {
Focus::ResizeTopLeft => CursorShape::NorthWestResize,
Focus::ResizeTopRight => CursorShape::NorthEastResize,
Focus::ResizeTop => CursorShape::NorthResize,
Focus::ResizeBottomLeft => CursorShape::SouthWestResize,
Focus::ResizeBottomRight => CursorShape::SouthEastResize,
Focus::ResizeBottom => CursorShape::SouthResize,
Focus::ResizeLeft => CursorShape::WestResize,
Focus::ResizeRight => CursorShape::EastResize,
Focus::Header => CursorShape::Default,
Focus::ResizeTopLeft => CursorIcon::NwResize,
Focus::ResizeTopRight => CursorIcon::NeResize,
Focus::ResizeTop => CursorIcon::NResize,
Focus::ResizeBottomLeft => CursorIcon::SwResize,
Focus::ResizeBottomRight => CursorIcon::SeResize,
Focus::ResizeBottom => CursorIcon::SResize,
Focus::ResizeLeft => CursorIcon::WResize,
Focus::ResizeRight => CursorIcon::EResize,
Focus::Header => CursorIcon::Default,
}
}
@ -754,7 +751,7 @@ impl PointerTarget<State> for CosmicWindow {
fn leave(&self, seat: &Seat<State>, data: &mut State, serial: Serial, time: u32) {
self.0.with_program(|p| {
let cursor_state = seat.user_data().get::<CursorState>().unwrap();
cursor_state.lock().unwrap().set_shape(CursorShape::Default);
cursor_state.lock().unwrap().unset_shape();
let _previous = p.swap_focus(None);
});
PointerTarget::leave(&self.0, seat, data, serial, time)