Add wl_touch support

Fixes #1
This commit is contained in:
Shawn Wallace 2024-04-29 19:35:46 -04:00
parent 7aaf98e5e0
commit e70cb81751
4 changed files with 78 additions and 3 deletions

View file

@ -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<WlTouch, client::wl_touch::WlTouch>;
impl HandleEvent for Touch {
type Event = client::wl_touch::Event;
fn handle_event<C: XConnection>(&mut self, event: Self::Event, state: &mut ServerState<C>) {
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<WlOutput, client::wl_output::WlOutput>;
impl HandleEvent for Output {
type Event = client::wl_output::Event;