Skip to main content

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