parent
7aaf98e5e0
commit
e70cb81751
4 changed files with 78 additions and 3 deletions
|
|
@ -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<C: XConnection> Dispatch<WlKeyboard, ObjectKey> for ServerState<C> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<C: XConnection> Dispatch<WlTouch, ObjectKey> for ServerState<C> {
|
||||
fn request(
|
||||
state: &mut Self,
|
||||
_: &wayland_server::Client,
|
||||
_: &WlTouch,
|
||||
request: <WlTouch as Resource>::Request,
|
||||
key: &ObjectKey,
|
||||
_: &DisplayHandle,
|
||||
_: &mut wayland_server::DataInit<'_, Self>,
|
||||
) {
|
||||
match request {
|
||||
Request::<WlTouch>::Release => {
|
||||
let Touch { client, .. }: &_ = state.objects[*key].as_ref();
|
||||
client.release();
|
||||
state.objects.remove(*key);
|
||||
}
|
||||
_ => unreachable!(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<C: XConnection> Dispatch<WlSeat, ObjectKey> for ServerState<C> {
|
||||
fn request(
|
||||
state: &mut Self,
|
||||
|
|
@ -345,6 +366,16 @@ impl<C: XConnection> Dispatch<WlSeat, ObjectKey> for ServerState<C> {
|
|||
Keyboard { client, server }.into()
|
||||
});
|
||||
}
|
||||
Request::<WlSeat>::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:?}"),
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -295,7 +295,8 @@ pub(crate) enum Object {
|
|||
RelativePointer(RelativePointer),
|
||||
DmabufFeedback(DmabufFeedback),
|
||||
Drm(Drm),
|
||||
XdgOutput(XdgOutput)
|
||||
XdgOutput(XdgOutput),
|
||||
Touch(Touch)
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue