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