Skip to main content

gdk/auto/
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::{AppLaunchContext, Atom, Device, Event, Monitor, Screen, Seat, Window, ffi};
6use glib::{
7    object::ObjectType as _,
8    prelude::*,
9    signal::{SignalHandlerId, connect_raw},
10    translate::*,
11};
12use std::boxed::Box as Box_;
13
14glib::wrapper! {
15    /// [`Display`][crate::Display] objects purpose are two fold:
16    ///
17    /// - To manage and provide information about input devices (pointers and keyboards)
18    ///
19    /// - To manage and provide information about the available `GdkScreens`
20    ///
21    /// GdkDisplay objects are the GDK representation of an X Display,
22    /// which can be described as a workstation consisting of
23    /// a keyboard, a pointing device (such as a mouse) and one or more
24    /// screens.
25    /// It is used to open and keep track of various GdkScreen objects
26    /// currently instantiated by the application. It is also used to
27    /// access the keyboard(s) and mouse pointer(s) of the display.
28    ///
29    /// Most of the input device handling has been factored out into
30    /// the separate [`DeviceManager`][crate::DeviceManager] object. Every display has a
31    /// device manager, which you can obtain using
32    /// `gdk_display_get_device_manager()`.
33    ///
34    /// ## Signals
35    ///
36    ///
37    /// #### `closed`
38    ///  The ::closed signal is emitted when the connection to the windowing
39    /// system for `display` is closed.
40    ///
41    ///
42    ///
43    ///
44    /// #### `monitor-added`
45    ///  The ::monitor-added signal is emitted whenever a monitor is
46    /// added.
47    ///
48    ///
49    ///
50    ///
51    /// #### `monitor-removed`
52    ///  The ::monitor-removed signal is emitted whenever a monitor is
53    /// removed.
54    ///
55    ///
56    ///
57    ///
58    /// #### `opened`
59    ///  The ::opened signal is emitted when the connection to the windowing
60    /// system for `display` is opened.
61    ///
62    ///
63    ///
64    ///
65    /// #### `seat-added`
66    ///  The ::seat-added signal is emitted whenever a new seat is made
67    /// known to the windowing system.
68    ///
69    ///
70    ///
71    ///
72    /// #### `seat-removed`
73    ///  The ::seat-removed signal is emitted whenever a seat is removed
74    /// by the windowing system.
75    ///
76    ///
77    ///
78    /// # Implements
79    ///
80    /// [`DisplayExtManual`][trait@crate::prelude::DisplayExtManual]
81    #[doc(alias = "GdkDisplay")]
82    pub struct Display(Object<ffi::GdkDisplay>);
83
84    match fn {
85        type_ => || ffi::gdk_display_get_type(),
86    }
87}
88
89impl Display {
90    /// Emits a short beep on `self`
91    #[doc(alias = "gdk_display_beep")]
92    pub fn beep(&self) {
93        unsafe {
94            ffi::gdk_display_beep(self.to_glib_none().0);
95        }
96    }
97
98    /// Closes the connection to the windowing system for the given display,
99    /// and cleans up associated resources.
100    #[doc(alias = "gdk_display_close")]
101    pub fn close(&self) {
102        unsafe {
103            ffi::gdk_display_close(self.to_glib_none().0);
104        }
105    }
106
107    /// Returns [`true`] if there is an ongoing grab on `device` for `self`.
108    /// ## `device`
109    /// a [`Device`][crate::Device]
110    ///
111    /// # Returns
112    ///
113    /// [`true`] if there is a grab in effect for `device`.
114    #[doc(alias = "gdk_display_device_is_grabbed")]
115    pub fn device_is_grabbed(&self, device: &impl IsA<Device>) -> bool {
116        unsafe {
117            from_glib(ffi::gdk_display_device_is_grabbed(
118                self.to_glib_none().0,
119                device.as_ref().to_glib_none().0,
120            ))
121        }
122    }
123
124    /// Flushes any requests queued for the windowing system; this happens automatically
125    /// when the main loop blocks waiting for new events, but if your application
126    /// is drawing without returning control to the main loop, you may need
127    /// to call this function explicitly. A common case where this function
128    /// needs to be called is when an application is executing drawing commands
129    /// from a thread other than the thread where the main loop is running.
130    ///
131    /// This is most useful for X11. On windowing systems where requests are
132    /// handled synchronously, this function will do nothing.
133    #[doc(alias = "gdk_display_flush")]
134    pub fn flush(&self) {
135        unsafe {
136            ffi::gdk_display_flush(self.to_glib_none().0);
137        }
138    }
139
140    /// Returns a [`AppLaunchContext`][crate::AppLaunchContext] suitable for launching
141    /// applications on the given display.
142    ///
143    /// # Returns
144    ///
145    /// a new [`AppLaunchContext`][crate::AppLaunchContext] for `self`.
146    ///  Free with `g_object_unref()` when done
147    #[doc(alias = "gdk_display_get_app_launch_context")]
148    #[doc(alias = "get_app_launch_context")]
149    pub fn app_launch_context(&self) -> Option<AppLaunchContext> {
150        unsafe {
151            from_glib_full(ffi::gdk_display_get_app_launch_context(
152                self.to_glib_none().0,
153            ))
154        }
155    }
156
157    /// Returns the default size to use for cursors on `self`.
158    ///
159    /// # Returns
160    ///
161    /// the default cursor size.
162    #[doc(alias = "gdk_display_get_default_cursor_size")]
163    #[doc(alias = "get_default_cursor_size")]
164    pub fn default_cursor_size(&self) -> u32 {
165        unsafe { ffi::gdk_display_get_default_cursor_size(self.to_glib_none().0) }
166    }
167
168    /// Returns the default group leader window for all toplevel windows
169    /// on `self`. This window is implicitly created by GDK.
170    /// See [`Window::set_group()`][crate::Window::set_group()].
171    ///
172    /// # Returns
173    ///
174    /// The default group leader window
175    /// for `self`
176    #[doc(alias = "gdk_display_get_default_group")]
177    #[doc(alias = "get_default_group")]
178    pub fn default_group(&self) -> Window {
179        unsafe { from_glib_none(ffi::gdk_display_get_default_group(self.to_glib_none().0)) }
180    }
181
182    /// Get the default [`Screen`][crate::Screen] for `self`.
183    ///
184    /// # Returns
185    ///
186    /// the default [`Screen`][crate::Screen] object for `self`
187    #[doc(alias = "gdk_display_get_default_screen")]
188    #[doc(alias = "get_default_screen")]
189    pub fn default_screen(&self) -> Screen {
190        unsafe { from_glib_none(ffi::gdk_display_get_default_screen(self.to_glib_none().0)) }
191    }
192
193    /// Returns the default [`Seat`][crate::Seat] for this display.
194    ///
195    /// # Returns
196    ///
197    /// the default seat.
198    #[doc(alias = "gdk_display_get_default_seat")]
199    #[doc(alias = "get_default_seat")]
200    pub fn default_seat(&self) -> Option<Seat> {
201        unsafe { from_glib_none(ffi::gdk_display_get_default_seat(self.to_glib_none().0)) }
202    }
203
204    /// Gets the next `GdkEvent` to be processed for `self`, fetching events from the
205    /// windowing system if necessary.
206    ///
207    /// # Returns
208    ///
209    /// the next `GdkEvent` to be processed, or [`None`]
210    /// if no events are pending. The returned `GdkEvent` should be freed
211    /// with `gdk_event_free()`.
212    #[doc(alias = "gdk_display_get_event")]
213    #[doc(alias = "get_event")]
214    pub fn event(&self) -> Option<Event> {
215        unsafe { from_glib_full(ffi::gdk_display_get_event(self.to_glib_none().0)) }
216    }
217
218    /// Gets the maximal size to use for cursors on `self`.
219    ///
220    /// # Returns
221    ///
222    ///
223    /// ## `width`
224    /// the return location for the maximal cursor width
225    ///
226    /// ## `height`
227    /// the return location for the maximal cursor height
228    #[doc(alias = "gdk_display_get_maximal_cursor_size")]
229    #[doc(alias = "get_maximal_cursor_size")]
230    pub fn maximal_cursor_size(&self) -> (u32, u32) {
231        unsafe {
232            let mut width = std::mem::MaybeUninit::uninit();
233            let mut height = std::mem::MaybeUninit::uninit();
234            ffi::gdk_display_get_maximal_cursor_size(
235                self.to_glib_none().0,
236                width.as_mut_ptr(),
237                height.as_mut_ptr(),
238            );
239            (width.assume_init(), height.assume_init())
240        }
241    }
242
243    /// Gets a monitor associated with this display.
244    /// ## `monitor_num`
245    /// number of the monitor
246    ///
247    /// # Returns
248    ///
249    /// the [`Monitor`][crate::Monitor], or [`None`] if
250    ///  `monitor_num` is not a valid monitor number
251    #[doc(alias = "gdk_display_get_monitor")]
252    #[doc(alias = "get_monitor")]
253    pub fn monitor(&self, monitor_num: i32) -> Option<Monitor> {
254        unsafe {
255            from_glib_none(ffi::gdk_display_get_monitor(
256                self.to_glib_none().0,
257                monitor_num,
258            ))
259        }
260    }
261
262    /// Gets the monitor in which the point (`x`, `y`) is located,
263    /// or a nearby monitor if the point is not in any monitor.
264    /// ## `x`
265    /// the x coordinate of the point
266    /// ## `y`
267    /// the y coordinate of the point
268    ///
269    /// # Returns
270    ///
271    /// the monitor containing the point
272    #[doc(alias = "gdk_display_get_monitor_at_point")]
273    #[doc(alias = "get_monitor_at_point")]
274    pub fn monitor_at_point(&self, x: i32, y: i32) -> Option<Monitor> {
275        unsafe {
276            from_glib_none(ffi::gdk_display_get_monitor_at_point(
277                self.to_glib_none().0,
278                x,
279                y,
280            ))
281        }
282    }
283
284    /// Gets the monitor in which the largest area of `window`
285    /// resides, or a monitor close to `window` if it is outside
286    /// of all monitors.
287    /// ## `window`
288    /// a [`Window`][crate::Window]
289    ///
290    /// # Returns
291    ///
292    /// the monitor with the largest overlap with `window`
293    #[doc(alias = "gdk_display_get_monitor_at_window")]
294    #[doc(alias = "get_monitor_at_window")]
295    pub fn monitor_at_window(&self, window: &Window) -> Option<Monitor> {
296        unsafe {
297            from_glib_none(ffi::gdk_display_get_monitor_at_window(
298                self.to_glib_none().0,
299                window.to_glib_none().0,
300            ))
301        }
302    }
303
304    /// Gets the number of monitors that belong to `self`.
305    ///
306    /// The returned number is valid until the next emission of the
307    /// [`monitor-added`][struct@crate::Display#monitor-added] or [`monitor-removed`][struct@crate::Display#monitor-removed] signal.
308    ///
309    /// # Returns
310    ///
311    /// the number of monitors
312    #[doc(alias = "gdk_display_get_n_monitors")]
313    #[doc(alias = "get_n_monitors")]
314    pub fn n_monitors(&self) -> i32 {
315        unsafe { ffi::gdk_display_get_n_monitors(self.to_glib_none().0) }
316    }
317
318    /// Gets the name of the display.
319    ///
320    /// # Returns
321    ///
322    /// a string representing the display name. This string is owned
323    /// by GDK and should not be modified or freed.
324    #[doc(alias = "gdk_display_get_name")]
325    #[doc(alias = "get_name")]
326    pub fn name(&self) -> glib::GString {
327        unsafe { from_glib_none(ffi::gdk_display_get_name(self.to_glib_none().0)) }
328    }
329
330    /// Gets the primary monitor for the display.
331    ///
332    /// The primary monitor is considered the monitor where the “main desktop”
333    /// lives. While normal application windows typically allow the window
334    /// manager to place the windows, specialized desktop applications
335    /// such as panels should place themselves on the primary monitor.
336    ///
337    /// # Returns
338    ///
339    /// the primary monitor, or [`None`] if no primary
340    ///  monitor is configured by the user
341    #[doc(alias = "gdk_display_get_primary_monitor")]
342    #[doc(alias = "get_primary_monitor")]
343    pub fn primary_monitor(&self) -> Option<Monitor> {
344        unsafe { from_glib_none(ffi::gdk_display_get_primary_monitor(self.to_glib_none().0)) }
345    }
346
347    /// Returns whether the display has events that are waiting
348    /// to be processed.
349    ///
350    /// # Returns
351    ///
352    /// [`true`] if there are events ready to be processed.
353    #[doc(alias = "gdk_display_has_pending")]
354    pub fn has_pending(&self) -> bool {
355        unsafe { from_glib(ffi::gdk_display_has_pending(self.to_glib_none().0)) }
356    }
357
358    /// Finds out if the display has been closed.
359    ///
360    /// # Returns
361    ///
362    /// [`true`] if the display is closed.
363    #[doc(alias = "gdk_display_is_closed")]
364    pub fn is_closed(&self) -> bool {
365        unsafe { from_glib(ffi::gdk_display_is_closed(self.to_glib_none().0)) }
366    }
367
368    /// Returns the list of seats known to `self`.
369    ///
370    /// # Returns
371    ///
372    /// the
373    ///  list of seats known to the [`Display`][crate::Display]
374    #[doc(alias = "gdk_display_list_seats")]
375    pub fn list_seats(&self) -> Vec<Seat> {
376        unsafe {
377            FromGlibPtrContainer::from_glib_container(ffi::gdk_display_list_seats(
378                self.to_glib_none().0,
379            ))
380        }
381    }
382
383    /// Indicates to the GUI environment that the application has
384    /// finished loading, using a given identifier.
385    ///
386    /// GTK+ will call this function automatically for `GtkWindow`
387    /// with custom startup-notification identifier unless
388    /// `gtk_window_set_auto_startup_notification()` is called to
389    /// disable that feature.
390    /// ## `startup_id`
391    /// a startup-notification identifier, for which
392    ///  notification process should be completed
393    #[doc(alias = "gdk_display_notify_startup_complete")]
394    pub fn notify_startup_complete(&self, startup_id: &str) {
395        unsafe {
396            ffi::gdk_display_notify_startup_complete(
397                self.to_glib_none().0,
398                startup_id.to_glib_none().0,
399            );
400        }
401    }
402
403    /// Gets a copy of the first `GdkEvent` in the `self`’s event queue, without
404    /// removing the event from the queue. (Note that this function will
405    /// not get more events from the windowing system. It only checks the events
406    /// that have already been moved to the GDK event queue.)
407    ///
408    /// # Returns
409    ///
410    /// a copy of the first `GdkEvent` on the event
411    /// queue, or [`None`] if no events are in the queue. The returned
412    /// `GdkEvent` should be freed with `gdk_event_free()`.
413    #[doc(alias = "gdk_display_peek_event")]
414    pub fn peek_event(&self) -> Option<Event> {
415        unsafe { from_glib_full(ffi::gdk_display_peek_event(self.to_glib_none().0)) }
416    }
417
418    /// Appends a copy of the given event onto the front of the event
419    /// queue for `self`.
420    /// ## `event`
421    /// a `GdkEvent`.
422    #[doc(alias = "gdk_display_put_event")]
423    pub fn put_event(&self, event: &Event) {
424        unsafe {
425            ffi::gdk_display_put_event(self.to_glib_none().0, event.to_glib_none().0);
426        }
427    }
428
429    /// Request [`EventOwnerChange`][crate::EventOwnerChange] events for ownership changes
430    /// of the selection named by the given atom.
431    /// ## `selection`
432    /// the [`Atom`][crate::Atom] naming the selection for which
433    ///  ownership change notification is requested
434    ///
435    /// # Returns
436    ///
437    /// whether [`EventOwnerChange`][crate::EventOwnerChange] events will
438    ///  be sent.
439    #[doc(alias = "gdk_display_request_selection_notification")]
440    pub fn request_selection_notification(&self, selection: &Atom) -> bool {
441        unsafe {
442            from_glib(ffi::gdk_display_request_selection_notification(
443                self.to_glib_none().0,
444                selection.to_glib_none().0,
445            ))
446        }
447    }
448
449    /// Sets the double click distance (two clicks within this distance
450    /// count as a double click and result in a [`EventType::_2buttonPress`][crate::EventType::_2buttonPress] event).
451    /// See also [`set_double_click_time()`][Self::set_double_click_time()].
452    /// Applications should not set this, it is a global
453    /// user-configured setting.
454    /// ## `distance`
455    /// distance in pixels
456    #[doc(alias = "gdk_display_set_double_click_distance")]
457    pub fn set_double_click_distance(&self, distance: u32) {
458        unsafe {
459            ffi::gdk_display_set_double_click_distance(self.to_glib_none().0, distance);
460        }
461    }
462
463    /// Sets the double click time (two clicks within this time interval
464    /// count as a double click and result in a [`EventType::_2buttonPress`][crate::EventType::_2buttonPress] event).
465    /// Applications should not set this, it is a global
466    /// user-configured setting.
467    /// ## `msec`
468    /// double click time in milliseconds (thousandths of a second)
469    #[doc(alias = "gdk_display_set_double_click_time")]
470    pub fn set_double_click_time(&self, msec: u32) {
471        unsafe {
472            ffi::gdk_display_set_double_click_time(self.to_glib_none().0, msec);
473        }
474    }
475
476    /// Issues a request to the clipboard manager to store the
477    /// clipboard data. On X11, this is a special program that works
478    /// according to the
479    /// [FreeDesktop Clipboard Specification](http://www.freedesktop.org/Standards/clipboard-manager-spec).
480    /// ## `clipboard_window`
481    /// a [`Window`][crate::Window] belonging to the clipboard owner
482    /// ## `time_`
483    /// a timestamp
484    /// ## `targets`
485    /// an array of targets
486    ///  that should be saved, or [`None`]
487    ///  if all available targets should be saved.
488    #[doc(alias = "gdk_display_store_clipboard")]
489    pub fn store_clipboard(&self, clipboard_window: &Window, time_: u32, targets: &[Atom]) {
490        let n_targets = targets.len() as _;
491        unsafe {
492            ffi::gdk_display_store_clipboard(
493                self.to_glib_none().0,
494                clipboard_window.to_glib_none().0,
495                time_,
496                targets.to_glib_none().0,
497                n_targets,
498            );
499        }
500    }
501
502    /// Returns whether the speicifed display supports clipboard
503    /// persistance; i.e. if it’s possible to store the clipboard data after an
504    /// application has quit. On X11 this checks if a clipboard daemon is
505    /// running.
506    ///
507    /// # Returns
508    ///
509    /// [`true`] if the display supports clipboard persistance.
510    #[doc(alias = "gdk_display_supports_clipboard_persistence")]
511    pub fn supports_clipboard_persistence(&self) -> bool {
512        unsafe {
513            from_glib(ffi::gdk_display_supports_clipboard_persistence(
514                self.to_glib_none().0,
515            ))
516        }
517    }
518
519    /// Returns [`true`] if cursors can use an 8bit alpha channel
520    /// on `self`. Otherwise, cursors are restricted to bilevel
521    /// alpha (i.e. a mask).
522    ///
523    /// # Returns
524    ///
525    /// whether cursors can have alpha channels.
526    #[doc(alias = "gdk_display_supports_cursor_alpha")]
527    pub fn supports_cursor_alpha(&self) -> bool {
528        unsafe {
529            from_glib(ffi::gdk_display_supports_cursor_alpha(
530                self.to_glib_none().0,
531            ))
532        }
533    }
534
535    /// Returns [`true`] if multicolored cursors are supported
536    /// on `self`. Otherwise, cursors have only a forground
537    /// and a background color.
538    ///
539    /// # Returns
540    ///
541    /// whether cursors can have multiple colors.
542    #[doc(alias = "gdk_display_supports_cursor_color")]
543    pub fn supports_cursor_color(&self) -> bool {
544        unsafe {
545            from_glib(ffi::gdk_display_supports_cursor_color(
546                self.to_glib_none().0,
547            ))
548        }
549    }
550
551    /// Returns [`true`] if `gdk_window_input_shape_combine_mask()` can
552    /// be used to modify the input shape of windows on `self`.
553    ///
554    /// # Returns
555    ///
556    /// [`true`] if windows with modified input shape are supported
557    #[doc(alias = "gdk_display_supports_input_shapes")]
558    pub fn supports_input_shapes(&self) -> bool {
559        unsafe {
560            from_glib(ffi::gdk_display_supports_input_shapes(
561                self.to_glib_none().0,
562            ))
563        }
564    }
565
566    /// Returns whether [`EventOwnerChange`][crate::EventOwnerChange] events will be
567    /// sent when the owner of a selection changes.
568    ///
569    /// # Returns
570    ///
571    /// whether [`EventOwnerChange`][crate::EventOwnerChange] events will
572    ///  be sent.
573    #[doc(alias = "gdk_display_supports_selection_notification")]
574    pub fn supports_selection_notification(&self) -> bool {
575        unsafe {
576            from_glib(ffi::gdk_display_supports_selection_notification(
577                self.to_glib_none().0,
578            ))
579        }
580    }
581
582    /// Returns [`true`] if `gdk_window_shape_combine_mask()` can
583    /// be used to create shaped windows on `self`.
584    ///
585    /// # Returns
586    ///
587    /// [`true`] if shaped windows are supported
588    #[doc(alias = "gdk_display_supports_shapes")]
589    pub fn supports_shapes(&self) -> bool {
590        unsafe { from_glib(ffi::gdk_display_supports_shapes(self.to_glib_none().0)) }
591    }
592
593    /// Flushes any requests queued for the windowing system and waits until all
594    /// requests have been handled. This is often used for making sure that the
595    /// display is synchronized with the current state of the program. Calling
596    /// [`sync()`][Self::sync()] before [`error_trap_pop()`][crate::error_trap_pop()] makes sure that any errors
597    /// generated from earlier requests are handled before the error trap is
598    /// removed.
599    ///
600    /// This is most useful for X11. On windowing systems where requests are
601    /// handled synchronously, this function will do nothing.
602    #[doc(alias = "gdk_display_sync")]
603    pub fn sync(&self) {
604        unsafe {
605            ffi::gdk_display_sync(self.to_glib_none().0);
606        }
607    }
608
609    /// Gets the default [`Display`][crate::Display]. This is a convenience
610    /// function for:
611    /// `gdk_display_manager_get_default_display (gdk_display_manager_get ())`.
612    ///
613    /// # Returns
614    ///
615    /// a [`Display`][crate::Display], or [`None`] if
616    ///  there is no default display.
617    #[doc(alias = "gdk_display_get_default")]
618    #[doc(alias = "get_default")]
619    #[allow(clippy::should_implement_trait)]
620    pub fn default() -> Option<Display> {
621        assert_initialized_main_thread!();
622        unsafe { from_glib_none(ffi::gdk_display_get_default()) }
623    }
624
625    /// Opens a display.
626    /// ## `display_name`
627    /// the name of the display to open
628    ///
629    /// # Returns
630    ///
631    /// a [`Display`][crate::Display], or [`None`] if the
632    ///  display could not be opened
633    #[doc(alias = "gdk_display_open")]
634    pub fn open(display_name: &str) -> Option<Display> {
635        assert_initialized_main_thread!();
636        unsafe { from_glib_none(ffi::gdk_display_open(display_name.to_glib_none().0)) }
637    }
638
639    /// The ::closed signal is emitted when the connection to the windowing
640    /// system for `display` is closed.
641    /// ## `is_error`
642    /// [`true`] if the display was closed due to an error
643    #[doc(alias = "closed")]
644    pub fn connect_closed<F: Fn(&Self, bool) + 'static>(&self, f: F) -> SignalHandlerId {
645        unsafe extern "C" fn closed_trampoline<F: Fn(&Display, bool) + 'static>(
646            this: *mut ffi::GdkDisplay,
647            is_error: glib::ffi::gboolean,
648            f: glib::ffi::gpointer,
649        ) {
650            unsafe {
651                let f: &F = &*(f as *const F);
652                f(&from_glib_borrow(this), from_glib(is_error))
653            }
654        }
655        unsafe {
656            let f: Box_<F> = Box_::new(f);
657            connect_raw(
658                self.as_ptr() as *mut _,
659                c"closed".as_ptr(),
660                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
661                    closed_trampoline::<F> as *const (),
662                )),
663                Box_::into_raw(f),
664            )
665        }
666    }
667
668    /// The ::monitor-added signal is emitted whenever a monitor is
669    /// added.
670    /// ## `monitor`
671    /// the monitor that was just added
672    #[doc(alias = "monitor-added")]
673    pub fn connect_monitor_added<F: Fn(&Self, &Monitor) + 'static>(&self, f: F) -> SignalHandlerId {
674        unsafe extern "C" fn monitor_added_trampoline<F: Fn(&Display, &Monitor) + 'static>(
675            this: *mut ffi::GdkDisplay,
676            monitor: *mut ffi::GdkMonitor,
677            f: glib::ffi::gpointer,
678        ) {
679            unsafe {
680                let f: &F = &*(f as *const F);
681                f(&from_glib_borrow(this), &from_glib_borrow(monitor))
682            }
683        }
684        unsafe {
685            let f: Box_<F> = Box_::new(f);
686            connect_raw(
687                self.as_ptr() as *mut _,
688                c"monitor-added".as_ptr(),
689                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
690                    monitor_added_trampoline::<F> as *const (),
691                )),
692                Box_::into_raw(f),
693            )
694        }
695    }
696
697    /// The ::monitor-removed signal is emitted whenever a monitor is
698    /// removed.
699    /// ## `monitor`
700    /// the monitor that was just removed
701    #[doc(alias = "monitor-removed")]
702    pub fn connect_monitor_removed<F: Fn(&Self, &Monitor) + 'static>(
703        &self,
704        f: F,
705    ) -> SignalHandlerId {
706        unsafe extern "C" fn monitor_removed_trampoline<F: Fn(&Display, &Monitor) + 'static>(
707            this: *mut ffi::GdkDisplay,
708            monitor: *mut ffi::GdkMonitor,
709            f: glib::ffi::gpointer,
710        ) {
711            unsafe {
712                let f: &F = &*(f as *const F);
713                f(&from_glib_borrow(this), &from_glib_borrow(monitor))
714            }
715        }
716        unsafe {
717            let f: Box_<F> = Box_::new(f);
718            connect_raw(
719                self.as_ptr() as *mut _,
720                c"monitor-removed".as_ptr(),
721                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
722                    monitor_removed_trampoline::<F> as *const (),
723                )),
724                Box_::into_raw(f),
725            )
726        }
727    }
728
729    /// The ::opened signal is emitted when the connection to the windowing
730    /// system for `display` is opened.
731    #[doc(alias = "opened")]
732    pub fn connect_opened<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
733        unsafe extern "C" fn opened_trampoline<F: Fn(&Display) + 'static>(
734            this: *mut ffi::GdkDisplay,
735            f: glib::ffi::gpointer,
736        ) {
737            unsafe {
738                let f: &F = &*(f as *const F);
739                f(&from_glib_borrow(this))
740            }
741        }
742        unsafe {
743            let f: Box_<F> = Box_::new(f);
744            connect_raw(
745                self.as_ptr() as *mut _,
746                c"opened".as_ptr(),
747                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
748                    opened_trampoline::<F> as *const (),
749                )),
750                Box_::into_raw(f),
751            )
752        }
753    }
754
755    /// The ::seat-added signal is emitted whenever a new seat is made
756    /// known to the windowing system.
757    /// ## `seat`
758    /// the seat that was just added
759    #[doc(alias = "seat-added")]
760    pub fn connect_seat_added<F: Fn(&Self, &Seat) + 'static>(&self, f: F) -> SignalHandlerId {
761        unsafe extern "C" fn seat_added_trampoline<F: Fn(&Display, &Seat) + 'static>(
762            this: *mut ffi::GdkDisplay,
763            seat: *mut ffi::GdkSeat,
764            f: glib::ffi::gpointer,
765        ) {
766            unsafe {
767                let f: &F = &*(f as *const F);
768                f(&from_glib_borrow(this), &from_glib_borrow(seat))
769            }
770        }
771        unsafe {
772            let f: Box_<F> = Box_::new(f);
773            connect_raw(
774                self.as_ptr() as *mut _,
775                c"seat-added".as_ptr(),
776                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
777                    seat_added_trampoline::<F> as *const (),
778                )),
779                Box_::into_raw(f),
780            )
781        }
782    }
783
784    /// The ::seat-removed signal is emitted whenever a seat is removed
785    /// by the windowing system.
786    /// ## `seat`
787    /// the seat that was just removed
788    #[doc(alias = "seat-removed")]
789    pub fn connect_seat_removed<F: Fn(&Self, &Seat) + 'static>(&self, f: F) -> SignalHandlerId {
790        unsafe extern "C" fn seat_removed_trampoline<F: Fn(&Display, &Seat) + 'static>(
791            this: *mut ffi::GdkDisplay,
792            seat: *mut ffi::GdkSeat,
793            f: glib::ffi::gpointer,
794        ) {
795            unsafe {
796                let f: &F = &*(f as *const F);
797                f(&from_glib_borrow(this), &from_glib_borrow(seat))
798            }
799        }
800        unsafe {
801            let f: Box_<F> = Box_::new(f);
802            connect_raw(
803                self.as_ptr() as *mut _,
804                c"seat-removed".as_ptr(),
805                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
806                    seat_removed_trampoline::<F> as *const (),
807                )),
808                Box_::into_raw(f),
809            )
810        }
811    }
812}
813
814impl std::fmt::Display for Display {
815    #[inline]
816    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
817        f.write_str(&self.name())
818    }
819}