1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// Take a look at the license at the top of the repository in the LICENSE file.

use glib::translate::*;
#[cfg(feature = "xlib")]
#[cfg_attr(docsrs, doc(cfg(feature = "xlib")))]
use x11::xlib::Window as XWindow;

use crate::X11Surface;
#[cfg(not(feature = "xlib"))]
use crate::XWindow;

impl X11Surface {
    /// Returns the X resource (surface) belonging to a [`gdk::Surface`][crate::gdk::Surface].
    ///
    /// # Returns
    ///
    /// the ID of @drawable’s X resource.
    #[doc(alias = "gdk_x11_surface_get_xid")]
    #[doc(alias = "get_xid")]
    pub fn xid(&self) -> XWindow {
        unsafe { ffi::gdk_x11_surface_get_xid(self.to_glib_none().0) }
    }

    /// Looks up the [`gdk::Surface`][crate::gdk::Surface] that wraps the given native window handle.
    /// ## `display`
    /// the [`gdk::Display`][crate::gdk::Display] corresponding to the
    ///   window handle
    /// ## `window`
    /// an Xlib Window
    ///
    /// # Returns
    ///
    /// the [`gdk::Surface`][crate::gdk::Surface] wrapper
    ///   for the native  window
    #[doc(alias = "gdk_x11_surface_lookup_for_display")]
    pub fn lookup_for_display(display: &crate::X11Display, window: XWindow) -> Option<X11Surface> {
        skip_assert_initialized!();
        unsafe {
            from_glib_none(ffi::gdk_x11_surface_lookup_for_display(
                display.to_glib_none().0,
                window,
            ))
        }
    }
}