gdk4_x11/
x11_surface.rs

1// Take a look at the license at the top of the repository in the LICENSE file.
2
3use glib::translate::*;
4#[cfg(feature = "xlib")]
5#[cfg_attr(docsrs, doc(cfg(feature = "xlib")))]
6use x11::xlib::Window as XWindow;
7
8#[cfg(not(feature = "xlib"))]
9use crate::XWindow;
10use crate::{ffi, X11Surface};
11
12impl X11Surface {
13    /// Returns the X resource (surface) belonging to a [`gdk::Surface`][crate::gdk::Surface].
14    ///
15    /// # Deprecated since 4.18
16    ///
17    ///
18    /// # Returns
19    ///
20    /// the ID of @drawable’s X resource.
21    #[doc(alias = "gdk_x11_surface_get_xid")]
22    #[doc(alias = "get_xid")]
23    pub fn xid(&self) -> XWindow {
24        unsafe { ffi::gdk_x11_surface_get_xid(self.to_glib_none().0) }
25    }
26
27    /// Looks up the [`gdk::Surface`][crate::gdk::Surface] that wraps the given native window handle.
28    ///
29    /// # Deprecated since 4.18
30    ///
31    /// ## `display`
32    /// the [`gdk::Display`][crate::gdk::Display] corresponding to the
33    ///   window handle
34    /// ## `window`
35    /// an Xlib Window
36    ///
37    /// # Returns
38    ///
39    /// the [`gdk::Surface`][crate::gdk::Surface] wrapper
40    ///   for the native  window
41    #[doc(alias = "gdk_x11_surface_lookup_for_display")]
42    pub fn lookup_for_display(display: &crate::X11Display, window: XWindow) -> Option<X11Surface> {
43        skip_assert_initialized!();
44        unsafe {
45            from_glib_none(ffi::gdk_x11_surface_lookup_for_display(
46                display.to_glib_none().0,
47                window,
48            ))
49        }
50    }
51}