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
46
47
48
49
50
51
52
53
// Take a look at the license at the top of the repository in the LICENSE file.

use crate::X11Display;
use glib::translate::ToGlibPtr;
#[cfg(any(feature = "v4_4", feature = "dox"))]
use khronos_egl as egl;
use x11::xlib;

impl X11Display {
    /// Retrieves the EGL display connection object for the given GDK display.
    ///
    /// This function returns `NULL` if GDK is using GLX.
    ///
    /// # Returns
    ///
    /// the EGL display object
    #[cfg(any(feature = "v4_4", feature = "dox"))]
    #[cfg_attr(feature = "dox", doc(cfg(feature = "v4_4")))]
    #[doc(alias = "gdk_x11_display_get_egl_display")]
    #[doc(alias = "get_egl_display")]
    pub fn egl_display(&self) -> Option<egl::Display> {
        unsafe {
            let ptr = ffi::gdk_x11_display_get_egl_display(self.to_glib_none().0);
            if ptr.is_null() {
                None
            } else {
                Some(egl::Display::from_ptr(ptr))
            }
        }
    }

    /// Returns the X display of a [`gdk::Display`][crate::gdk::Display].
    ///
    /// # Returns
    ///
    /// an X display
    #[doc(alias = "gdk_x11_display_get_xdisplay")]
    #[doc(alias = "get_xdisplay")]
    pub unsafe fn xdisplay(&self) -> *mut xlib::Display {
        ffi::gdk_x11_display_get_xdisplay(self.to_glib_none().0)
    }

    /// Returns the X Screen used by [`gdk::Display`][crate::gdk::Display].
    ///
    /// # Returns
    ///
    /// an X Screen
    #[doc(alias = "gdk_x11_display_get_xscreen")]
    #[doc(alias = "get_xscreen")]
    pub unsafe fn xscreen(&self) -> *mut xlib::Screen {
        ffi::gdk_x11_display_get_xscreen(self.to_glib_none().0)
    }
}