gdk4_x11/functions.rs
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 54 55 56
// 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::Atom as XAtom;
pub use crate::auto::functions::*;
#[cfg(not(feature = "xlib"))]
use crate::XAtom;
use crate::{ffi, X11Display};
/// Returns the X atom for a [`gdk::Display`][crate::gdk::Display] corresponding to @atom_name.
/// This function caches the result, so if called repeatedly it is much
/// faster than XInternAtom(), which is a round trip to the server each time.
/// ## `display`
/// a [`gdk::Display`][crate::gdk::Display]
/// ## `atom_name`
/// a string
///
/// # Returns
///
/// a X atom for a [`gdk::Display`][crate::gdk::Display]
#[doc(alias = "gdk_x11_get_xatom_by_name_for_display")]
pub fn x11_get_xatom_by_name_for_display(display: &X11Display, atom_name: impl IntoGStr) -> XAtom {
skip_assert_initialized!();
unsafe {
atom_name.run_with_gstr(|atom_name| {
ffi::gdk_x11_get_xatom_by_name_for_display(display.to_glib_none().0, atom_name.as_ptr())
})
}
}
/// Returns the name of an X atom for its display. This
/// function is meant mainly for debugging, so for convenience, unlike
/// XAtomName() and the result doesn’t need to
/// be freed.
/// ## `display`
/// the [`gdk::Display`][crate::gdk::Display] where @xatom is defined
/// ## `xatom`
/// an X atom
///
/// # Returns
///
/// name of the X atom; this string is owned by GDK,
/// so it shouldn’t be modified or freed.
#[doc(alias = "gdk_x11_get_xatom_name_for_display")]
pub fn x11_get_xatom_name_for_display(display: &X11Display, xatom: XAtom) -> Option<glib::GString> {
skip_assert_initialized!();
unsafe {
from_glib_none(ffi::gdk_x11_get_xatom_name_for_display(
display.to_glib_none().0,
xatom,
))
}
}