gdk4_wayland/
wayland_monitor.rs
1#[cfg(feature = "wayland_crate")]
4#[cfg_attr(docsrs, doc(cfg(feature = "wayland_crate")))]
5use wayland_client::{backend::ObjectId, protocol::wl_output::WlOutput, 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::WaylandMonitor;
14
15impl WaylandMonitor {
16 #[doc(alias = "gdk_wayland_monitor_get_wl_output")]
22 #[doc(alias = "get_wl_output")]
23 #[cfg(feature = "wayland_crate")]
24 #[cfg_attr(docsrs, doc(cfg(feature = "wayland_crate")))]
25 pub fn wl_output(&self) -> Option<WlOutput> {
26 let display = self.display().downcast::<crate::WaylandDisplay>().unwrap();
27 unsafe {
28 let output_ptr = ffi::gdk_wayland_monitor_get_wl_output(self.to_glib_none().0);
29 if output_ptr.is_null() {
30 None
31 } else {
32 let cnx = display.connection();
33 let id = ObjectId::from_ptr(WlOutput::interface(), output_ptr as *mut _).unwrap();
34
35 WlOutput::from_id(&cnx, id).ok()
36 }
37 }
38 }
39}