wayland: Implement cursor-shape-v1
This commit is contained in:
parent
79ae56c601
commit
0ffe6ae718
9 changed files with 92 additions and 161 deletions
|
|
@ -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);
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -2,9 +2,8 @@
|
|||
|
||||
use crate::{
|
||||
backend::render::{
|
||||
cursor::{CursorShape, CursorState},
|
||||
element::AsGlowRenderer,
|
||||
BackdropShader, IndicatorShader, Key, SplitRenderElements, Usage,
|
||||
cursor::CursorState, element::AsGlowRenderer, BackdropShader, IndicatorShader, Key,
|
||||
SplitRenderElements, Usage,
|
||||
},
|
||||
shell::{
|
||||
element::{
|
||||
|
|
@ -32,7 +31,7 @@ use smithay::{
|
|||
desktop::{layer_map_for_output, space::SpaceElement},
|
||||
input::{
|
||||
pointer::{
|
||||
AxisFrame, ButtonEvent, GestureHoldBeginEvent, GestureHoldEndEvent,
|
||||
AxisFrame, ButtonEvent, CursorIcon, GestureHoldBeginEvent, GestureHoldEndEvent,
|
||||
GesturePinchBeginEvent, GesturePinchEndEvent, GesturePinchUpdateEvent,
|
||||
GestureSwipeBeginEvent, GestureSwipeEndEvent, GestureSwipeUpdateEvent,
|
||||
GrabStartData as PointerGrabStartData, MotionEvent, PointerGrab, PointerInnerHandle,
|
||||
|
|
@ -710,7 +709,7 @@ impl MoveGrab {
|
|||
|
||||
{
|
||||
let cursor_state = seat.user_data().get::<CursorState>().unwrap();
|
||||
cursor_state.lock().unwrap().set_shape(CursorShape::Grab);
|
||||
cursor_state.lock().unwrap().set_shape(CursorIcon::Grab);
|
||||
}
|
||||
|
||||
MoveGrab {
|
||||
|
|
@ -850,7 +849,7 @@ impl Drop for MoveGrab {
|
|||
|
||||
{
|
||||
let cursor_state = seat.user_data().get::<CursorState>().unwrap();
|
||||
cursor_state.lock().unwrap().set_shape(CursorShape::Default);
|
||||
cursor_state.lock().unwrap().unset_shape();
|
||||
}
|
||||
|
||||
if let Some((mapped, position)) = position {
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
use crate::{
|
||||
backend::render::cursor::{CursorShape, CursorState},
|
||||
backend::render::cursor::CursorState,
|
||||
shell::{
|
||||
focus::target::PointerFocusTarget,
|
||||
grabs::{GrabStartData, ReleaseMode},
|
||||
|
|
@ -14,7 +14,7 @@ use smithay::{
|
|||
backend::input::ButtonState,
|
||||
input::{
|
||||
pointer::{
|
||||
AxisFrame, ButtonEvent, Focus, GestureHoldBeginEvent, GestureHoldEndEvent,
|
||||
AxisFrame, ButtonEvent, CursorIcon, Focus, GestureHoldBeginEvent, GestureHoldEndEvent,
|
||||
GesturePinchBeginEvent, GesturePinchEndEvent, GesturePinchUpdateEvent,
|
||||
GestureSwipeBeginEvent, GestureSwipeEndEvent, GestureSwipeUpdateEvent,
|
||||
GrabStartData as PointerGrabStartData, MotionEvent, PointerGrab, PointerInnerHandle,
|
||||
|
|
@ -54,8 +54,8 @@ impl PointerTarget<State> for ResizeForkTarget {
|
|||
.lock()
|
||||
.unwrap()
|
||||
.set_shape(match self.orientation {
|
||||
Orientation::Horizontal => CursorShape::RowResize,
|
||||
Orientation::Vertical => CursorShape::ColResize,
|
||||
Orientation::Horizontal => CursorIcon::RowResize,
|
||||
Orientation::Vertical => CursorIcon::ColResize,
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -68,7 +68,7 @@ impl PointerTarget<State> for ResizeForkTarget {
|
|||
) {
|
||||
let user_data = seat.user_data();
|
||||
let cursor_state = user_data.get::<CursorState>().unwrap();
|
||||
cursor_state.lock().unwrap().set_shape(CursorShape::Default)
|
||||
cursor_state.lock().unwrap().unset_shape();
|
||||
}
|
||||
|
||||
fn button(&self, seat: &Seat<State>, data: &mut State, event: &ButtonEvent) {
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
use std::{any::Any, cell::RefCell, collections::HashMap, sync::Mutex, time::Duration};
|
||||
use std::{any::Any, cell::RefCell, collections::HashMap, sync::Mutex};
|
||||
|
||||
use crate::{
|
||||
backend::render::cursor::{CursorShape, CursorState},
|
||||
backend::render::cursor::CursorState,
|
||||
config::{xkb_config_to_wl, Config},
|
||||
input::{ModifiersShortcutQueue, SupressedButtons, SupressedKeys},
|
||||
state::State,
|
||||
|
|
@ -13,7 +13,7 @@ use smithay::{
|
|||
desktop::utils::bbox_from_surface_tree,
|
||||
input::{
|
||||
keyboard::{LedState, XkbConfig},
|
||||
pointer::{CursorIcon, CursorImageAttributes, CursorImageStatus},
|
||||
pointer::{CursorImageAttributes, CursorImageStatus},
|
||||
Seat, SeatState,
|
||||
},
|
||||
output::Output,
|
||||
|
|
@ -347,17 +347,15 @@ impl SeatExt for Seat<State> {
|
|||
);
|
||||
Some((buffer_geo, (hotspot.x, hotspot.y).into()))
|
||||
}
|
||||
CursorImageStatus::Named(CursorIcon::Default) => {
|
||||
CursorImageStatus::Named(cursor_icon) => {
|
||||
let seat_userdata = self.user_data();
|
||||
seat_userdata.insert_if_missing_threadsafe(CursorState::default);
|
||||
let state = seat_userdata.get::<CursorState>().unwrap();
|
||||
let frame = state
|
||||
.lock()
|
||||
.unwrap()
|
||||
.cursors
|
||||
.get(&CursorShape::Default)
|
||||
.unwrap()
|
||||
.get_image(1, Into::<Duration>::into(time).as_millis() as u32);
|
||||
.get_named_cursor(cursor_icon)
|
||||
.get_image(1, time.as_millis());
|
||||
|
||||
Some((
|
||||
Rectangle::from_loc_and_size(
|
||||
|
|
@ -367,10 +365,6 @@ impl SeatExt for Seat<State> {
|
|||
(frame.xhot as i32, frame.yhot as i32).into(),
|
||||
))
|
||||
}
|
||||
CursorImageStatus::Named(_) => {
|
||||
// TODO: Handle for `cursor_shape_v1` protocol
|
||||
None
|
||||
}
|
||||
CursorImageStatus::Hidden => None,
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue