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