gdk4_wayland/
wayland_seat.rs1use std::ffi::c_void;
4use std::ptr::NonNull;
5
6#[cfg(feature = "wayland_crate")]
7#[cfg_attr(docsrs, doc(cfg(feature = "wayland_crate")))]
8use wayland_client::{Proxy, backend::ObjectId, protocol::wl_seat::WlSeat};
9
10#[cfg(feature = "wayland_crate")]
11#[cfg_attr(docsrs, doc(cfg(feature = "wayland_crate")))]
12use crate::prelude::*;
13use crate::{WaylandSeat, ffi};
14use glib::translate::*;
15
16impl WaylandSeat {
17 #[doc(alias = "gdk_wayland_seat_get_wl_seat")]
18 #[doc(alias = "get_wl_seat")]
19 pub fn wl_seat_raw(&self) -> Option<NonNull<c_void>> {
20 NonNull::new(unsafe { ffi::gdk_wayland_seat_get_wl_seat(self.to_glib_none().0) })
21 }
22
23 #[doc(alias = "gdk_wayland_seat_get_wl_seat")]
29 #[doc(alias = "get_wl_seat")]
30 #[cfg(feature = "wayland_crate")]
31 #[cfg_attr(docsrs, doc(cfg(feature = "wayland_crate")))]
32 pub fn wl_seat(&self) -> Option<WlSeat> {
33 let display = self.display().downcast::<crate::WaylandDisplay>().unwrap();
34 let ptr = self.wl_seat_raw()?;
35 unsafe {
36 let cnx = display.connection();
37 let id = ObjectId::from_ptr(WlSeat::interface(), ptr.as_ptr() as *mut _).unwrap();
38
39 WlSeat::from_id(&cnx, id).ok()
40 }
41 }
42}