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