shell: Touch support for move grab

Touch support is still needed for other grabs. And SSDs (and libcosmic)
need to start move/menu/etc. based on touch.
This commit is contained in:
Ian Douglas Scott 2024-04-04 19:17:03 -07:00 committed by Victoria Brekenfeld
parent 895ea6aec1
commit b18a3a8bc7
5 changed files with 208 additions and 83 deletions

View file

@ -1,9 +1,13 @@
use smithay::{
input::pointer::{
AxisFrame, ButtonEvent, GestureHoldBeginEvent, GestureHoldEndEvent, GesturePinchBeginEvent,
GesturePinchEndEvent, GesturePinchUpdateEvent, GestureSwipeBeginEvent,
GestureSwipeEndEvent, GestureSwipeUpdateEvent, GrabStartData as PointerGrabStartData,
MotionEvent, PointerGrab, PointerInnerHandle, RelativeMotionEvent,
input::{
pointer::{
AxisFrame, ButtonEvent, GestureHoldBeginEvent, GestureHoldEndEvent,
GesturePinchBeginEvent, GesturePinchEndEvent, GesturePinchUpdateEvent,
GestureSwipeBeginEvent, GestureSwipeEndEvent, GestureSwipeUpdateEvent,
GrabStartData as PointerGrabStartData, MotionEvent, PointerGrab, PointerInnerHandle,
RelativeMotionEvent,
},
touch::GrabStartData as TouchGrabStartData,
},
reexports::wayland_protocols::xdg::shell::server::xdg_toplevel,
utils::{Logical, Point},
@ -17,6 +21,35 @@ use super::{
layout::{floating::ResizeSurfaceGrab, tiling::ResizeForkGrab},
};
#[derive(Debug, Clone)]
pub enum GrabStartData {
Touch(TouchGrabStartData<State>),
Pointer(PointerGrabStartData<State>),
}
impl GrabStartData {
pub fn focus(&self) -> Option<&(PointerFocusTarget, Point<i32, Logical>)> {
match self {
Self::Touch(touch) => touch.focus.as_ref(),
Self::Pointer(pointer) => pointer.focus.as_ref(),
}
}
pub fn set_focus(&mut self, focus: Option<(PointerFocusTarget, Point<i32, Logical>)>) {
match self {
Self::Touch(touch) => touch.focus = focus,
Self::Pointer(pointer) => pointer.focus = focus,
}
}
pub fn location(&self) -> Point<f64, Logical> {
match self {
Self::Touch(touch) => touch.location,
Self::Pointer(pointer) => pointer.location,
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum ReleaseMode {
Click,