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::{AppLaunchContext, Clipboard, Device, Event, Monitor, Seat, Surface, ffi};
15use glib::{
16 object::ObjectType as _,
17 prelude::*,
18 signal::{SignalHandlerId, connect_raw},
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 unsafe {
638 let f: &F = &*(f as *const F);
639 f(
640 Display::from_glib_borrow(this).unsafe_cast_ref(),
641 from_glib(is_error),
642 )
643 }
644 }
645 unsafe {
646 let f: Box_<F> = Box_::new(f);
647 connect_raw(
648 self.as_ptr() as *mut _,
649 c"closed".as_ptr() as *const _,
650 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
651 closed_trampoline::<Self, F> as *const (),
652 )),
653 Box_::into_raw(f),
654 )
655 }
656 }
657
658 /// Emitted when the connection to the windowing system for @display is opened.
659 #[doc(alias = "opened")]
660 fn connect_opened<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
661 unsafe extern "C" fn opened_trampoline<P: IsA<Display>, F: Fn(&P) + 'static>(
662 this: *mut ffi::GdkDisplay,
663 f: glib::ffi::gpointer,
664 ) {
665 unsafe {
666 let f: &F = &*(f as *const F);
667 f(Display::from_glib_borrow(this).unsafe_cast_ref())
668 }
669 }
670 unsafe {
671 let f: Box_<F> = Box_::new(f);
672 connect_raw(
673 self.as_ptr() as *mut _,
674 c"opened".as_ptr() as *const _,
675 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
676 opened_trampoline::<Self, F> as *const (),
677 )),
678 Box_::into_raw(f),
679 )
680 }
681 }
682
683 /// Emitted whenever a new seat is made known to the windowing system.
684 /// ## `seat`
685 /// the seat that was just added
686 #[doc(alias = "seat-added")]
687 fn connect_seat_added<F: Fn(&Self, &Seat) + 'static>(&self, f: F) -> SignalHandlerId {
688 unsafe extern "C" fn seat_added_trampoline<P: IsA<Display>, F: Fn(&P, &Seat) + 'static>(
689 this: *mut ffi::GdkDisplay,
690 seat: *mut ffi::GdkSeat,
691 f: glib::ffi::gpointer,
692 ) {
693 unsafe {
694 let f: &F = &*(f as *const F);
695 f(
696 Display::from_glib_borrow(this).unsafe_cast_ref(),
697 &from_glib_borrow(seat),
698 )
699 }
700 }
701 unsafe {
702 let f: Box_<F> = Box_::new(f);
703 connect_raw(
704 self.as_ptr() as *mut _,
705 c"seat-added".as_ptr() as *const _,
706 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
707 seat_added_trampoline::<Self, F> as *const (),
708 )),
709 Box_::into_raw(f),
710 )
711 }
712 }
713
714 /// Emitted whenever a seat is removed by the windowing system.
715 /// ## `seat`
716 /// the seat that was just removed
717 #[doc(alias = "seat-removed")]
718 fn connect_seat_removed<F: Fn(&Self, &Seat) + 'static>(&self, f: F) -> SignalHandlerId {
719 unsafe extern "C" fn seat_removed_trampoline<
720 P: IsA<Display>,
721 F: Fn(&P, &Seat) + 'static,
722 >(
723 this: *mut ffi::GdkDisplay,
724 seat: *mut ffi::GdkSeat,
725 f: glib::ffi::gpointer,
726 ) {
727 unsafe {
728 let f: &F = &*(f as *const F);
729 f(
730 Display::from_glib_borrow(this).unsafe_cast_ref(),
731 &from_glib_borrow(seat),
732 )
733 }
734 }
735 unsafe {
736 let f: Box_<F> = Box_::new(f);
737 connect_raw(
738 self.as_ptr() as *mut _,
739 c"seat-removed".as_ptr() as *const _,
740 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
741 seat_removed_trampoline::<Self, F> as *const (),
742 )),
743 Box_::into_raw(f),
744 )
745 }
746 }
747
748 /// Emitted whenever a setting changes its value.
749 /// ## `setting`
750 /// the name of the setting that changed
751 #[doc(alias = "setting-changed")]
752 fn connect_setting_changed<F: Fn(&Self, &str) + 'static>(&self, f: F) -> SignalHandlerId {
753 unsafe extern "C" fn setting_changed_trampoline<
754 P: IsA<Display>,
755 F: Fn(&P, &str) + 'static,
756 >(
757 this: *mut ffi::GdkDisplay,
758 setting: *mut std::ffi::c_char,
759 f: glib::ffi::gpointer,
760 ) {
761 unsafe {
762 let f: &F = &*(f as *const F);
763 f(
764 Display::from_glib_borrow(this).unsafe_cast_ref(),
765 &glib::GString::from_glib_borrow(setting),
766 )
767 }
768 }
769 unsafe {
770 let f: Box_<F> = Box_::new(f);
771 connect_raw(
772 self.as_ptr() as *mut _,
773 c"setting-changed".as_ptr() as *const _,
774 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
775 setting_changed_trampoline::<Self, F> as *const (),
776 )),
777 Box_::into_raw(f),
778 )
779 }
780 }
781
782 #[doc(alias = "composited")]
783 fn connect_composited_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
784 unsafe extern "C" fn notify_composited_trampoline<P: IsA<Display>, F: Fn(&P) + 'static>(
785 this: *mut ffi::GdkDisplay,
786 _param_spec: glib::ffi::gpointer,
787 f: glib::ffi::gpointer,
788 ) {
789 unsafe {
790 let f: &F = &*(f as *const F);
791 f(Display::from_glib_borrow(this).unsafe_cast_ref())
792 }
793 }
794 unsafe {
795 let f: Box_<F> = Box_::new(f);
796 connect_raw(
797 self.as_ptr() as *mut _,
798 c"notify::composited".as_ptr() as *const _,
799 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
800 notify_composited_trampoline::<Self, F> as *const (),
801 )),
802 Box_::into_raw(f),
803 )
804 }
805 }
806
807 #[cfg(feature = "v4_14")]
808 #[cfg_attr(docsrs, doc(cfg(feature = "v4_14")))]
809 #[doc(alias = "dmabuf-formats")]
810 fn connect_dmabuf_formats_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
811 unsafe extern "C" fn notify_dmabuf_formats_trampoline<
812 P: IsA<Display>,
813 F: Fn(&P) + 'static,
814 >(
815 this: *mut ffi::GdkDisplay,
816 _param_spec: glib::ffi::gpointer,
817 f: glib::ffi::gpointer,
818 ) {
819 unsafe {
820 let f: &F = &*(f as *const F);
821 f(Display::from_glib_borrow(this).unsafe_cast_ref())
822 }
823 }
824 unsafe {
825 let f: Box_<F> = Box_::new(f);
826 connect_raw(
827 self.as_ptr() as *mut _,
828 c"notify::dmabuf-formats".as_ptr() as *const _,
829 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
830 notify_dmabuf_formats_trampoline::<Self, F> as *const (),
831 )),
832 Box_::into_raw(f),
833 )
834 }
835 }
836
837 #[doc(alias = "input-shapes")]
838 fn connect_input_shapes_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
839 unsafe extern "C" fn notify_input_shapes_trampoline<
840 P: IsA<Display>,
841 F: Fn(&P) + 'static,
842 >(
843 this: *mut ffi::GdkDisplay,
844 _param_spec: glib::ffi::gpointer,
845 f: glib::ffi::gpointer,
846 ) {
847 unsafe {
848 let f: &F = &*(f as *const F);
849 f(Display::from_glib_borrow(this).unsafe_cast_ref())
850 }
851 }
852 unsafe {
853 let f: Box_<F> = Box_::new(f);
854 connect_raw(
855 self.as_ptr() as *mut _,
856 c"notify::input-shapes".as_ptr() as *const _,
857 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
858 notify_input_shapes_trampoline::<Self, F> as *const (),
859 )),
860 Box_::into_raw(f),
861 )
862 }
863 }
864
865 #[doc(alias = "rgba")]
866 fn connect_rgba_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
867 unsafe extern "C" fn notify_rgba_trampoline<P: IsA<Display>, F: Fn(&P) + 'static>(
868 this: *mut ffi::GdkDisplay,
869 _param_spec: glib::ffi::gpointer,
870 f: glib::ffi::gpointer,
871 ) {
872 unsafe {
873 let f: &F = &*(f as *const F);
874 f(Display::from_glib_borrow(this).unsafe_cast_ref())
875 }
876 }
877 unsafe {
878 let f: Box_<F> = Box_::new(f);
879 connect_raw(
880 self.as_ptr() as *mut _,
881 c"notify::rgba".as_ptr() as *const _,
882 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
883 notify_rgba_trampoline::<Self, F> as *const (),
884 )),
885 Box_::into_raw(f),
886 )
887 }
888 }
889
890 #[cfg(feature = "v4_14")]
891 #[cfg_attr(docsrs, doc(cfg(feature = "v4_14")))]
892 #[doc(alias = "shadow-width")]
893 fn connect_shadow_width_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
894 unsafe extern "C" fn notify_shadow_width_trampoline<
895 P: IsA<Display>,
896 F: Fn(&P) + 'static,
897 >(
898 this: *mut ffi::GdkDisplay,
899 _param_spec: glib::ffi::gpointer,
900 f: glib::ffi::gpointer,
901 ) {
902 unsafe {
903 let f: &F = &*(f as *const F);
904 f(Display::from_glib_borrow(this).unsafe_cast_ref())
905 }
906 }
907 unsafe {
908 let f: Box_<F> = Box_::new(f);
909 connect_raw(
910 self.as_ptr() as *mut _,
911 c"notify::shadow-width".as_ptr() as *const _,
912 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
913 notify_shadow_width_trampoline::<Self, F> as *const (),
914 )),
915 Box_::into_raw(f),
916 )
917 }
918 }
919}
920
921impl<O: IsA<Display>> DisplayExt for O {}