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