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
8pub use crate::auto::functions::*;
9#[cfg(not(feature = "xlib"))]
10use crate::XAtom;
11use crate::{ffi, X11Display};
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/// Returns the name of an X atom for its display. This
38/// function is meant mainly for debugging, so for convenience, unlike
39/// XAtomName() and the result doesn’t need to
40/// be freed.
41///
42/// # Deprecated since 4.18
43///
44/// ## `display`
45/// the [`gdk::Display`][crate::gdk::Display] where @xatom is defined
46/// ## `xatom`
47/// an X atom
48///
49/// # Returns
50///
51/// name of the X atom; this string is owned by GDK,
52///   so it shouldn’t be modified or freed.
53#[doc(alias = "gdk_x11_get_xatom_name_for_display")]
54pub fn x11_get_xatom_name_for_display(display: &X11Display, xatom: XAtom) -> Option<glib::GString> {
55    skip_assert_initialized!();
56    unsafe {
57        from_glib_none(ffi::gdk_x11_get_xatom_name_for_display(
58            display.to_glib_none().0,
59            xatom,
60        ))
61    }
62}