Skip to main content

gdk4_x11/
functions.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::Atom as XAtom;
7
8#[cfg(not(feature = "xlib"))]
9use crate::XAtom;
10pub use crate::auto::functions::*;
11use crate::{X11Display, ffi};
12
13/// Returns the X atom for a [`gdk::Display`][crate::gdk::Display] corresponding to @atom_name.
14/// This function caches the result, so if called repeatedly it is much
15/// faster than XInternAtom(), which is a round trip to the server each time.
16///
17/// # Deprecated since 4.18
18///
19/// ## `display`
20/// a [`gdk::Display`][crate::gdk::Display]
21/// ## `atom_name`
22/// a string
23///
24/// # Returns
25///
26/// a X atom for a [`gdk::Display`][crate::gdk::Display]
27#[doc(alias = "gdk_x11_get_xatom_by_name_for_display")]
28pub fn x11_get_xatom_by_name_for_display(display: &X11Display, atom_name: impl IntoGStr) -> XAtom {
29    skip_assert_initialized!();
30    unsafe {
31        atom_name.run_with_gstr(|atom_name| {
32            ffi::gdk_x11_get_xatom_by_name_for_display(display.to_glib_none().0, atom_name.as_ptr())
33        })
34    }
35}
36
37/// t need to
38/// be freed.
39///
40/// # Deprecated since 4.18
41///
42/// ## `display`
43/// the [`gdk::Display`][crate::gdk::Display] where @xatom is defined
44/// ## `xatom`
45/// an X atom
46///
47/// # Returns
48///
49/// t be modified or freed.
50#[doc(alias = "gdk_x11_get_xatom_name_for_display")]
51pub fn x11_get_xatom_name_for_display(display: &X11Display, xatom: XAtom) -> Option<glib::GString> {
52    skip_assert_initialized!();
53    unsafe {
54        from_glib_none(ffi::gdk_x11_get_xatom_name_for_display(
55            display.to_glib_none().0,
56            xatom,
57        ))
58    }
59}