gdkx11/auto/x11_display.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::ffi;
6use glib::{prelude::*, translate::*};
7
8glib::wrapper! {
9 ///
10 ///
11 /// # Implements
12 ///
13 /// [`trait@gdk::prelude::DisplayExt`]
14 #[doc(alias = "GdkX11Display")]
15 pub struct X11Display(Object<ffi::GdkX11Display, ffi::GdkX11DisplayClass>) @extends gdk::Display;
16
17 match fn {
18 type_ => || ffi::gdk_x11_display_get_type(),
19 }
20}
21
22impl X11Display {
23 //#[doc(alias = "gdk_x11_display_broadcast_startup_message")]
24 //pub fn broadcast_startup_message(&self, message_type: &str, : /*Unknown conversion*//*Unimplemented*/Basic: VarArgs) {
25 // unsafe { TODO: call ffi:gdk_x11_display_broadcast_startup_message() }
26 //}
27
28 /// Pops the error trap pushed by [`error_trap_push()`][Self::error_trap_push()].
29 /// Will XSync() if necessary and will always block until
30 /// the error is known to have occurred or not occurred,
31 /// so the error code can be returned.
32 ///
33 /// If you don’t need to use the return value,
34 /// [`error_trap_pop_ignored()`][Self::error_trap_pop_ignored()] would be more efficient.
35 ///
36 /// See `gdk_error_trap_pop()` for the all-displays-at-once
37 /// equivalent.
38 ///
39 /// # Returns
40 ///
41 /// X error code or 0 on success
42 #[doc(alias = "gdk_x11_display_error_trap_pop")]
43 pub fn error_trap_pop(&self) -> i32 {
44 unsafe { ffi::gdk_x11_display_error_trap_pop(self.to_glib_none().0) }
45 }
46
47 /// Pops the error trap pushed by [`error_trap_push()`][Self::error_trap_push()].
48 /// Does not block to see if an error occurred; merely records the
49 /// range of requests to ignore errors for, and ignores those errors
50 /// if they arrive asynchronously.
51 ///
52 /// See `gdk_error_trap_pop_ignored()` for the all-displays-at-once
53 /// equivalent.
54 #[doc(alias = "gdk_x11_display_error_trap_pop_ignored")]
55 pub fn error_trap_pop_ignored(&self) {
56 unsafe {
57 ffi::gdk_x11_display_error_trap_pop_ignored(self.to_glib_none().0);
58 }
59 }
60
61 /// Begins a range of X requests on `self` for which X error events
62 /// will be ignored. Unignored errors (when no trap is pushed) will abort
63 /// the application. Use [`error_trap_pop()`][Self::error_trap_pop()] or
64 /// [`error_trap_pop_ignored()`][Self::error_trap_pop_ignored()]to lift a trap pushed
65 /// with this function.
66 ///
67 /// See also `gdk_error_trap_push()` to push a trap on all displays.
68 #[doc(alias = "gdk_x11_display_error_trap_push")]
69 pub fn error_trap_push(&self) {
70 unsafe {
71 ffi::gdk_x11_display_error_trap_push(self.to_glib_none().0);
72 }
73 }
74
75 /// Gets the startup notification ID for a display.
76 ///
77 /// # Returns
78 ///
79 /// the startup notification ID for `self`
80 #[doc(alias = "gdk_x11_display_get_startup_notification_id")]
81 #[doc(alias = "get_startup_notification_id")]
82 pub fn startup_notification_id(&self) -> Option<glib::GString> {
83 unsafe {
84 from_glib_none(ffi::gdk_x11_display_get_startup_notification_id(
85 self.to_glib_none().0,
86 ))
87 }
88 }
89
90 /// Returns the timestamp of the last user interaction on
91 /// `self`. The timestamp is taken from events caused
92 /// by user interaction such as key presses or pointer
93 /// movements. See [`X11Window::set_user_time()`][crate::X11Window::set_user_time()].
94 ///
95 /// # Returns
96 ///
97 /// the timestamp of the last user interaction
98 #[doc(alias = "gdk_x11_display_get_user_time")]
99 #[doc(alias = "get_user_time")]
100 pub fn user_time(&self) -> u32 {
101 unsafe { ffi::gdk_x11_display_get_user_time(self.to_glib_none().0) }
102 }
103
104 /// Call XGrabServer() on `self`.
105 /// To ungrab the display again, use [`ungrab()`][Self::ungrab()].
106 ///
107 /// [`grab()`][Self::grab()]/[`ungrab()`][Self::ungrab()] calls can be nested.
108 #[doc(alias = "gdk_x11_display_grab")]
109 pub fn grab(&self) {
110 unsafe {
111 ffi::gdk_x11_display_grab(self.to_glib_none().0);
112 }
113 }
114
115 /// Sets the cursor theme from which the images for cursor
116 /// should be taken.
117 ///
118 /// If the windowing system supports it, existing cursors created
119 /// with `gdk_cursor_new()`, [`gdk::Cursor::for_display()`][crate::gdk::Cursor::for_display()] and
120 /// [`gdk::Cursor::from_name()`][crate::gdk::Cursor::from_name()] are updated to reflect the theme
121 /// change. Custom cursors constructed with
122 /// [`gdk::Cursor::from_pixbuf()`][crate::gdk::Cursor::from_pixbuf()] will have to be handled
123 /// by the application (GTK+ applications can learn about
124 /// cursor theme changes by listening for change notification
125 /// for the corresponding `GtkSetting`).
126 /// ## `theme`
127 /// the name of the cursor theme to use, or [`None`] to unset
128 /// a previously set value
129 /// ## `size`
130 /// the cursor size to use, or 0 to keep the previous size
131 #[doc(alias = "gdk_x11_display_set_cursor_theme")]
132 pub fn set_cursor_theme(&self, theme: Option<&str>, size: i32) {
133 unsafe {
134 ffi::gdk_x11_display_set_cursor_theme(
135 self.to_glib_none().0,
136 theme.to_glib_none().0,
137 size,
138 );
139 }
140 }
141
142 /// Sets the startup notification ID for a display.
143 ///
144 /// This is usually taken from the value of the DESKTOP_STARTUP_ID
145 /// environment variable, but in some cases (such as the application not
146 /// being launched using `exec()`) it can come from other sources.
147 ///
148 /// If the ID contains the string "_TIME" then the portion following that
149 /// string is taken to be the X11 timestamp of the event that triggered
150 /// the application to be launched and the GDK current event time is set
151 /// accordingly.
152 ///
153 /// The startup ID is also what is used to signal that the startup is
154 /// complete (for example, when opening a window or when calling
155 /// `gdk_notify_startup_complete()`).
156 /// ## `startup_id`
157 /// the startup notification ID (must be valid utf8)
158 #[doc(alias = "gdk_x11_display_set_startup_notification_id")]
159 pub fn set_startup_notification_id(&self, startup_id: &str) {
160 unsafe {
161 ffi::gdk_x11_display_set_startup_notification_id(
162 self.to_glib_none().0,
163 startup_id.to_glib_none().0,
164 );
165 }
166 }
167
168 /// Forces a specific window scale for all windows on this display,
169 /// instead of using the default or user configured scale. This
170 /// is can be used to disable scaling support by setting `scale` to
171 /// 1, or to programmatically set the window scale.
172 ///
173 /// Once the scale is set by this call it will not change in response
174 /// to later user configuration changes.
175 /// ## `scale`
176 /// The new scale value
177 #[doc(alias = "gdk_x11_display_set_window_scale")]
178 pub fn set_window_scale(&self, scale: i32) {
179 unsafe {
180 ffi::gdk_x11_display_set_window_scale(self.to_glib_none().0, scale);
181 }
182 }
183
184 /// Convert a string from the encoding of the current
185 /// locale into a form suitable for storing in a window property.
186 /// ## `str`
187 /// a nul-terminated string
188 ///
189 /// # Returns
190 ///
191 /// 0 upon success, non-zero upon failure
192 ///
193 /// ## `encoding`
194 /// location to store the encoding atom
195 /// (to be used as the type for the property)
196 ///
197 /// ## `format`
198 /// location to store the format of the property
199 ///
200 /// ## `ctext`
201 /// location to store newly
202 /// allocated data for the property
203 #[doc(alias = "gdk_x11_display_string_to_compound_text")]
204 pub fn string_to_compound_text(&self, str: &str) -> (i32, gdk::Atom, i32, Vec<u8>) {
205 unsafe {
206 let mut encoding = gdk::Atom::uninitialized();
207 let mut format = std::mem::MaybeUninit::uninit();
208 let mut ctext = std::ptr::null_mut();
209 let mut length = std::mem::MaybeUninit::uninit();
210 let ret = ffi::gdk_x11_display_string_to_compound_text(
211 self.to_glib_none().0,
212 str.to_glib_none().0,
213 encoding.to_glib_none_mut().0,
214 format.as_mut_ptr(),
215 &mut ctext,
216 length.as_mut_ptr(),
217 );
218 (
219 ret,
220 encoding,
221 format.assume_init(),
222 FromGlibContainer::from_glib_full_num(ctext, length.assume_init() as _),
223 )
224 }
225 }
226
227 /// Ungrab `self` after it has been grabbed with
228 /// [`grab()`][Self::grab()].
229 #[doc(alias = "gdk_x11_display_ungrab")]
230 pub fn ungrab(&self) {
231 unsafe {
232 ffi::gdk_x11_display_ungrab(self.to_glib_none().0);
233 }
234 }
235
236 /// Converts from UTF-8 to compound text.
237 /// ## `str`
238 /// a UTF-8 string
239 ///
240 /// # Returns
241 ///
242 /// [`true`] if the conversion succeeded,
243 /// otherwise [`false`]
244 ///
245 /// ## `encoding`
246 /// location to store resulting encoding
247 ///
248 /// ## `format`
249 /// location to store format of the result
250 ///
251 /// ## `ctext`
252 /// location to store the data of the result
253 #[doc(alias = "gdk_x11_display_utf8_to_compound_text")]
254 pub fn utf8_to_compound_text(&self, str: &str) -> Option<(gdk::Atom, i32, Vec<u8>)> {
255 unsafe {
256 let mut encoding = gdk::Atom::uninitialized();
257 let mut format = std::mem::MaybeUninit::uninit();
258 let mut ctext = std::ptr::null_mut();
259 let mut length = std::mem::MaybeUninit::uninit();
260 let ret = from_glib(ffi::gdk_x11_display_utf8_to_compound_text(
261 self.to_glib_none().0,
262 str.to_glib_none().0,
263 encoding.to_glib_none_mut().0,
264 format.as_mut_ptr(),
265 &mut ctext,
266 length.as_mut_ptr(),
267 ));
268 if ret {
269 Some((
270 encoding,
271 format.assume_init(),
272 FromGlibContainer::from_glib_full_num(ctext, length.assume_init() as _),
273 ))
274 } else {
275 None
276 }
277 }
278 }
279
280 /// Retrieves the version of the GLX implementation.
281 /// ## `display`
282 /// a [`gdk::Display`][crate::gdk::Display]
283 ///
284 /// # Returns
285 ///
286 /// [`true`] if GLX is available
287 ///
288 /// ## `major`
289 /// return location for the GLX major version
290 ///
291 /// ## `minor`
292 /// return location for the GLX minor version
293 #[doc(alias = "gdk_x11_display_get_glx_version")]
294 #[doc(alias = "get_glx_version")]
295 pub fn glx_version(display: &impl IsA<gdk::Display>) -> Option<(i32, i32)> {
296 assert_initialized_main_thread!();
297 unsafe {
298 let mut major = std::mem::MaybeUninit::uninit();
299 let mut minor = std::mem::MaybeUninit::uninit();
300 let ret = from_glib(ffi::gdk_x11_display_get_glx_version(
301 display.as_ref().to_glib_none().0,
302 major.as_mut_ptr(),
303 minor.as_mut_ptr(),
304 ));
305 if ret {
306 Some((major.assume_init(), minor.assume_init()))
307 } else {
308 None
309 }
310 }
311 }
312}