gdk4_wayland/
wayland_seat.rs
1#[cfg(feature = "wayland_crate")]
4#[cfg_attr(docsrs, doc(cfg(feature = "wayland_crate")))]
5use wayland_client::{backend::ObjectId, protocol::wl_seat::WlSeat, Proxy};
6#[cfg(feature = "wayland_crate")]
7#[cfg_attr(docsrs, doc(cfg(feature = "wayland_crate")))]
8use {
9 crate::{ffi, prelude::*},
10 glib::translate::*,
11};
12
13use crate::WaylandSeat;
14
15impl WaylandSeat {
16 #[doc(alias = "gdk_wayland_seat_get_wl_seat")]
22 #[doc(alias = "get_wl_seat")]
23 #[cfg(feature = "wayland_crate")]
24 #[cfg_attr(docsrs, doc(cfg(feature = "wayland_crate")))]
25 pub fn wl_seat(&self) -> Option<WlSeat> {
26 let display = self.display().downcast::<crate::WaylandDisplay>().unwrap();
27 unsafe {
28 let seat_ptr = ffi::gdk_wayland_seat_get_wl_seat(self.to_glib_none().0);
29 if seat_ptr.is_null() {
30 None
31 } else {
32 let cnx = display.connection();
33 let id = ObjectId::from_ptr(WlSeat::interface(), seat_ptr as *mut _).unwrap();
34
35 WlSeat::from_id(&cnx, id).ok()
36 }
37 }
38 }
39}