gdkwayland/wayland_seat.rs
1// Take a look at the license at the top of the repository in the LICENSE file.
2
3use gdk::prelude::*;
4use glib::translate::ToGlibPtr;
5
6use wayland_client::backend::ObjectId;
7use wayland_client::protocol::wl_seat::WlSeat;
8use wayland_client::Proxy;
9
10glib::wrapper! {
11 #[doc(alias = "GdkWaylandSeat")]
12 pub struct WaylandSeat(Object<ffi::GdkWaylandSeat>) @extends gdk::Seat;
13
14 match fn {
15 type_ => || ffi::gdk_wayland_seat_get_type(),
16 }
17}
18
19impl WaylandSeat {
20 #[doc(alias = "gdk_wayland_seat_get_wl_seat")]
21 #[doc(alias = "get_wl_seat")]
22 pub fn wl_seat(&self) -> Option<WlSeat> {
23 unsafe {
24 let seat_ptr = ffi::gdk_wayland_seat_get_wl_seat(self.to_glib_none().0);
25 if seat_ptr.is_null() {
26 None
27 } else {
28 let display = self.display()?.unsafe_cast::<crate::WaylandDisplay>();
29 let cnx = display.connection();
30 let id = ObjectId::from_ptr(WlSeat::interface(), seat_ptr as *mut _).unwrap();
31
32 WlSeat::from_id(&cnx, id).ok()
33 }
34 }
35 }
36}