gdk4/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#![allow(deprecated)]
5
6#[cfg(feature = "v4_14")]
7#[cfg_attr(docsrs, doc(cfg(feature = "v4_14")))]
8use crate::DmabufFormats;
9#[cfg(feature = "v4_6")]
10#[cfg_attr(docsrs, doc(cfg(feature = "v4_6")))]
11use crate::GLContext;
12use crate::{ffi, AppLaunchContext, Clipboard, Device, Event, Monitor, Seat, Surface};
13use glib::{
14    object::ObjectType as _,
15    prelude::*,
16    signal::{connect_raw, SignalHandlerId},
17    translate::*,
18};
19use std::boxed::Box as Box_;
20
21glib::wrapper! {
22    /// A representation of a workstation.
23    ///
24    /// Their purpose are two-fold:
25    ///
26    /// - To manage and provide information about input devices (pointers, keyboards, etc)
27    /// - To manage and provide information about output devices (monitors, projectors, etc)
28    ///
29    /// Most of the input device handling has been factored out into separate
30    /// [`Seat`][crate::Seat] objects. Every display has a one or more seats, which
31    /// can be accessed with [`DisplayExt::default_seat()`][crate::prelude::DisplayExt::default_seat()] and
32    /// [`DisplayExt::list_seats()`][crate::prelude::DisplayExt::list_seats()].
33    ///
34    /// Output devices are represented by [`Monitor`][crate::Monitor] objects, which can
35    /// be accessed with [`DisplayExt::monitor_at_surface()`][crate::prelude::DisplayExt::monitor_at_surface()] and similar APIs.
36    ///
37    /// ## Properties
38    ///
39    ///
40    /// #### `composited`
41    ///  [`true`] if the display properly composites the alpha channel.
42    ///
43    /// Readable
44    ///
45    ///
46    /// #### `dmabuf-formats`
47    ///  The dma-buf formats that are supported on this display
48    ///
49    /// Readable
50    ///
51    ///
52    /// #### `input-shapes`
53    ///  [`true`] if the display supports input shapes.
54    ///
55    /// Readable
56    ///
57    ///
58    /// #### `rgba`
59    ///  [`true`] if the display supports an alpha channel.
60    ///
61    /// Readable
62    ///
63    ///
64    /// #### `shadow-width`
65    ///  [`true`] if the display supports extensible frames.
66    ///
67    /// Readable
68    ///
69    /// ## Signals
70    ///
71    ///
72    /// #### `closed`
73    ///  Emitted when the connection to the windowing system for @display is closed.
74    ///
75    ///
76    ///
77    ///
78    /// #### `opened`
79    ///  Emitted when the connection to the windowing system for @display is opened.
80    ///
81    ///
82    ///
83    ///
84    /// #### `seat-added`
85    ///  Emitted whenever a new seat is made known to the windowing system.
86    ///
87    ///
88    ///
89    ///
90    /// #### `seat-removed`
91    ///  Emitted whenever a seat is removed by the windowing system.
92    ///
93    ///
94    ///
95    ///
96    /// #### `setting-changed`
97    ///  Emitted whenever a setting changes its value.
98    ///
99    ///
100    ///
101    /// # Implements
102    ///
103    /// [`DisplayExt`][trait@crate::prelude::DisplayExt], [`DisplayExtManual`][trait@crate::prelude::DisplayExtManual]
104    #[doc(alias = "GdkDisplay")]
105    pub struct Display(Object<ffi::GdkDisplay>);
106
107    match fn {
108        type_ => || ffi::gdk_display_get_type(),
109    }
110}
111
112impl Display {
113    pub const NONE: Option<&'static Display> = None;
114
115    /// Gets the default [`Display`][crate::Display].
116    ///
117    /// This is a convenience function for:
118    ///
119    ///     gdk_display_manager_get_default_display (gdk_display_manager_get ())
120    ///
121    /// # Returns
122    ///
123    /// a [`Display`][crate::Display], or [`None`] if
124    ///   there is no default display
125    #[doc(alias = "gdk_display_get_default")]
126    #[doc(alias = "get_default")]
127    #[allow(clippy::should_implement_trait)]
128    pub fn default() -> Option<Display> {
129        assert_initialized_main_thread!();
130        unsafe { from_glib_none(ffi::gdk_display_get_default()) }
131    }
132
133    /// Opens a display.
134    ///
135    /// If opening the display fails, `NULL` is returned.
136    /// ## `display_name`
137    /// the name of the display to open
138    ///
139    /// # Returns
140    ///
141    /// a [`Display`][crate::Display]
142    #[doc(alias = "gdk_display_open")]
143    pub fn open(display_name: Option<&str>) -> Option<Display> {
144        assert_initialized_main_thread!();
145        unsafe { from_glib_none(ffi::gdk_display_open(display_name.to_glib_none().0)) }
146    }
147}
148
149impl std::fmt::Display for Display {
150    #[inline]
151    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
152        f.write_str(&DisplayExt::name(self))
153    }
154}
155
156/// Trait containing all [`struct@Display`] methods.
157///
158/// # Implementors
159///
160/// [`Display`][struct@crate::Display]
161pub trait DisplayExt: IsA<Display> + 'static {
162    /// Emits a short beep on @self
163    #[doc(alias = "gdk_display_beep")]
164    fn beep(&self) {
165        unsafe {
166            ffi::gdk_display_beep(self.as_ref().to_glib_none().0);
167        }
168    }
169
170    /// Closes the connection to the windowing system for the given display.
171    ///
172    /// This cleans up associated resources.
173    #[doc(alias = "gdk_display_close")]
174    fn close(&self) {
175        unsafe {
176            ffi::gdk_display_close(self.as_ref().to_glib_none().0);
177        }
178    }
179
180    /// Creates a new [`GLContext`][crate::GLContext] for the [`Display`][crate::Display].
181    ///
182    /// The context is disconnected from any particular surface or surface
183    /// and cannot be used to draw to any surface. It can only be used to
184    /// draw to non-surface framebuffers like textures.
185    ///
186    /// If the creation of the [`GLContext`][crate::GLContext] failed, @error will be set.
187    /// Before using the returned [`GLContext`][crate::GLContext], you will need to
188    /// call [`GLContextExt::make_current()`][crate::prelude::GLContextExt::make_current()] or [`GLContextExt::realize()`][crate::prelude::GLContextExt::realize()].
189    ///
190    /// # Returns
191    ///
192    /// the newly created [`GLContext`][crate::GLContext]
193    #[cfg(feature = "v4_6")]
194    #[cfg_attr(docsrs, doc(cfg(feature = "v4_6")))]
195    #[doc(alias = "gdk_display_create_gl_context")]
196    fn create_gl_context(&self) -> Result<GLContext, glib::Error> {
197        unsafe {
198            let mut error = std::ptr::null_mut();
199            let ret =
200                ffi::gdk_display_create_gl_context(self.as_ref().to_glib_none().0, &mut error);
201            if error.is_null() {
202                Ok(from_glib_full(ret))
203            } else {
204                Err(from_glib_full(error))
205            }
206        }
207    }
208
209    /// Returns [`true`] if there is an ongoing grab on @device for @self.
210    /// ## `device`
211    /// a [`Device`][crate::Device]
212    ///
213    /// # Returns
214    ///
215    /// [`true`] if there is a grab in effect for @device.
216    #[doc(alias = "gdk_display_device_is_grabbed")]
217    fn device_is_grabbed(&self, device: &impl IsA<Device>) -> bool {
218        unsafe {
219            from_glib(ffi::gdk_display_device_is_grabbed(
220                self.as_ref().to_glib_none().0,
221                device.as_ref().to_glib_none().0,
222            ))
223        }
224    }
225
226    /// Flushes any requests queued for the windowing system.
227    ///
228    /// This happens automatically when the main loop blocks waiting for new events,
229    /// but if your application is drawing without returning control to the main loop,
230    /// you may need to call this function explicitly. A common case where this function
231    /// needs to be called is when an application is executing drawing commands
232    /// from a thread other than the thread where the main loop is running.
233    ///
234    /// This is most useful for X11. On windowing systems where requests are
235    /// handled synchronously, this function will do nothing.
236    #[doc(alias = "gdk_display_flush")]
237    fn flush(&self) {
238        unsafe {
239            ffi::gdk_display_flush(self.as_ref().to_glib_none().0);
240        }
241    }
242
243    /// Returns a [`AppLaunchContext`][crate::AppLaunchContext] suitable for launching
244    /// applications on the given display.
245    ///
246    /// # Returns
247    ///
248    /// a new [`AppLaunchContext`][crate::AppLaunchContext] for @self
249    #[doc(alias = "gdk_display_get_app_launch_context")]
250    #[doc(alias = "get_app_launch_context")]
251    fn app_launch_context(&self) -> AppLaunchContext {
252        unsafe {
253            from_glib_full(ffi::gdk_display_get_app_launch_context(
254                self.as_ref().to_glib_none().0,
255            ))
256        }
257    }
258
259    /// Gets the clipboard used for copy/paste operations.
260    ///
261    /// # Returns
262    ///
263    /// the display's clipboard
264    #[doc(alias = "gdk_display_get_clipboard")]
265    #[doc(alias = "get_clipboard")]
266    fn clipboard(&self) -> Clipboard {
267        unsafe {
268            from_glib_none(ffi::gdk_display_get_clipboard(
269                self.as_ref().to_glib_none().0,
270            ))
271        }
272    }
273
274    /// Returns the default [`Seat`][crate::Seat] for this display.
275    ///
276    /// Note that a display may not have a seat. In this case,
277    /// this function will return [`None`].
278    ///
279    /// # Returns
280    ///
281    /// the default seat.
282    #[doc(alias = "gdk_display_get_default_seat")]
283    #[doc(alias = "get_default_seat")]
284    fn default_seat(&self) -> Option<Seat> {
285        unsafe {
286            from_glib_none(ffi::gdk_display_get_default_seat(
287                self.as_ref().to_glib_none().0,
288            ))
289        }
290    }
291
292    /// Returns the dma-buf formats that are supported on this display.
293    ///
294    /// GTK may use OpenGL or Vulkan to support some formats.
295    /// Calling this function will then initialize them if they aren't yet.
296    ///
297    /// The formats returned by this function can be used for negotiating
298    /// buffer formats with producers such as v4l, pipewire or GStreamer.
299    ///
300    /// To learn more about dma-bufs, see [`DmabufTextureBuilder`][crate::DmabufTextureBuilder].
301    ///
302    /// # Returns
303    ///
304    /// a [`DmabufFormats`][crate::DmabufFormats] object
305    #[cfg(feature = "v4_14")]
306    #[cfg_attr(docsrs, doc(cfg(feature = "v4_14")))]
307    #[doc(alias = "gdk_display_get_dmabuf_formats")]
308    #[doc(alias = "get_dmabuf_formats")]
309    #[doc(alias = "dmabuf-formats")]
310    fn dmabuf_formats(&self) -> DmabufFormats {
311        unsafe {
312            from_glib_none(ffi::gdk_display_get_dmabuf_formats(
313                self.as_ref().to_glib_none().0,
314            ))
315        }
316    }
317
318    /// Gets the monitor in which the largest area of @surface
319    /// resides.
320    /// ## `surface`
321    /// a [`Surface`][crate::Surface]
322    ///
323    /// # Returns
324    ///
325    /// the monitor with the largest
326    ///   overlap with @surface
327    #[doc(alias = "gdk_display_get_monitor_at_surface")]
328    #[doc(alias = "get_monitor_at_surface")]
329    fn monitor_at_surface(&self, surface: &impl IsA<Surface>) -> Option<Monitor> {
330        unsafe {
331            from_glib_none(ffi::gdk_display_get_monitor_at_surface(
332                self.as_ref().to_glib_none().0,
333                surface.as_ref().to_glib_none().0,
334            ))
335        }
336    }
337
338    /// Gets the list of monitors associated with this display.
339    ///
340    /// Subsequent calls to this function will always return the
341    /// same list for the same display.
342    ///
343    /// You can listen to the GListModel::items-changed signal on
344    /// this list to monitor changes to the monitor of this display.
345    ///
346    /// # Returns
347    ///
348    /// a `GListModel` of [`Monitor`][crate::Monitor]
349    #[doc(alias = "gdk_display_get_monitors")]
350    #[doc(alias = "get_monitors")]
351    fn monitors(&self) -> gio::ListModel {
352        unsafe {
353            from_glib_none(ffi::gdk_display_get_monitors(
354                self.as_ref().to_glib_none().0,
355            ))
356        }
357    }
358
359    /// Gets the name of the display.
360    ///
361    /// # Returns
362    ///
363    /// a string representing the display name. This string is owned
364    ///   by GDK and should not be modified or freed.
365    #[doc(alias = "gdk_display_get_name")]
366    #[doc(alias = "get_name")]
367    fn name(&self) -> glib::GString {
368        unsafe { from_glib_none(ffi::gdk_display_get_name(self.as_ref().to_glib_none().0)) }
369    }
370
371    /// Gets the clipboard used for the primary selection.
372    ///
373    /// On backends where the primary clipboard is not supported natively,
374    /// GDK emulates this clipboard locally.
375    ///
376    /// # Returns
377    ///
378    /// the primary clipboard
379    #[doc(alias = "gdk_display_get_primary_clipboard")]
380    #[doc(alias = "get_primary_clipboard")]
381    fn primary_clipboard(&self) -> Clipboard {
382        unsafe {
383            from_glib_none(ffi::gdk_display_get_primary_clipboard(
384                self.as_ref().to_glib_none().0,
385            ))
386        }
387    }
388
389    /// Gets the startup notification ID for a Wayland display, or [`None`]
390    /// if no ID has been defined.
391    ///
392    /// # Deprecated since 4.10
393    ///
394    ///
395    /// # Returns
396    ///
397    /// the startup notification ID for @self
398    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
399    #[allow(deprecated)]
400    #[doc(alias = "gdk_display_get_startup_notification_id")]
401    #[doc(alias = "get_startup_notification_id")]
402    fn startup_notification_id(&self) -> Option<glib::GString> {
403        unsafe {
404            from_glib_none(ffi::gdk_display_get_startup_notification_id(
405                self.as_ref().to_glib_none().0,
406            ))
407        }
408    }
409
410    /// Finds out if the display has been closed.
411    ///
412    /// # Returns
413    ///
414    /// [`true`] if the display is closed.
415    #[doc(alias = "gdk_display_is_closed")]
416    fn is_closed(&self) -> bool {
417        unsafe { from_glib(ffi::gdk_display_is_closed(self.as_ref().to_glib_none().0)) }
418    }
419
420    /// Returns whether surfaces can reasonably be expected to have
421    /// their alpha channel drawn correctly on the screen.
422    ///
423    /// Check [`is_rgba()`][Self::is_rgba()] for whether the display
424    /// supports an alpha channel.
425    ///
426    /// On X11 this function returns whether a compositing manager is
427    /// compositing on @self.
428    ///
429    /// On modern displays, this value is always [`true`].
430    ///
431    /// # Returns
432    ///
433    /// Whether surfaces with RGBA visuals can reasonably
434    ///   be expected to have their alpha channels drawn correctly
435    ///   on the screen.
436    #[doc(alias = "gdk_display_is_composited")]
437    #[doc(alias = "composited")]
438    fn is_composited(&self) -> bool {
439        unsafe {
440            from_glib(ffi::gdk_display_is_composited(
441                self.as_ref().to_glib_none().0,
442            ))
443        }
444    }
445
446    /// Returns whether surfaces on this @self are created with an
447    /// alpha channel.
448    ///
449    /// Even if a [`true`] is returned, it is possible that the
450    /// surface’s alpha channel won’t be honored when displaying the
451    /// surface on the screen: in particular, for X an appropriate
452    /// windowing manager and compositing manager must be running to
453    /// provide appropriate display. Use [`is_composited()`][Self::is_composited()]
454    /// to check if that is the case.
455    ///
456    /// On modern displays, this value is always [`true`].
457    ///
458    /// # Returns
459    ///
460    /// [`true`] if surfaces are created with an alpha channel or
461    ///   [`false`] if the display does not support this functionality.
462    #[doc(alias = "gdk_display_is_rgba")]
463    #[doc(alias = "rgba")]
464    fn is_rgba(&self) -> bool {
465        unsafe { from_glib(ffi::gdk_display_is_rgba(self.as_ref().to_glib_none().0)) }
466    }
467
468    /// Returns the list of seats known to @self.
469    ///
470    /// # Returns
471    ///
472    /// the
473    ///   list of seats known to the [`Display`][crate::Display]
474    #[doc(alias = "gdk_display_list_seats")]
475    fn list_seats(&self) -> Vec<Seat> {
476        unsafe {
477            FromGlibPtrContainer::from_glib_container(ffi::gdk_display_list_seats(
478                self.as_ref().to_glib_none().0,
479            ))
480        }
481    }
482
483    /// Indicates to the GUI environment that the application has
484    /// finished loading, using a given identifier.
485    ///
486    /// GTK will call this function automatically for [GtkWindow](../gtk4/class.Window.html)
487    /// with custom startup-notification identifier unless
488    /// [gtk_window_set_auto_startup_notification()](../gtk4/method.Window.set_auto_startup_notification.html)
489    /// is called to disable that feature.
490    ///
491    /// # Deprecated since 4.10
492    ///
493    /// Using [`ToplevelExt::set_startup_id()`][crate::prelude::ToplevelExt::set_startup_id()] is sufficient
494    /// ## `startup_id`
495    /// a startup-notification identifier, for which
496    ///   notification process should be completed
497    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
498    #[allow(deprecated)]
499    #[doc(alias = "gdk_display_notify_startup_complete")]
500    fn notify_startup_complete(&self, startup_id: &str) {
501        unsafe {
502            ffi::gdk_display_notify_startup_complete(
503                self.as_ref().to_glib_none().0,
504                startup_id.to_glib_none().0,
505            );
506        }
507    }
508
509    /// Checks that OpenGL is available for @self and ensures that it is
510    /// properly initialized.
511    /// When this fails, an @error will be set describing the error and this
512    /// function returns [`false`].
513    ///
514    /// Note that even if this function succeeds, creating a [`GLContext`][crate::GLContext]
515    /// may still fail.
516    ///
517    /// This function is idempotent. Calling it multiple times will just
518    /// return the same value or error.
519    ///
520    /// You never need to call this function, GDK will call it automatically
521    /// as needed. But you can use it as a check when setting up code that
522    /// might make use of OpenGL.
523    ///
524    /// # Returns
525    ///
526    /// [`true`] if the display supports OpenGL
527    #[cfg(feature = "v4_4")]
528    #[cfg_attr(docsrs, doc(cfg(feature = "v4_4")))]
529    #[doc(alias = "gdk_display_prepare_gl")]
530    fn prepare_gl(&self) -> Result<(), glib::Error> {
531        unsafe {
532            let mut error = std::ptr::null_mut();
533            let is_ok = ffi::gdk_display_prepare_gl(self.as_ref().to_glib_none().0, &mut error);
534            debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null());
535            if error.is_null() {
536                Ok(())
537            } else {
538                Err(from_glib_full(error))
539            }
540        }
541    }
542
543    /// Adds the given event to the event queue for @self.
544    ///
545    /// # Deprecated since 4.10
546    ///
547    /// This function is only useful in very
548    /// special situations and should not be used by applications.
549    /// ## `event`
550    /// a [`Event`][crate::Event]
551    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
552    #[allow(deprecated)]
553    #[doc(alias = "gdk_display_put_event")]
554    fn put_event(&self, event: impl AsRef<Event>) {
555        unsafe {
556            ffi::gdk_display_put_event(
557                self.as_ref().to_glib_none().0,
558                event.as_ref().to_glib_none().0,
559            );
560        }
561    }
562
563    /// Returns [`true`] if the display supports input shapes.
564    ///
565    /// This means that [`SurfaceExt::set_input_region()`][crate::prelude::SurfaceExt::set_input_region()] can
566    /// be used to modify the input shape of surfaces on @self.
567    ///
568    /// On modern displays, this value is always [`true`].
569    ///
570    /// # Returns
571    ///
572    /// [`true`] if surfaces with modified input shape are supported
573    #[doc(alias = "gdk_display_supports_input_shapes")]
574    #[doc(alias = "input-shapes")]
575    fn supports_input_shapes(&self) -> bool {
576        unsafe {
577            from_glib(ffi::gdk_display_supports_input_shapes(
578                self.as_ref().to_glib_none().0,
579            ))
580        }
581    }
582
583    /// Returns whether it's possible for a surface to draw outside of the window area.
584    ///
585    /// If [`true`] is returned the application decides if it wants to draw shadows.
586    /// If [`false`] is returned, the compositor decides if it wants to draw shadows.
587    ///
588    /// # Returns
589    ///
590    /// [`true`] if surfaces can draw shadows or
591    ///   [`false`] if the display does not support this functionality.
592    #[cfg(feature = "v4_14")]
593    #[cfg_attr(docsrs, doc(cfg(feature = "v4_14")))]
594    #[doc(alias = "gdk_display_supports_shadow_width")]
595    #[doc(alias = "shadow-width")]
596    fn supports_shadow_width(&self) -> bool {
597        unsafe {
598            from_glib(ffi::gdk_display_supports_shadow_width(
599                self.as_ref().to_glib_none().0,
600            ))
601        }
602    }
603
604    /// Flushes any requests queued for the windowing system and waits until all
605    /// requests have been handled.
606    ///
607    /// This is often used for making sure that the display is synchronized
608    /// with the current state of the program. Calling [`sync()`][Self::sync()]
609    /// before `GdkX11::Display::error_trap_pop()` makes sure that any errors
610    /// generated from earlier requests are handled before the error trap is removed.
611    ///
612    /// This is most useful for X11. On windowing systems where requests are
613    /// handled synchronously, this function will do nothing.
614    #[doc(alias = "gdk_display_sync")]
615    fn sync(&self) {
616        unsafe {
617            ffi::gdk_display_sync(self.as_ref().to_glib_none().0);
618        }
619    }
620
621    /// Emitted when the connection to the windowing system for @display is closed.
622    /// ## `is_error`
623    /// [`true`] if the display was closed due to an error
624    #[doc(alias = "closed")]
625    fn connect_closed<F: Fn(&Self, bool) + 'static>(&self, f: F) -> SignalHandlerId {
626        unsafe extern "C" fn closed_trampoline<P: IsA<Display>, F: Fn(&P, bool) + 'static>(
627            this: *mut ffi::GdkDisplay,
628            is_error: glib::ffi::gboolean,
629            f: glib::ffi::gpointer,
630        ) {
631            let f: &F = &*(f as *const F);
632            f(
633                Display::from_glib_borrow(this).unsafe_cast_ref(),
634                from_glib(is_error),
635            )
636        }
637        unsafe {
638            let f: Box_<F> = Box_::new(f);
639            connect_raw(
640                self.as_ptr() as *mut _,
641                c"closed".as_ptr() as *const _,
642                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
643                    closed_trampoline::<Self, F> as *const (),
644                )),
645                Box_::into_raw(f),
646            )
647        }
648    }
649
650    /// Emitted when the connection to the windowing system for @display is opened.
651    #[doc(alias = "opened")]
652    fn connect_opened<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
653        unsafe extern "C" fn opened_trampoline<P: IsA<Display>, F: Fn(&P) + 'static>(
654            this: *mut ffi::GdkDisplay,
655            f: glib::ffi::gpointer,
656        ) {
657            let f: &F = &*(f as *const F);
658            f(Display::from_glib_borrow(this).unsafe_cast_ref())
659        }
660        unsafe {
661            let f: Box_<F> = Box_::new(f);
662            connect_raw(
663                self.as_ptr() as *mut _,
664                c"opened".as_ptr() as *const _,
665                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
666                    opened_trampoline::<Self, F> as *const (),
667                )),
668                Box_::into_raw(f),
669            )
670        }
671    }
672
673    /// Emitted whenever a new seat is made known to the windowing system.
674    /// ## `seat`
675    /// the seat that was just added
676    #[doc(alias = "seat-added")]
677    fn connect_seat_added<F: Fn(&Self, &Seat) + 'static>(&self, f: F) -> SignalHandlerId {
678        unsafe extern "C" fn seat_added_trampoline<P: IsA<Display>, F: Fn(&P, &Seat) + 'static>(
679            this: *mut ffi::GdkDisplay,
680            seat: *mut ffi::GdkSeat,
681            f: glib::ffi::gpointer,
682        ) {
683            let f: &F = &*(f as *const F);
684            f(
685                Display::from_glib_borrow(this).unsafe_cast_ref(),
686                &from_glib_borrow(seat),
687            )
688        }
689        unsafe {
690            let f: Box_<F> = Box_::new(f);
691            connect_raw(
692                self.as_ptr() as *mut _,
693                c"seat-added".as_ptr() as *const _,
694                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
695                    seat_added_trampoline::<Self, F> as *const (),
696                )),
697                Box_::into_raw(f),
698            )
699        }
700    }
701
702    /// Emitted whenever a seat is removed by the windowing system.
703    /// ## `seat`
704    /// the seat that was just removed
705    #[doc(alias = "seat-removed")]
706    fn connect_seat_removed<F: Fn(&Self, &Seat) + 'static>(&self, f: F) -> SignalHandlerId {
707        unsafe extern "C" fn seat_removed_trampoline<
708            P: IsA<Display>,
709            F: Fn(&P, &Seat) + 'static,
710        >(
711            this: *mut ffi::GdkDisplay,
712            seat: *mut ffi::GdkSeat,
713            f: glib::ffi::gpointer,
714        ) {
715            let f: &F = &*(f as *const F);
716            f(
717                Display::from_glib_borrow(this).unsafe_cast_ref(),
718                &from_glib_borrow(seat),
719            )
720        }
721        unsafe {
722            let f: Box_<F> = Box_::new(f);
723            connect_raw(
724                self.as_ptr() as *mut _,
725                c"seat-removed".as_ptr() as *const _,
726                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
727                    seat_removed_trampoline::<Self, F> as *const (),
728                )),
729                Box_::into_raw(f),
730            )
731        }
732    }
733
734    /// Emitted whenever a setting changes its value.
735    /// ## `setting`
736    /// the name of the setting that changed
737    #[doc(alias = "setting-changed")]
738    fn connect_setting_changed<F: Fn(&Self, &str) + 'static>(&self, f: F) -> SignalHandlerId {
739        unsafe extern "C" fn setting_changed_trampoline<
740            P: IsA<Display>,
741            F: Fn(&P, &str) + 'static,
742        >(
743            this: *mut ffi::GdkDisplay,
744            setting: *mut std::ffi::c_char,
745            f: glib::ffi::gpointer,
746        ) {
747            let f: &F = &*(f as *const F);
748            f(
749                Display::from_glib_borrow(this).unsafe_cast_ref(),
750                &glib::GString::from_glib_borrow(setting),
751            )
752        }
753        unsafe {
754            let f: Box_<F> = Box_::new(f);
755            connect_raw(
756                self.as_ptr() as *mut _,
757                c"setting-changed".as_ptr() as *const _,
758                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
759                    setting_changed_trampoline::<Self, F> as *const (),
760                )),
761                Box_::into_raw(f),
762            )
763        }
764    }
765
766    #[doc(alias = "composited")]
767    fn connect_composited_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
768        unsafe extern "C" fn notify_composited_trampoline<P: IsA<Display>, F: Fn(&P) + 'static>(
769            this: *mut ffi::GdkDisplay,
770            _param_spec: glib::ffi::gpointer,
771            f: glib::ffi::gpointer,
772        ) {
773            let f: &F = &*(f as *const F);
774            f(Display::from_glib_borrow(this).unsafe_cast_ref())
775        }
776        unsafe {
777            let f: Box_<F> = Box_::new(f);
778            connect_raw(
779                self.as_ptr() as *mut _,
780                c"notify::composited".as_ptr() as *const _,
781                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
782                    notify_composited_trampoline::<Self, F> as *const (),
783                )),
784                Box_::into_raw(f),
785            )
786        }
787    }
788
789    #[cfg(feature = "v4_14")]
790    #[cfg_attr(docsrs, doc(cfg(feature = "v4_14")))]
791    #[doc(alias = "dmabuf-formats")]
792    fn connect_dmabuf_formats_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
793        unsafe extern "C" fn notify_dmabuf_formats_trampoline<
794            P: IsA<Display>,
795            F: Fn(&P) + 'static,
796        >(
797            this: *mut ffi::GdkDisplay,
798            _param_spec: glib::ffi::gpointer,
799            f: glib::ffi::gpointer,
800        ) {
801            let f: &F = &*(f as *const F);
802            f(Display::from_glib_borrow(this).unsafe_cast_ref())
803        }
804        unsafe {
805            let f: Box_<F> = Box_::new(f);
806            connect_raw(
807                self.as_ptr() as *mut _,
808                c"notify::dmabuf-formats".as_ptr() as *const _,
809                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
810                    notify_dmabuf_formats_trampoline::<Self, F> as *const (),
811                )),
812                Box_::into_raw(f),
813            )
814        }
815    }
816
817    #[doc(alias = "input-shapes")]
818    fn connect_input_shapes_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
819        unsafe extern "C" fn notify_input_shapes_trampoline<
820            P: IsA<Display>,
821            F: Fn(&P) + 'static,
822        >(
823            this: *mut ffi::GdkDisplay,
824            _param_spec: glib::ffi::gpointer,
825            f: glib::ffi::gpointer,
826        ) {
827            let f: &F = &*(f as *const F);
828            f(Display::from_glib_borrow(this).unsafe_cast_ref())
829        }
830        unsafe {
831            let f: Box_<F> = Box_::new(f);
832            connect_raw(
833                self.as_ptr() as *mut _,
834                c"notify::input-shapes".as_ptr() as *const _,
835                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
836                    notify_input_shapes_trampoline::<Self, F> as *const (),
837                )),
838                Box_::into_raw(f),
839            )
840        }
841    }
842
843    #[doc(alias = "rgba")]
844    fn connect_rgba_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
845        unsafe extern "C" fn notify_rgba_trampoline<P: IsA<Display>, F: Fn(&P) + 'static>(
846            this: *mut ffi::GdkDisplay,
847            _param_spec: glib::ffi::gpointer,
848            f: glib::ffi::gpointer,
849        ) {
850            let f: &F = &*(f as *const F);
851            f(Display::from_glib_borrow(this).unsafe_cast_ref())
852        }
853        unsafe {
854            let f: Box_<F> = Box_::new(f);
855            connect_raw(
856                self.as_ptr() as *mut _,
857                c"notify::rgba".as_ptr() as *const _,
858                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
859                    notify_rgba_trampoline::<Self, F> as *const (),
860                )),
861                Box_::into_raw(f),
862            )
863        }
864    }
865
866    #[cfg(feature = "v4_14")]
867    #[cfg_attr(docsrs, doc(cfg(feature = "v4_14")))]
868    #[doc(alias = "shadow-width")]
869    fn connect_shadow_width_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
870        unsafe extern "C" fn notify_shadow_width_trampoline<
871            P: IsA<Display>,
872            F: Fn(&P) + 'static,
873        >(
874            this: *mut ffi::GdkDisplay,
875            _param_spec: glib::ffi::gpointer,
876            f: glib::ffi::gpointer,
877        ) {
878            let f: &F = &*(f as *const F);
879            f(Display::from_glib_borrow(this).unsafe_cast_ref())
880        }
881        unsafe {
882            let f: Box_<F> = Box_::new(f);
883            connect_raw(
884                self.as_ptr() as *mut _,
885                c"notify::shadow-width".as_ptr() as *const _,
886                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
887                    notify_shadow_width_trampoline::<Self, F> as *const (),
888                )),
889                Box_::into_raw(f),
890            )
891        }
892    }
893}
894
895impl<O: IsA<Display>> DisplayExt for O {}