gdk4_wayland/
wayland_monitor.rs1#[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")]
17 #[doc(alias = "get_wl_output")]
18 #[cfg(feature = "wayland_crate")]
19 #[cfg_attr(docsrs, doc(cfg(feature = "wayland_crate")))]
20 pub fn wl_output(&self) -> Option<WlOutput> {
21 let display = self.display().downcast::<crate::WaylandDisplay>().unwrap();
22 unsafe {
23 let output_ptr = ffi::gdk_wayland_monitor_get_wl_output(self.to_glib_none().0);
24 if output_ptr.is_null() {
25 None
26 } else {
27 let cnx = display.connection();
28 let id = ObjectId::from_ptr(WlOutput::interface(), output_ptr as *mut _).unwrap();
29
30 WlOutput::from_id(&cnx, id).ok()
31 }
32 }
33 }
34}