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