diff --git a/satellite/src/clientside.rs b/satellite/src/clientside.rs index 23d6d9c..912043c 100644 --- a/satellite/src/clientside.rs +++ b/satellite/src/clientside.rs @@ -6,6 +6,7 @@ use wayland_client::protocol::{ wl_buffer::WlBuffer, wl_callback::WlCallback, wl_compositor::WlCompositor, wl_keyboard::WlKeyboard, wl_output::WlOutput, wl_pointer::WlPointer, wl_registry::WlRegistry, wl_seat::WlSeat, wl_shm::WlShm, wl_shm_pool::WlShmPool, wl_surface::WlSurface, + wl_touch::WlTouch, }; use wayland_client::{delegate_noop, Connection, Dispatch, EventQueue, Proxy, QueueHandle}; use wayland_protocols::wp::relative_pointer::zv1::client::{ @@ -198,3 +199,4 @@ push_events!(ZwpRelativePointerV1); push_events!(WlDrm); push_events!(DmabufFeedback); push_events!(XdgOutput); +push_events!(WlTouch); diff --git a/satellite/src/server/dispatch.rs b/satellite/src/server/dispatch.rs index 326197e..56b367e 100644 --- a/satellite/src/server/dispatch.rs +++ b/satellite/src/server/dispatch.rs @@ -27,7 +27,7 @@ use wayland_server::{ protocol::{ wl_buffer::WlBuffer, wl_callback::WlCallback, wl_compositor::WlCompositor, wl_keyboard::WlKeyboard, wl_output::WlOutput, wl_pointer::WlPointer, wl_seat::WlSeat, - wl_shm::WlShm, wl_shm_pool::WlShmPool, wl_surface::WlSurface, + wl_shm::WlShm, wl_shm_pool::WlShmPool, wl_surface::WlSurface, wl_touch::WlTouch, }, Dispatch, DisplayHandle, GlobalDispatch, Resource, }; @@ -313,6 +313,27 @@ impl Dispatch for ServerState { } } +impl Dispatch for ServerState { + fn request( + state: &mut Self, + _: &wayland_server::Client, + _: &WlTouch, + request: ::Request, + key: &ObjectKey, + _: &DisplayHandle, + _: &mut wayland_server::DataInit<'_, Self>, + ) { + match request { + Request::::Release => { + let Touch { client, .. }: &_ = state.objects[*key].as_ref(); + client.release(); + state.objects.remove(*key); + } + _ => unreachable!(), + } + } +} + impl Dispatch for ServerState { fn request( state: &mut Self, @@ -345,6 +366,16 @@ impl Dispatch for ServerState { Keyboard { client, server }.into() }); } + Request::::GetTouch { id } => { + state + .objects + .insert_from_other_objects([*key], |[seat_obj], key| { + let Seat { client, .. }: &Seat = seat_obj.try_into().unwrap(); + let client = client.get_touch(&state.qh, key); + let server = data_init.init(id, key); + Touch { client, server }.into() + }); + } other => warn!("unhandled seat request: {other:?}"), } } diff --git a/satellite/src/server/event.rs b/satellite/src/server/event.rs index 96ef300..5229264 100644 --- a/satellite/src/server/event.rs +++ b/satellite/src/server/event.rs @@ -17,7 +17,7 @@ use wayland_protocols::{ }; use wayland_server::protocol::{ wl_buffer::WlBuffer, wl_keyboard::WlKeyboard, wl_output::WlOutput, wl_pointer::WlPointer, - wl_seat::WlSeat, + wl_seat::WlSeat, wl_touch::WlTouch, }; /// Lord forgive me, I am a sinner, who's probably gonna sin again @@ -514,6 +514,47 @@ impl HandleEvent for Keyboard { } } +pub type Touch = GenericObject; +impl HandleEvent for Touch { + type Event = client::wl_touch::Event; + fn handle_event(&mut self, event: Self::Event, state: &mut ServerState) { + simple_event_shunt! { + self.server, event: client::wl_touch::Event => [ + Down { + serial, + time, + |surface| state.get_server_surface_from_client(surface), + id, + x, + y + }, + Up { + serial, + time, + id + }, + Motion { + time, + id, + x, + y + }, + Frame, + Cancel, + Shape { + id, + major, + minor + }, + Orientation { + id, + orientation + } + ] + } + } +} + pub type Output = GenericObject; impl HandleEvent for Output { type Event = client::wl_output::Event; diff --git a/satellite/src/server/mod.rs b/satellite/src/server/mod.rs index 36165a1..e0fa963 100644 --- a/satellite/src/server/mod.rs +++ b/satellite/src/server/mod.rs @@ -295,7 +295,8 @@ pub(crate) enum Object { RelativePointer(RelativePointer), DmabufFeedback(DmabufFeedback), Drm(Drm), - XdgOutput(XdgOutput) + XdgOutput(XdgOutput), + Touch(Touch) } }