Skip to main content

gdkx11/auto/
functions.rs

1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from gir-files (https://github.com/gtk-rs/gir-files)
3// DO NOT EDIT
4
5use crate::{X11DeviceCore, X11DeviceManagerCore, X11Display, X11Window};
6use glib::{prelude::*, translate::*};
7use x11::xlib;
8
9/// Converts from a [`gdk::Atom`][crate::gdk::Atom] to the X atom for the default GDK display
10/// with the same string value.
11/// ## `atom`
12/// A [`gdk::Atom`][crate::gdk::Atom]
13///
14/// # Returns
15///
16/// the X atom corresponding to `atom`.
17#[doc(alias = "gdk_x11_atom_to_xatom")]
18pub fn x11_atom_to_xatom(atom: &gdk::Atom) -> xlib::Atom {
19    assert_initialized_main_thread!();
20    unsafe { ffi::gdk_x11_atom_to_xatom(atom.to_glib_none().0) }
21}
22
23/// Converts from a [`gdk::Atom`][crate::gdk::Atom] to the X atom for a [`gdk::Display`][crate::gdk::Display]
24/// with the same string value. The special value `GDK_NONE`
25/// is converted to `None`.
26/// ## `display`
27/// A [`gdk::Display`][crate::gdk::Display]
28/// ## `atom`
29/// A [`gdk::Atom`][crate::gdk::Atom], or `GDK_NONE`
30///
31/// # Returns
32///
33/// the X atom corresponding to `atom`, or `None`
34#[doc(alias = "gdk_x11_atom_to_xatom_for_display")]
35pub fn x11_atom_to_xatom_for_display(display: &X11Display, atom: &gdk::Atom) -> xlib::Atom {
36    skip_assert_initialized!();
37    unsafe {
38        ffi::gdk_x11_atom_to_xatom_for_display(display.to_glib_none().0, atom.to_glib_none().0)
39    }
40}
41
42/// Returns the device ID as seen by XInput2.
43///
44/// > If `gdk_disable_multidevice()` has been called, this function
45/// > will respectively return 2/3 for the core pointer and keyboard,
46/// > (matching the IDs for the Virtual Core Pointer and Keyboard in
47/// > XInput 2), but calling this function on any slave devices (i.e.
48/// > those managed via XInput 1.x), will return 0.
49/// ## `device`
50/// a [`gdk::Device`][crate::gdk::Device]
51///
52/// # Returns
53///
54/// the XInput2 device ID.
55#[doc(alias = "gdk_x11_device_get_id")]
56pub fn x11_device_get_id(device: &X11DeviceCore) -> i32 {
57    skip_assert_initialized!();
58    unsafe { ffi::gdk_x11_device_get_id(device.to_glib_none().0) }
59}
60
61/// Returns the [`gdk::Device`][crate::gdk::Device] that wraps the given device ID.
62/// ## `device_manager`
63/// a [`gdk::DeviceManager`][crate::gdk::DeviceManager]
64/// ## `device_id`
65/// a device ID, as understood by the XInput2 protocol
66///
67/// # Returns
68///
69/// The [`gdk::Device`][crate::gdk::Device] wrapping the device ID,
70///  or [`None`] if the given ID doesn’t currently represent a device.
71#[doc(alias = "gdk_x11_device_manager_lookup")]
72pub fn x11_device_manager_lookup(
73    device_manager: &impl IsA<X11DeviceManagerCore>,
74    device_id: i32,
75) -> Option<X11DeviceCore> {
76    skip_assert_initialized!();
77    unsafe {
78        from_glib_none(ffi::gdk_x11_device_manager_lookup(
79            device_manager.as_ref().to_glib_none().0,
80            device_id,
81        ))
82    }
83}
84
85/// Gets the root window of the default screen
86/// (see [`x11_get_default_screen()`][crate::x11_get_default_screen()]).
87///
88/// # Returns
89///
90/// an Xlib Window.
91#[doc(alias = "gdk_x11_get_default_root_xwindow")]
92pub fn x11_get_default_root_xwindow() -> xlib::Window {
93    assert_initialized_main_thread!();
94    unsafe { ffi::gdk_x11_get_default_root_xwindow() }
95}
96
97/// Gets the default GTK+ screen number.
98///
99/// # Returns
100///
101/// returns the screen number specified by
102///  the --display command line option or the DISPLAY environment
103///  variable when `gdk_init()` calls XOpenDisplay().
104#[doc(alias = "gdk_x11_get_default_screen")]
105pub fn x11_get_default_screen() -> i32 {
106    assert_initialized_main_thread!();
107    unsafe { ffi::gdk_x11_get_default_screen() }
108}
109
110//#[cfg_attr(feature = "v3_24", deprecated = "Since 3.24")]
111//#[cfg(feature = "v3_24_2")]
112//#[cfg_attr(docsrs, doc(cfg(feature = "v3_24_2")))]
113//#[allow(deprecated)]
114//#[doc(alias = "gdk_x11_get_parent_relative_pattern")]
115//pub fn x11_get_parent_relative_pattern() -> /*Ignored*/Option<cairo::Pattern> {
116//    unsafe { TODO: call ffi:gdk_x11_get_parent_relative_pattern() }
117//}
118
119/// Routine to get the current X server time stamp.
120/// ## `window`
121/// a [`gdk::Window`][crate::gdk::Window], used for communication
122///  with the server. The window must have
123///  GDK_PROPERTY_CHANGE_MASK in its events mask or a hang will
124///  result.
125///
126/// # Returns
127///
128/// the time stamp.
129#[doc(alias = "gdk_x11_get_server_time")]
130pub fn x11_get_server_time(window: &X11Window) -> u32 {
131    skip_assert_initialized!();
132    unsafe { ffi::gdk_x11_get_server_time(window.to_glib_none().0) }
133}
134
135/// Returns the X atom for GDK’s default display corresponding to `atom_name`.
136/// This function caches the result, so if called repeatedly it is much
137/// faster than XInternAtom(), which is a round trip to the server each time.
138/// ## `atom_name`
139/// a string
140///
141/// # Returns
142///
143/// a X atom for GDK’s default display.
144#[doc(alias = "gdk_x11_get_xatom_by_name")]
145pub fn x11_get_xatom_by_name(atom_name: &str) -> xlib::Atom {
146    assert_initialized_main_thread!();
147    unsafe { ffi::gdk_x11_get_xatom_by_name(atom_name.to_glib_none().0) }
148}
149
150/// Returns the X atom for a [`gdk::Display`][crate::gdk::Display] corresponding to `atom_name`.
151/// This function caches the result, so if called repeatedly it is much
152/// faster than XInternAtom(), which is a round trip to the server each time.
153/// ## `display`
154/// a [`gdk::Display`][crate::gdk::Display]
155/// ## `atom_name`
156/// a string
157///
158/// # Returns
159///
160/// a X atom for a [`gdk::Display`][crate::gdk::Display]
161#[doc(alias = "gdk_x11_get_xatom_by_name_for_display")]
162pub fn x11_get_xatom_by_name_for_display(display: &X11Display, atom_name: &str) -> xlib::Atom {
163    skip_assert_initialized!();
164    unsafe {
165        ffi::gdk_x11_get_xatom_by_name_for_display(
166            display.to_glib_none().0,
167            atom_name.to_glib_none().0,
168        )
169    }
170}
171
172/// Returns the name of an X atom for GDK’s default display. This
173/// function is meant mainly for debugging, so for convenience, unlike
174/// XAtomName() and [`gdk::Atom::name()`][crate::gdk::Atom::name()], the result
175/// doesn’t need to be freed. Also, this function will never return [`None`],
176/// even if `xatom` is invalid.
177/// ## `xatom`
178/// an X atom for GDK’s default display
179///
180/// # Returns
181///
182/// name of the X atom; this string is owned by GTK+,
183///  so it shouldn’t be modifed or freed.
184#[doc(alias = "gdk_x11_get_xatom_name")]
185pub fn x11_get_xatom_name(xatom: xlib::Atom) -> Option<glib::GString> {
186    assert_initialized_main_thread!();
187    unsafe { from_glib_none(ffi::gdk_x11_get_xatom_name(xatom)) }
188}
189
190/// Returns the name of an X atom for its display. This
191/// function is meant mainly for debugging, so for convenience, unlike
192/// XAtomName() and [`gdk::Atom::name()`][crate::gdk::Atom::name()], the result doesn’t need to
193/// be freed.
194/// ## `display`
195/// the [`gdk::Display`][crate::gdk::Display] where `xatom` is defined
196/// ## `xatom`
197/// an X atom
198///
199/// # Returns
200///
201/// name of the X atom; this string is owned by GDK,
202///  so it shouldn’t be modifed or freed.
203#[doc(alias = "gdk_x11_get_xatom_name_for_display")]
204pub fn x11_get_xatom_name_for_display(
205    display: &X11Display,
206    xatom: xlib::Atom,
207) -> Option<glib::GString> {
208    skip_assert_initialized!();
209    unsafe {
210        from_glib_none(ffi::gdk_x11_get_xatom_name_for_display(
211            display.to_glib_none().0,
212            xatom,
213        ))
214    }
215}
216
217/// Call [`X11Display::grab()`][crate::X11Display::grab()] on the default display.
218/// To ungrab the server again, use [`x11_ungrab_server()`][crate::x11_ungrab_server()].
219///
220/// [`x11_grab_server()`][crate::x11_grab_server()]/[`x11_ungrab_server()`][crate::x11_ungrab_server()] calls can be nested.
221#[doc(alias = "gdk_x11_grab_server")]
222pub fn x11_grab_server() {
223    assert_initialized_main_thread!();
224    unsafe {
225        ffi::gdk_x11_grab_server();
226    }
227}
228
229/// Registers interest in receiving extension events with type codes
230/// between `event_base` and `event_base + n_events - 1`.
231/// The registered events must have the window field in the same place
232/// as core X events (this is not the case for e.g. XKB extension events).
233///
234/// If an event type is registered, events of this type will go through
235/// global and window-specific filters (see [`WindowExtManual::add_filter()`][crate::gdk::prelude::WindowExtManual::add_filter()]).
236/// Unregistered events will only go through global filters.
237/// GDK may register the events of some X extensions on its own.
238///
239/// This function should only be needed in unusual circumstances, e.g.
240/// when filtering XInput extension events on the root window.
241/// ## `display`
242/// a [`gdk::Display`][crate::gdk::Display]
243/// ## `event_base`
244/// first event type code to register
245/// ## `n_events`
246/// number of event type codes to register
247#[doc(alias = "gdk_x11_register_standard_event_type")]
248pub fn x11_register_standard_event_type(display: &X11Display, event_base: i32, n_events: i32) {
249    skip_assert_initialized!();
250    unsafe {
251        ffi::gdk_x11_register_standard_event_type(display.to_glib_none().0, event_base, n_events);
252    }
253}
254
255/// Sets the `SM_CLIENT_ID` property on the application’s leader window so that
256/// the window manager can save the application’s state using the X11R6 ICCCM
257/// session management protocol.
258///
259/// See the X Session Management Library documentation for more information on
260/// session management and the Inter-Client Communication Conventions Manual
261/// ## `sm_client_id`
262/// the client id assigned by the session manager
263///  when the connection was opened, or [`None`] to remove the property.
264#[doc(alias = "gdk_x11_set_sm_client_id")]
265pub fn x11_set_sm_client_id(sm_client_id: Option<&str>) {
266    assert_initialized_main_thread!();
267    unsafe {
268        ffi::gdk_x11_set_sm_client_id(sm_client_id.to_glib_none().0);
269    }
270}
271
272/// Ungrab the default display after it has been grabbed with
273/// [`x11_grab_server()`][crate::x11_grab_server()].
274#[doc(alias = "gdk_x11_ungrab_server")]
275pub fn x11_ungrab_server() {
276    assert_initialized_main_thread!();
277    unsafe {
278        ffi::gdk_x11_ungrab_server();
279    }
280}
281
282/// Convert from an X atom for the default display to the corresponding
283/// [`gdk::Atom`][crate::gdk::Atom].
284/// ## `xatom`
285/// an X atom for the default GDK display
286///
287/// # Returns
288///
289/// the corresponding G`dkAtom`.
290#[doc(alias = "gdk_x11_xatom_to_atom")]
291pub fn x11_xatom_to_atom(xatom: xlib::Atom) -> Option<gdk::Atom> {
292    assert_initialized_main_thread!();
293    unsafe { from_glib_none(ffi::gdk_x11_xatom_to_atom(xatom)) }
294}
295
296/// Convert from an X atom for a [`gdk::Display`][crate::gdk::Display] to the corresponding
297/// [`gdk::Atom`][crate::gdk::Atom].
298/// ## `display`
299/// A [`gdk::Display`][crate::gdk::Display]
300/// ## `xatom`
301/// an X atom
302///
303/// # Returns
304///
305/// the corresponding [`gdk::Atom`][crate::gdk::Atom].
306#[doc(alias = "gdk_x11_xatom_to_atom_for_display")]
307pub fn x11_xatom_to_atom_for_display(display: &X11Display, xatom: xlib::Atom) -> Option<gdk::Atom> {
308    skip_assert_initialized!();
309    unsafe {
310        from_glib_none(ffi::gdk_x11_xatom_to_atom_for_display(
311            display.to_glib_none().0,
312            xatom,
313        ))
314    }
315}