gdk4_x11/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#![allow(deprecated)]
5
6use crate::{X11Screen, ffi};
7use glib::translate::*;
8
9glib::wrapper! {
10 ///
11 ///
12 /// ## Signals
13 ///
14 ///
15 /// #### `xevent`
16 /// The ::xevent signal is a low level signal that is emitted
17 /// whenever an XEvent has been received.
18 ///
19 /// When handlers to this signal return [`true`], no other handlers will be
20 /// invoked. In particular, the default handler for this function is
21 /// GDK's own event handling mechanism, so by returning [`true`] for an event
22 /// that GDK expects to translate, you may break GDK and/or GTK+ in
23 /// interesting ways. You have been warned.
24 ///
25 /// If you want this signal handler to queue a [`gdk::Event`][crate::gdk::Event], you can use
26 /// gdk_display_put_event().
27 ///
28 /// If you are interested in X GenericEvents, bear in mind that
29 /// XGetEventData() has been already called on the event, and
30 /// XFreeEventData() will be called afterwards.
31 ///
32 ///
33 /// <details><summary><h4>Display</h4></summary>
34 ///
35 ///
36 /// #### `closed`
37 /// Emitted when the connection to the windowing system for @display is closed.
38 ///
39 ///
40 ///
41 ///
42 /// #### `opened`
43 /// Emitted when the connection to the windowing system for @display is opened.
44 ///
45 ///
46 ///
47 ///
48 /// #### `seat-added`
49 /// Emitted whenever a new seat is made known to the windowing system.
50 ///
51 ///
52 ///
53 ///
54 /// #### `seat-removed`
55 /// Emitted whenever a seat is removed by the windowing system.
56 ///
57 ///
58 ///
59 ///
60 /// #### `setting-changed`
61 /// Emitted whenever a setting changes its value.
62 ///
63 ///
64 /// </details>
65 ///
66 /// # Implements
67 ///
68 /// [`trait@gdk::prelude::DisplayExt`]
69 #[doc(alias = "GdkX11Display")]
70 pub struct X11Display(Object<ffi::GdkX11Display, ffi::GdkX11DisplayClass>) @extends gdk::Display;
71
72 match fn {
73 type_ => || ffi::gdk_x11_display_get_type(),
74 }
75}
76
77impl X11Display {
78 //#[cfg_attr(feature = "v4_18", deprecated = "Since 4.18")]
79 //#[allow(deprecated)]
80 //#[doc(alias = "gdk_x11_display_broadcast_startup_message")]
81 //pub fn broadcast_startup_message(&self, message_type: &str, : /*Unknown conversion*//*Unimplemented*/Basic: VarArgs) {
82 // unsafe { TODO: call ffi:gdk_x11_display_broadcast_startup_message() }
83 //}
84
85 /// Pops the error trap pushed by gdk_x11_display_error_trap_push().
86 /// Will XSync() if necessary and will always block until
87 /// the error is known to have occurred or not occurred,
88 /// so the error code can be returned.
89 ///
90 /// If you don’t need to use the return value,
91 /// gdk_x11_display_error_trap_pop_ignored() would be more efficient.
92 ///
93 /// # Deprecated since 4.18
94 ///
95 ///
96 /// # Returns
97 ///
98 /// X error code or 0 on success
99 #[cfg_attr(feature = "v4_18", deprecated = "Since 4.18")]
100 #[allow(deprecated)]
101 #[doc(alias = "gdk_x11_display_error_trap_pop")]
102 pub fn error_trap_pop(&self) -> i32 {
103 unsafe { ffi::gdk_x11_display_error_trap_pop(self.to_glib_none().0) }
104 }
105
106 /// Pops the error trap pushed by gdk_x11_display_error_trap_push().
107 /// Does not block to see if an error occurred; merely records the
108 /// range of requests to ignore errors for, and ignores those errors
109 /// if they arrive asynchronously.
110 ///
111 /// # Deprecated since 4.18
112 ///
113 #[cfg_attr(feature = "v4_18", deprecated = "Since 4.18")]
114 #[allow(deprecated)]
115 #[doc(alias = "gdk_x11_display_error_trap_pop_ignored")]
116 pub fn error_trap_pop_ignored(&self) {
117 unsafe {
118 ffi::gdk_x11_display_error_trap_pop_ignored(self.to_glib_none().0);
119 }
120 }
121
122 /// Begins a range of X requests on @self for which X error events
123 /// will be ignored. Unignored errors (when no trap is pushed) will abort
124 /// the application. Use gdk_x11_display_error_trap_pop() or
125 /// gdk_x11_display_error_trap_pop_ignored()to lift a trap pushed
126 /// with this function.
127 ///
128 /// # Deprecated since 4.18
129 ///
130 #[cfg_attr(feature = "v4_18", deprecated = "Since 4.18")]
131 #[allow(deprecated)]
132 #[doc(alias = "gdk_x11_display_error_trap_push")]
133 pub fn error_trap_push(&self) {
134 unsafe {
135 ffi::gdk_x11_display_error_trap_push(self.to_glib_none().0);
136 }
137 }
138
139 /// Returns the default group leader surface for all toplevel surfaces
140 /// on @self. This surface is implicitly created by GDK.
141 /// See gdk_x11_surface_set_group().
142 ///
143 /// # Deprecated since 4.18
144 ///
145 ///
146 /// # Returns
147 ///
148 /// The default group leader surface
149 /// for @self
150 #[cfg_attr(feature = "v4_18", deprecated = "Since 4.18")]
151 #[allow(deprecated)]
152 #[doc(alias = "gdk_x11_display_get_default_group")]
153 #[doc(alias = "get_default_group")]
154 pub fn default_group(&self) -> gdk::Surface {
155 unsafe {
156 from_glib_none(ffi::gdk_x11_display_get_default_group(
157 self.to_glib_none().0,
158 ))
159 }
160 }
161
162 /// Retrieves the version of the EGL implementation.
163 ///
164 /// # Deprecated since 4.18
165 ///
166 ///
167 /// # Returns
168 ///
169 /// [`true`] if EGL is available
170 ///
171 /// ## `major`
172 /// return location for the EGL major version
173 ///
174 /// ## `minor`
175 /// return location for the EGL minor version
176 #[cfg_attr(feature = "v4_18", deprecated = "Since 4.18")]
177 #[cfg(feature = "v4_4")]
178 #[cfg_attr(docsrs, doc(cfg(feature = "v4_4")))]
179 #[allow(deprecated)]
180 #[doc(alias = "gdk_x11_display_get_egl_version")]
181 #[doc(alias = "get_egl_version")]
182 pub fn egl_version(&self) -> Option<(i32, i32)> {
183 unsafe {
184 let mut major = std::mem::MaybeUninit::uninit();
185 let mut minor = std::mem::MaybeUninit::uninit();
186 let ret = from_glib(ffi::gdk_x11_display_get_egl_version(
187 self.to_glib_none().0,
188 major.as_mut_ptr(),
189 minor.as_mut_ptr(),
190 ));
191 if ret {
192 Some((major.assume_init(), minor.assume_init()))
193 } else {
194 None
195 }
196 }
197 }
198
199 /// Retrieves the version of the GLX implementation.
200 ///
201 /// # Deprecated since 4.18
202 ///
203 ///
204 /// # Returns
205 ///
206 /// [`true`] if GLX is available
207 ///
208 /// ## `major`
209 /// return location for the GLX major version
210 ///
211 /// ## `minor`
212 /// return location for the GLX minor version
213 #[cfg_attr(feature = "v4_18", deprecated = "Since 4.18")]
214 #[allow(deprecated)]
215 #[doc(alias = "gdk_x11_display_get_glx_version")]
216 #[doc(alias = "get_glx_version")]
217 pub fn glx_version(&self) -> Option<(i32, i32)> {
218 unsafe {
219 let mut major = std::mem::MaybeUninit::uninit();
220 let mut minor = std::mem::MaybeUninit::uninit();
221 let ret = from_glib(ffi::gdk_x11_display_get_glx_version(
222 self.to_glib_none().0,
223 major.as_mut_ptr(),
224 minor.as_mut_ptr(),
225 ));
226 if ret {
227 Some((major.assume_init(), minor.assume_init()))
228 } else {
229 None
230 }
231 }
232 }
233
234 /// Gets the primary monitor for the display.
235 ///
236 /// The primary monitor is considered the monitor where the “main desktop”
237 /// lives. While normal application surfaces typically allow the window
238 /// manager to place the surfaces, specialized desktop applications
239 /// such as panels should place themselves on the primary monitor.
240 ///
241 /// If no monitor is the designated primary monitor, any monitor
242 /// (usually the first) may be returned.
243 ///
244 /// # Deprecated since 4.18
245 ///
246 ///
247 /// # Returns
248 ///
249 /// the primary monitor, or any monitor if no
250 /// primary monitor is configured by the user
251 #[cfg_attr(feature = "v4_18", deprecated = "Since 4.18")]
252 #[allow(deprecated)]
253 #[doc(alias = "gdk_x11_display_get_primary_monitor")]
254 #[doc(alias = "get_primary_monitor")]
255 pub fn primary_monitor(&self) -> gdk::Monitor {
256 unsafe {
257 from_glib_none(ffi::gdk_x11_display_get_primary_monitor(
258 self.to_glib_none().0,
259 ))
260 }
261 }
262
263 /// Retrieves the [`X11Screen`][crate::X11Screen] of the @self.
264 ///
265 /// # Deprecated since 4.18
266 ///
267 ///
268 /// # Returns
269 ///
270 /// the [`X11Screen`][crate::X11Screen]
271 #[cfg_attr(feature = "v4_18", deprecated = "Since 4.18")]
272 #[allow(deprecated)]
273 #[doc(alias = "gdk_x11_display_get_screen")]
274 #[doc(alias = "get_screen")]
275 pub fn screen(&self) -> X11Screen {
276 unsafe { from_glib_none(ffi::gdk_x11_display_get_screen(self.to_glib_none().0)) }
277 }
278
279 /// Gets the startup notification ID for a display.
280 ///
281 /// # Deprecated since 4.10
282 ///
283 ///
284 /// # Returns
285 ///
286 /// the startup notification ID for @self
287 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
288 #[allow(deprecated)]
289 #[doc(alias = "gdk_x11_display_get_startup_notification_id")]
290 #[doc(alias = "get_startup_notification_id")]
291 pub fn startup_notification_id(&self) -> glib::GString {
292 unsafe {
293 from_glib_none(ffi::gdk_x11_display_get_startup_notification_id(
294 self.to_glib_none().0,
295 ))
296 }
297 }
298
299 /// Returns the timestamp of the last user interaction on
300 /// @self. The timestamp is taken from events caused
301 /// by user interaction such as key presses or pointer
302 /// movements. See gdk_x11_surface_set_user_time().
303 ///
304 /// # Deprecated since 4.18
305 ///
306 ///
307 /// # Returns
308 ///
309 /// the timestamp of the last user interaction
310 #[cfg_attr(feature = "v4_18", deprecated = "Since 4.18")]
311 #[allow(deprecated)]
312 #[doc(alias = "gdk_x11_display_get_user_time")]
313 #[doc(alias = "get_user_time")]
314 pub fn user_time(&self) -> u32 {
315 unsafe { ffi::gdk_x11_display_get_user_time(self.to_glib_none().0) }
316 }
317
318 /// Call XGrabServer() on @self.
319 /// To ungrab the display again, use gdk_x11_display_ungrab().
320 ///
321 /// gdk_x11_display_grab()/gdk_x11_display_ungrab() calls can be nested.
322 ///
323 /// # Deprecated since 4.18
324 ///
325 #[cfg_attr(feature = "v4_18", deprecated = "Since 4.18")]
326 #[allow(deprecated)]
327 #[doc(alias = "gdk_x11_display_grab")]
328 pub fn grab(&self) {
329 unsafe {
330 ffi::gdk_x11_display_grab(self.to_glib_none().0);
331 }
332 }
333
334 /// Sets the cursor theme from which the images for cursor
335 /// should be taken.
336 ///
337 /// If the windowing system supports it, existing cursors created
338 /// with [`gdk::Cursor::from_name()`][crate::gdk::Cursor::from_name()] are updated to reflect the theme
339 /// change. Custom cursors constructed with [`gdk::Cursor::from_texture()`][crate::gdk::Cursor::from_texture()]
340 /// will have to be handled by the application (GTK applications can learn
341 /// about cursor theme changes by listening for change notification
342 /// for the corresponding `GtkSetting`).
343 ///
344 /// # Deprecated since 4.16
345 ///
346 /// Use the cursor-related properties of
347 /// [GtkSettings](../gtk4/class.Settings.html) to set the cursor theme
348 /// ## `theme`
349 /// the name of the cursor theme to use, or [`None`]
350 /// to unset a previously set value
351 /// ## `size`
352 /// the cursor size to use, or 0 to keep the previous size
353 #[cfg_attr(feature = "v4_16", deprecated = "Since 4.16")]
354 #[allow(deprecated)]
355 #[doc(alias = "gdk_x11_display_set_cursor_theme")]
356 pub fn set_cursor_theme(&self, theme: Option<&str>, size: i32) {
357 unsafe {
358 ffi::gdk_x11_display_set_cursor_theme(
359 self.to_glib_none().0,
360 theme.to_glib_none().0,
361 size,
362 );
363 }
364 }
365
366 /// Sets the startup notification ID for a display.
367 ///
368 /// This is usually taken from the value of the DESKTOP_STARTUP_ID
369 /// environment variable, but in some cases (such as the application not
370 /// being launched using exec()) it can come from other sources.
371 ///
372 /// If the ID contains the string "_TIME" then the portion following that
373 /// string is taken to be the X11 timestamp of the event that triggered
374 /// the application to be launched and the GDK current event time is set
375 /// accordingly.
376 ///
377 /// The startup ID is also what is used to signal that the startup is
378 /// complete (for example, when opening a window or when calling
379 /// gdk_display_notify_startup_complete()).
380 ///
381 /// # Deprecated since 4.10
382 ///
383 /// Using `Gdk::Toplevel::set_startup_id()` is sufficient
384 /// ## `startup_id`
385 /// the startup notification ID (must be valid utf8)
386 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
387 #[allow(deprecated)]
388 #[doc(alias = "gdk_x11_display_set_startup_notification_id")]
389 pub fn set_startup_notification_id(&self, startup_id: &str) {
390 unsafe {
391 ffi::gdk_x11_display_set_startup_notification_id(
392 self.to_glib_none().0,
393 startup_id.to_glib_none().0,
394 );
395 }
396 }
397
398 /// Forces a specific window scale for all windows on this display,
399 /// instead of using the default or user configured scale. This
400 /// is can be used to disable scaling support by setting @scale to
401 /// 1, or to programmatically set the window scale.
402 ///
403 /// Once the scale is set by this call it will not change in response
404 /// to later user configuration changes.
405 ///
406 /// # Deprecated since 4.18
407 ///
408 /// ## `scale`
409 /// The new scale value
410 #[cfg_attr(feature = "v4_18", deprecated = "Since 4.18")]
411 #[allow(deprecated)]
412 #[doc(alias = "gdk_x11_display_set_surface_scale")]
413 pub fn set_surface_scale(&self, scale: i32) {
414 unsafe {
415 ffi::gdk_x11_display_set_surface_scale(self.to_glib_none().0, scale);
416 }
417 }
418
419 /// Convert a string from the encoding of the current
420 /// locale into a form suitable for storing in a window property.
421 ///
422 /// # Deprecated since 4.18
423 ///
424 /// ## `str`
425 /// a nul-terminated string
426 ///
427 /// # Returns
428 ///
429 /// 0 upon success, non-zero upon failure
430 ///
431 /// ## `encoding`
432 /// location to store the encoding
433 /// (to be used as the type for the property)
434 ///
435 /// ## `format`
436 /// location to store the format of the property
437 ///
438 /// ## `ctext`
439 /// location to store newly
440 /// allocated data for the property
441 #[cfg_attr(feature = "v4_18", deprecated = "Since 4.18")]
442 #[allow(deprecated)]
443 #[doc(alias = "gdk_x11_display_string_to_compound_text")]
444 pub fn string_to_compound_text(&self, str: &str) -> (i32, glib::GString, i32, Vec<u8>) {
445 unsafe {
446 let mut encoding = std::ptr::null();
447 let mut format = std::mem::MaybeUninit::uninit();
448 let mut ctext = std::ptr::null_mut();
449 let mut length = std::mem::MaybeUninit::uninit();
450 let ret = ffi::gdk_x11_display_string_to_compound_text(
451 self.to_glib_none().0,
452 str.to_glib_none().0,
453 &mut encoding,
454 format.as_mut_ptr(),
455 &mut ctext,
456 length.as_mut_ptr(),
457 );
458 (
459 ret,
460 from_glib_none(encoding),
461 format.assume_init(),
462 FromGlibContainer::from_glib_full_num(ctext, length.assume_init() as _),
463 )
464 }
465 }
466
467 /// Ungrab @self after it has been grabbed with
468 /// gdk_x11_display_grab().
469 ///
470 /// # Deprecated since 4.18
471 ///
472 #[cfg_attr(feature = "v4_18", deprecated = "Since 4.18")]
473 #[allow(deprecated)]
474 #[doc(alias = "gdk_x11_display_ungrab")]
475 pub fn ungrab(&self) {
476 unsafe {
477 ffi::gdk_x11_display_ungrab(self.to_glib_none().0);
478 }
479 }
480
481 /// Converts from UTF-8 to compound text.
482 ///
483 /// # Deprecated since 4.18
484 ///
485 /// ## `str`
486 /// a UTF-8 string
487 ///
488 /// # Returns
489 ///
490 /// [`true`] if the conversion succeeded, otherwise [`false`]
491 ///
492 /// ## `encoding`
493 /// location to store resulting encoding
494 ///
495 /// ## `format`
496 /// location to store format of the result
497 ///
498 /// ## `ctext`
499 /// location to store the data of the result
500 #[cfg_attr(feature = "v4_18", deprecated = "Since 4.18")]
501 #[allow(deprecated)]
502 #[doc(alias = "gdk_x11_display_utf8_to_compound_text")]
503 pub fn utf8_to_compound_text(&self, str: &str) -> Option<(glib::GString, i32, Vec<u8>)> {
504 unsafe {
505 let mut encoding = std::ptr::null();
506 let mut format = std::mem::MaybeUninit::uninit();
507 let mut ctext = std::ptr::null_mut();
508 let mut length = std::mem::MaybeUninit::uninit();
509 let ret = from_glib(ffi::gdk_x11_display_utf8_to_compound_text(
510 self.to_glib_none().0,
511 str.to_glib_none().0,
512 &mut encoding,
513 format.as_mut_ptr(),
514 &mut ctext,
515 length.as_mut_ptr(),
516 ));
517 if ret {
518 Some((
519 from_glib_none(encoding),
520 format.assume_init(),
521 FromGlibContainer::from_glib_full_num(ctext, length.assume_init() as _),
522 ))
523 } else {
524 None
525 }
526 }
527 }
528
529 /// Tries to open a new display to the X server given by
530 /// @display_name. If opening the display fails, [`None`] is
531 /// returned.
532 ///
533 /// # Deprecated since 4.18
534 ///
535 /// ## `display_name`
536 /// name of the X display.
537 /// See the XOpenDisplay() for details.
538 ///
539 /// # Returns
540 ///
541 /// The new display
542 #[cfg_attr(feature = "v4_18", deprecated = "Since 4.18")]
543 #[allow(deprecated)]
544 #[doc(alias = "gdk_x11_display_open")]
545 pub fn open(display_name: Option<&str>) -> Option<gdk::Display> {
546 assert_initialized_main_thread!();
547 unsafe { from_glib_full(ffi::gdk_x11_display_open(display_name.to_glib_none().0)) }
548 }
549}