Skip to main content

gdk4/auto/
device.rs

1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from gir-files (https://github.com/gtk-rs/gir-files)
3// DO NOT EDIT
4
5use crate::{DeviceTool, Display, InputSource, ModifierType, Seat, Surface, ffi};
6use glib::{
7    object::ObjectType as _,
8    prelude::*,
9    signal::{SignalHandlerId, connect_raw},
10    translate::*,
11};
12use std::boxed::Box as Box_;
13
14glib::wrapper! {
15    /// Represents an input device, such as a keyboard, mouse or touchpad.
16    ///
17    /// See the [`Seat`][crate::Seat] documentation for more information
18    /// about the various kinds of devices, and their relationships.
19    ///
20    /// This is an Abstract Base Class, you cannot instantiate it.
21    ///
22    /// ## Properties
23    ///
24    ///
25    /// #### `active-layout-index`
26    ///  The index of the keyboard active layout of a [`Device`][crate::Device].
27    ///
28    /// Will be -1 if there is no valid active layout.
29    ///
30    /// This is only relevant for keyboard devices.
31    ///
32    /// Readable
33    ///
34    ///
35    /// #### `caps-lock-state`
36    ///  Whether Caps Lock is on.
37    ///
38    /// This is only relevant for keyboard devices.
39    ///
40    /// Readable
41    ///
42    ///
43    /// #### `direction`
44    ///  The direction of the current layout.
45    ///
46    /// This is only relevant for keyboard devices.
47    ///
48    /// Readable
49    ///
50    ///
51    /// #### `display`
52    ///  The [`Display`][crate::Display] the [`Device`][crate::Device] pertains to.
53    ///
54    /// Readable | Writeable | Construct Only
55    ///
56    ///
57    /// #### `has-bidi-layouts`
58    ///  Whether the device has both right-to-left and left-to-right layouts.
59    ///
60    /// This is only relevant for keyboard devices.
61    ///
62    /// Readable
63    ///
64    ///
65    /// #### `has-cursor`
66    ///  Whether the device is represented by a cursor on the screen.
67    ///
68    /// Readable | Writeable | Construct Only
69    ///
70    ///
71    /// #### `layout-names`
72    ///  The names of the keyboard layouts of a [`Device`][crate::Device].
73    ///
74    /// This is only relevant for keyboard devices.
75    ///
76    /// Readable
77    ///
78    ///
79    /// #### `modifier-state`
80    ///  The current modifier state of the device.
81    ///
82    /// This is only relevant for keyboard devices.
83    ///
84    /// Readable
85    ///
86    ///
87    /// #### `n-axes`
88    ///  Number of axes in the device.
89    ///
90    /// Readable
91    ///
92    ///
93    /// #### `name`
94    ///  The device name.
95    ///
96    /// Readable | Writeable | Construct Only
97    ///
98    ///
99    /// #### `num-lock-state`
100    ///  Whether Num Lock is on.
101    ///
102    /// This is only relevant for keyboard devices.
103    ///
104    /// Readable
105    ///
106    ///
107    /// #### `num-touches`
108    ///  The maximal number of concurrent touches on a touch device.
109    ///
110    /// Will be 0 if the device is not a touch device or if the number
111    /// of touches is unknown.
112    ///
113    /// Readable | Writeable | Construct Only
114    ///
115    ///
116    /// #### `product-id`
117    ///  Product ID of this device.
118    ///
119    /// See [`DeviceExt::product_id()`][crate::prelude::DeviceExt::product_id()].
120    ///
121    /// Readable | Writeable | Construct Only
122    ///
123    ///
124    /// #### `scroll-lock-state`
125    ///  Whether Scroll Lock is on.
126    ///
127    /// This is only relevant for keyboard devices.
128    ///
129    /// Readable
130    ///
131    ///
132    /// #### `seat`
133    ///  [`Seat`][crate::Seat] of this device.
134    ///
135    /// Readable | Writeable
136    ///
137    ///
138    /// #### `source`
139    ///  Source type for the device.
140    ///
141    /// Readable | Writeable | Construct Only
142    ///
143    ///
144    /// #### `tool`
145    ///  The [`DeviceTool`][crate::DeviceTool] that is currently used with this device.
146    ///
147    /// Readable
148    ///
149    ///
150    /// #### `vendor-id`
151    ///  Vendor ID of this device.
152    ///
153    /// See [`DeviceExt::vendor_id()`][crate::prelude::DeviceExt::vendor_id()].
154    ///
155    /// Readable | Writeable | Construct Only
156    ///
157    /// ## Signals
158    ///
159    ///
160    /// #### `changed`
161    ///  Emitted either when the number of either axes or keys changes.
162    ///
163    /// On X11 this will normally happen when the physical device
164    /// routing events through the logical device changes (for
165    /// example, user switches from the USB mouse to a tablet); in
166    /// that case the logical device will change to reflect the axes
167    /// and keys on the new physical device.
168    ///
169    ///
170    ///
171    ///
172    /// #### `tool-changed`
173    ///  Emitted on pen/eraser devices whenever tools enter or leave proximity.
174    ///
175    ///
176    ///
177    /// # Implements
178    ///
179    /// [`DeviceExt`][trait@crate::prelude::DeviceExt]
180    #[doc(alias = "GdkDevice")]
181    pub struct Device(Object<ffi::GdkDevice>);
182
183    match fn {
184        type_ => || ffi::gdk_device_get_type(),
185    }
186}
187
188impl Device {
189    pub const NONE: Option<&'static Device> = None;
190}
191
192impl std::fmt::Display for Device {
193    #[inline]
194    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
195        f.write_str(&DeviceExt::name(self))
196    }
197}
198
199/// Trait containing all [`struct@Device`] methods.
200///
201/// # Implementors
202///
203/// [`DevicePad`][struct@crate::DevicePad], [`Device`][struct@crate::Device]
204pub trait DeviceExt: IsA<Device> + 'static {
205    /// Retrieves the index of the active layout of the keyboard.
206    ///
207    /// If there is no valid active layout for the [`Device`][crate::Device], this function will
208    /// return -1;
209    ///
210    /// This is only relevant for keyboard devices.
211    ///
212    /// # Returns
213    ///
214    /// The layout index of the active layout or -1.
215    #[cfg(feature = "v4_18")]
216    #[cfg_attr(docsrs, doc(cfg(feature = "v4_18")))]
217    #[doc(alias = "gdk_device_get_active_layout_index")]
218    #[doc(alias = "get_active_layout_index")]
219    #[doc(alias = "active-layout-index")]
220    fn active_layout_index(&self) -> i32 {
221        unsafe { ffi::gdk_device_get_active_layout_index(self.as_ref().to_glib_none().0) }
222    }
223
224    /// Retrieves whether the Caps Lock modifier of the keyboard is locked.
225    ///
226    /// This is only relevant for keyboard devices.
227    ///
228    /// # Returns
229    ///
230    /// [`true`] if Caps Lock is on for @self
231    #[doc(alias = "gdk_device_get_caps_lock_state")]
232    #[doc(alias = "get_caps_lock_state")]
233    #[doc(alias = "caps-lock-state")]
234    fn is_caps_locked(&self) -> bool {
235        unsafe {
236            from_glib(ffi::gdk_device_get_caps_lock_state(
237                self.as_ref().to_glib_none().0,
238            ))
239        }
240    }
241
242    /// Retrieves the current tool for @self.
243    ///
244    /// # Returns
245    ///
246    /// the [`DeviceTool`][crate::DeviceTool]
247    #[doc(alias = "gdk_device_get_device_tool")]
248    #[doc(alias = "get_device_tool")]
249    #[doc(alias = "tool")]
250    fn device_tool(&self) -> Option<DeviceTool> {
251        unsafe {
252            from_glib_none(ffi::gdk_device_get_device_tool(
253                self.as_ref().to_glib_none().0,
254            ))
255        }
256    }
257
258    /// Returns the direction of effective layout of the keyboard.
259    ///
260    /// This is only relevant for keyboard devices.
261    ///
262    /// The direction of a layout is the direction of the majority
263    /// of its symbols. See `unichar_direction()`.
264    ///
265    /// # Returns
266    ///
267    /// [`pango::Direction::Ltr`][crate::pango::Direction::Ltr] or [`pango::Direction::Rtl`][crate::pango::Direction::Rtl]
268    ///   if it can determine the direction. [`pango::Direction::Neutral`][crate::pango::Direction::Neutral]
269    ///   otherwise
270    #[doc(alias = "gdk_device_get_direction")]
271    #[doc(alias = "get_direction")]
272    fn direction(&self) -> pango::Direction {
273        unsafe {
274            from_glib(ffi::gdk_device_get_direction(
275                self.as_ref().to_glib_none().0,
276            ))
277        }
278    }
279
280    /// Returns the [`Display`][crate::Display] to which @self pertains.
281    ///
282    /// # Returns
283    ///
284    /// a [`Display`][crate::Display]
285    #[doc(alias = "gdk_device_get_display")]
286    #[doc(alias = "get_display")]
287    fn display(&self) -> Display {
288        unsafe { from_glib_none(ffi::gdk_device_get_display(self.as_ref().to_glib_none().0)) }
289    }
290
291    /// Determines whether the pointer follows device motion.
292    ///
293    /// This is not meaningful for keyboard devices, which
294    /// don't have a pointer.
295    ///
296    /// # Returns
297    ///
298    /// [`true`] if the pointer follows device motion
299    #[doc(alias = "gdk_device_get_has_cursor")]
300    #[doc(alias = "get_has_cursor")]
301    #[doc(alias = "has-cursor")]
302    fn has_cursor(&self) -> bool {
303        unsafe {
304            from_glib(ffi::gdk_device_get_has_cursor(
305                self.as_ref().to_glib_none().0,
306            ))
307        }
308    }
309
310    /// Retrieves the names of the layouts of the keyboard.
311    ///
312    /// This is only relevant for keyboard devices.
313    ///
314    /// # Returns
315    ///
316    ///
317    ///   [`None`]-terminated array of strings of layouts,
318    #[cfg(feature = "v4_18")]
319    #[cfg_attr(docsrs, doc(cfg(feature = "v4_18")))]
320    #[doc(alias = "gdk_device_get_layout_names")]
321    #[doc(alias = "get_layout_names")]
322    #[doc(alias = "layout-names")]
323    fn layout_names(&self) -> Vec<glib::GString> {
324        unsafe {
325            FromGlibPtrContainer::from_glib_full(ffi::gdk_device_get_layout_names(
326                self.as_ref().to_glib_none().0,
327            ))
328        }
329    }
330
331    /// Retrieves the current modifier state of the keyboard.
332    ///
333    /// This is only relevant for keyboard devices.
334    ///
335    /// # Returns
336    ///
337    /// the current modifier state
338    #[doc(alias = "gdk_device_get_modifier_state")]
339    #[doc(alias = "get_modifier_state")]
340    #[doc(alias = "modifier-state")]
341    fn modifier_state(&self) -> ModifierType {
342        unsafe {
343            from_glib(ffi::gdk_device_get_modifier_state(
344                self.as_ref().to_glib_none().0,
345            ))
346        }
347    }
348
349    /// The name of the device, suitable for showing in a user interface.
350    ///
351    /// # Returns
352    ///
353    /// a name
354    #[doc(alias = "gdk_device_get_name")]
355    #[doc(alias = "get_name")]
356    fn name(&self) -> glib::GString {
357        unsafe { from_glib_none(ffi::gdk_device_get_name(self.as_ref().to_glib_none().0)) }
358    }
359
360    /// Retrieves whether the Num Lock modifier of the keyboard is locked.
361    ///
362    /// This is only relevant for keyboard devices.
363    ///
364    /// # Returns
365    ///
366    /// [`true`] if Num Lock is on for @self
367    #[doc(alias = "gdk_device_get_num_lock_state")]
368    #[doc(alias = "get_num_lock_state")]
369    #[doc(alias = "num-lock-state")]
370    fn is_num_locked(&self) -> bool {
371        unsafe {
372            from_glib(ffi::gdk_device_get_num_lock_state(
373                self.as_ref().to_glib_none().0,
374            ))
375        }
376    }
377
378    /// Retrieves the number of touch points associated to @self.
379    ///
380    /// # Returns
381    ///
382    /// the number of touch points
383    #[doc(alias = "gdk_device_get_num_touches")]
384    #[doc(alias = "get_num_touches")]
385    #[doc(alias = "num-touches")]
386    fn num_touches(&self) -> u32 {
387        unsafe { ffi::gdk_device_get_num_touches(self.as_ref().to_glib_none().0) }
388    }
389
390    /// Returns the product ID of this device.
391    ///
392    /// This ID is retrieved from the device, and does not change.
393    /// See [`vendor_id()`][Self::vendor_id()] for more information.
394    ///
395    /// # Returns
396    ///
397    /// the product ID
398    #[doc(alias = "gdk_device_get_product_id")]
399    #[doc(alias = "get_product_id")]
400    #[doc(alias = "product-id")]
401    fn product_id(&self) -> Option<glib::GString> {
402        unsafe {
403            from_glib_none(ffi::gdk_device_get_product_id(
404                self.as_ref().to_glib_none().0,
405            ))
406        }
407    }
408
409    /// Retrieves whether the Scroll Lock modifier of the keyboard is locked.
410    ///
411    /// This is only relevant for keyboard devices.
412    ///
413    /// # Returns
414    ///
415    /// [`true`] if Scroll Lock is on for @self
416    #[doc(alias = "gdk_device_get_scroll_lock_state")]
417    #[doc(alias = "get_scroll_lock_state")]
418    #[doc(alias = "scroll-lock-state")]
419    fn is_scroll_locked(&self) -> bool {
420        unsafe {
421            from_glib(ffi::gdk_device_get_scroll_lock_state(
422                self.as_ref().to_glib_none().0,
423            ))
424        }
425    }
426
427    /// Returns the [`Seat`][crate::Seat] the device belongs to.
428    ///
429    /// # Returns
430    ///
431    /// a [`Seat`][crate::Seat]
432    #[doc(alias = "gdk_device_get_seat")]
433    #[doc(alias = "get_seat")]
434    fn seat(&self) -> Seat {
435        unsafe { from_glib_none(ffi::gdk_device_get_seat(self.as_ref().to_glib_none().0)) }
436    }
437
438    /// Determines the type of the device.
439    ///
440    /// # Returns
441    ///
442    /// a [`InputSource`][crate::InputSource]
443    #[doc(alias = "gdk_device_get_source")]
444    #[doc(alias = "get_source")]
445    fn source(&self) -> InputSource {
446        unsafe { from_glib(ffi::gdk_device_get_source(self.as_ref().to_glib_none().0)) }
447    }
448
449    /// Obtains the surface underneath @self, returning the location of the
450    /// device in @win_x and @win_y.
451    ///
452    /// Returns [`None`] if the surface tree under @self is not known to GDK
453    /// (for example, belongs to another application).
454    ///
455    /// # Returns
456    ///
457    /// the [`Surface`][crate::Surface] under the
458    ///   device position
459    ///
460    /// ## `win_x`
461    /// return location for the X coordinate
462    ///   of the device location relative to the surface origin
463    ///
464    /// ## `win_y`
465    /// return location for the Y coordinate
466    ///   of the device location relative to the surface origin
467    #[doc(alias = "gdk_device_get_surface_at_position")]
468    #[doc(alias = "get_surface_at_position")]
469    fn surface_at_position(&self) -> (Option<Surface>, f64, f64) {
470        unsafe {
471            let mut win_x = std::mem::MaybeUninit::uninit();
472            let mut win_y = std::mem::MaybeUninit::uninit();
473            let ret = from_glib_none(ffi::gdk_device_get_surface_at_position(
474                self.as_ref().to_glib_none().0,
475                win_x.as_mut_ptr(),
476                win_y.as_mut_ptr(),
477            ));
478            (ret, win_x.assume_init(), win_y.assume_init())
479        }
480    }
481
482    /// Returns the timestamp of the last activity for this device.
483    ///
484    /// In practice, this means the timestamp of the last event that was
485    /// received from the OS for this device. (GTK may occasionally produce
486    /// events for a device that are not received from the OS, and will not
487    /// update the timestamp).
488    ///
489    /// # Returns
490    ///
491    /// the timestamp of the last activity for this device
492    #[cfg(feature = "v4_2")]
493    #[cfg_attr(docsrs, doc(cfg(feature = "v4_2")))]
494    #[doc(alias = "gdk_device_get_timestamp")]
495    #[doc(alias = "get_timestamp")]
496    fn timestamp(&self) -> u32 {
497        unsafe { ffi::gdk_device_get_timestamp(self.as_ref().to_glib_none().0) }
498    }
499
500    /// Returns the vendor ID of this device.
501    ///
502    /// This ID is retrieved from the device, and does not change.
503    ///
504    /// This function, together with [`product_id()`][Self::product_id()],
505    /// can be used to eg. compose `GSettings` paths to store settings
506    /// for this device.
507    ///
508    /// **⚠️ The following code is in c ⚠️**
509    ///
510    /// ```c
511    ///  static GSettings *
512    ///  get_device_settings (GdkDevice *device)
513    ///  {
514    ///    const char *vendor, *product;
515    ///    GSettings *settings;
516    ///    GdkDevice *device;
517    ///    char *path;
518    ///
519    ///    vendor = gdk_device_get_vendor_id (device);
520    ///    product = gdk_device_get_product_id (device);
521    ///
522    ///    path = g_strdup_printf ("/org/example/app/devices/%s:%s/", vendor, product);
523    ///    settings = g_settings_new_with_path (DEVICE_SCHEMA, path);
524    ///    g_free (path);
525    ///
526    ///    return settings;
527    ///  }
528    /// ```
529    ///
530    /// # Returns
531    ///
532    /// the vendor ID
533    #[doc(alias = "gdk_device_get_vendor_id")]
534    #[doc(alias = "get_vendor_id")]
535    #[doc(alias = "vendor-id")]
536    fn vendor_id(&self) -> Option<glib::GString> {
537        unsafe {
538            from_glib_none(ffi::gdk_device_get_vendor_id(
539                self.as_ref().to_glib_none().0,
540            ))
541        }
542    }
543
544    /// Determines if layouts for both right-to-left and
545    /// left-to-right languages are in use on the keyboard.
546    ///
547    /// This is only relevant for keyboard devices.
548    ///
549    /// # Returns
550    ///
551    /// [`true`] if there are layouts with both directions, [`false`] otherwise
552    #[doc(alias = "gdk_device_has_bidi_layouts")]
553    #[doc(alias = "has-bidi-layouts")]
554    fn has_bidi_layouts(&self) -> bool {
555        unsafe {
556            from_glib(ffi::gdk_device_has_bidi_layouts(
557                self.as_ref().to_glib_none().0,
558            ))
559        }
560    }
561
562    /// Number of axes in the device.
563    #[doc(alias = "n-axes")]
564    fn n_axes(&self) -> u32 {
565        ObjectExt::property(self.as_ref(), "n-axes")
566    }
567
568    /// [`Seat`][crate::Seat] of this device.
569    fn set_seat<P: IsA<Seat>>(&self, seat: Option<&P>) {
570        ObjectExt::set_property(self.as_ref(), "seat", seat)
571    }
572
573    /// Emitted either when the number of either axes or keys changes.
574    ///
575    /// On X11 this will normally happen when the physical device
576    /// routing events through the logical device changes (for
577    /// example, user switches from the USB mouse to a tablet); in
578    /// that case the logical device will change to reflect the axes
579    /// and keys on the new physical device.
580    #[doc(alias = "changed")]
581    fn connect_changed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
582        unsafe extern "C" fn changed_trampoline<P: IsA<Device>, F: Fn(&P) + 'static>(
583            this: *mut ffi::GdkDevice,
584            f: glib::ffi::gpointer,
585        ) {
586            unsafe {
587                let f: &F = &*(f as *const F);
588                f(Device::from_glib_borrow(this).unsafe_cast_ref())
589            }
590        }
591        unsafe {
592            let f: Box_<F> = Box_::new(f);
593            connect_raw(
594                self.as_ptr() as *mut _,
595                c"changed".as_ptr() as *const _,
596                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
597                    changed_trampoline::<Self, F> as *const (),
598                )),
599                Box_::into_raw(f),
600            )
601        }
602    }
603
604    /// Emitted on pen/eraser devices whenever tools enter or leave proximity.
605    /// ## `tool`
606    /// The new current tool
607    #[doc(alias = "tool-changed")]
608    fn connect_tool_changed<F: Fn(&Self, &DeviceTool) + 'static>(&self, f: F) -> SignalHandlerId {
609        unsafe extern "C" fn tool_changed_trampoline<
610            P: IsA<Device>,
611            F: Fn(&P, &DeviceTool) + 'static,
612        >(
613            this: *mut ffi::GdkDevice,
614            tool: *mut ffi::GdkDeviceTool,
615            f: glib::ffi::gpointer,
616        ) {
617            unsafe {
618                let f: &F = &*(f as *const F);
619                f(
620                    Device::from_glib_borrow(this).unsafe_cast_ref(),
621                    &from_glib_borrow(tool),
622                )
623            }
624        }
625        unsafe {
626            let f: Box_<F> = Box_::new(f);
627            connect_raw(
628                self.as_ptr() as *mut _,
629                c"tool-changed".as_ptr() as *const _,
630                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
631                    tool_changed_trampoline::<Self, F> as *const (),
632                )),
633                Box_::into_raw(f),
634            )
635        }
636    }
637
638    #[cfg(feature = "v4_18")]
639    #[cfg_attr(docsrs, doc(cfg(feature = "v4_18")))]
640    #[doc(alias = "active-layout-index")]
641    fn connect_active_layout_index_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
642        unsafe extern "C" fn notify_active_layout_index_trampoline<
643            P: IsA<Device>,
644            F: Fn(&P) + 'static,
645        >(
646            this: *mut ffi::GdkDevice,
647            _param_spec: glib::ffi::gpointer,
648            f: glib::ffi::gpointer,
649        ) {
650            unsafe {
651                let f: &F = &*(f as *const F);
652                f(Device::from_glib_borrow(this).unsafe_cast_ref())
653            }
654        }
655        unsafe {
656            let f: Box_<F> = Box_::new(f);
657            connect_raw(
658                self.as_ptr() as *mut _,
659                c"notify::active-layout-index".as_ptr() as *const _,
660                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
661                    notify_active_layout_index_trampoline::<Self, F> as *const (),
662                )),
663                Box_::into_raw(f),
664            )
665        }
666    }
667
668    #[doc(alias = "caps-lock-state")]
669    fn connect_caps_lock_state_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
670        unsafe extern "C" fn notify_caps_lock_state_trampoline<
671            P: IsA<Device>,
672            F: Fn(&P) + 'static,
673        >(
674            this: *mut ffi::GdkDevice,
675            _param_spec: glib::ffi::gpointer,
676            f: glib::ffi::gpointer,
677        ) {
678            unsafe {
679                let f: &F = &*(f as *const F);
680                f(Device::from_glib_borrow(this).unsafe_cast_ref())
681            }
682        }
683        unsafe {
684            let f: Box_<F> = Box_::new(f);
685            connect_raw(
686                self.as_ptr() as *mut _,
687                c"notify::caps-lock-state".as_ptr() as *const _,
688                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
689                    notify_caps_lock_state_trampoline::<Self, F> as *const (),
690                )),
691                Box_::into_raw(f),
692            )
693        }
694    }
695
696    #[doc(alias = "direction")]
697    fn connect_direction_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
698        unsafe extern "C" fn notify_direction_trampoline<P: IsA<Device>, F: Fn(&P) + 'static>(
699            this: *mut ffi::GdkDevice,
700            _param_spec: glib::ffi::gpointer,
701            f: glib::ffi::gpointer,
702        ) {
703            unsafe {
704                let f: &F = &*(f as *const F);
705                f(Device::from_glib_borrow(this).unsafe_cast_ref())
706            }
707        }
708        unsafe {
709            let f: Box_<F> = Box_::new(f);
710            connect_raw(
711                self.as_ptr() as *mut _,
712                c"notify::direction".as_ptr() as *const _,
713                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
714                    notify_direction_trampoline::<Self, F> as *const (),
715                )),
716                Box_::into_raw(f),
717            )
718        }
719    }
720
721    #[doc(alias = "has-bidi-layouts")]
722    fn connect_has_bidi_layouts_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
723        unsafe extern "C" fn notify_has_bidi_layouts_trampoline<
724            P: IsA<Device>,
725            F: Fn(&P) + 'static,
726        >(
727            this: *mut ffi::GdkDevice,
728            _param_spec: glib::ffi::gpointer,
729            f: glib::ffi::gpointer,
730        ) {
731            unsafe {
732                let f: &F = &*(f as *const F);
733                f(Device::from_glib_borrow(this).unsafe_cast_ref())
734            }
735        }
736        unsafe {
737            let f: Box_<F> = Box_::new(f);
738            connect_raw(
739                self.as_ptr() as *mut _,
740                c"notify::has-bidi-layouts".as_ptr() as *const _,
741                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
742                    notify_has_bidi_layouts_trampoline::<Self, F> as *const (),
743                )),
744                Box_::into_raw(f),
745            )
746        }
747    }
748
749    #[cfg(feature = "v4_18")]
750    #[cfg_attr(docsrs, doc(cfg(feature = "v4_18")))]
751    #[doc(alias = "layout-names")]
752    fn connect_layout_names_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
753        unsafe extern "C" fn notify_layout_names_trampoline<P: IsA<Device>, F: Fn(&P) + 'static>(
754            this: *mut ffi::GdkDevice,
755            _param_spec: glib::ffi::gpointer,
756            f: glib::ffi::gpointer,
757        ) {
758            unsafe {
759                let f: &F = &*(f as *const F);
760                f(Device::from_glib_borrow(this).unsafe_cast_ref())
761            }
762        }
763        unsafe {
764            let f: Box_<F> = Box_::new(f);
765            connect_raw(
766                self.as_ptr() as *mut _,
767                c"notify::layout-names".as_ptr() as *const _,
768                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
769                    notify_layout_names_trampoline::<Self, F> as *const (),
770                )),
771                Box_::into_raw(f),
772            )
773        }
774    }
775
776    #[doc(alias = "modifier-state")]
777    fn connect_modifier_state_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
778        unsafe extern "C" fn notify_modifier_state_trampoline<
779            P: IsA<Device>,
780            F: Fn(&P) + 'static,
781        >(
782            this: *mut ffi::GdkDevice,
783            _param_spec: glib::ffi::gpointer,
784            f: glib::ffi::gpointer,
785        ) {
786            unsafe {
787                let f: &F = &*(f as *const F);
788                f(Device::from_glib_borrow(this).unsafe_cast_ref())
789            }
790        }
791        unsafe {
792            let f: Box_<F> = Box_::new(f);
793            connect_raw(
794                self.as_ptr() as *mut _,
795                c"notify::modifier-state".as_ptr() as *const _,
796                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
797                    notify_modifier_state_trampoline::<Self, F> as *const (),
798                )),
799                Box_::into_raw(f),
800            )
801        }
802    }
803
804    #[doc(alias = "n-axes")]
805    fn connect_n_axes_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
806        unsafe extern "C" fn notify_n_axes_trampoline<P: IsA<Device>, F: Fn(&P) + 'static>(
807            this: *mut ffi::GdkDevice,
808            _param_spec: glib::ffi::gpointer,
809            f: glib::ffi::gpointer,
810        ) {
811            unsafe {
812                let f: &F = &*(f as *const F);
813                f(Device::from_glib_borrow(this).unsafe_cast_ref())
814            }
815        }
816        unsafe {
817            let f: Box_<F> = Box_::new(f);
818            connect_raw(
819                self.as_ptr() as *mut _,
820                c"notify::n-axes".as_ptr() as *const _,
821                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
822                    notify_n_axes_trampoline::<Self, F> as *const (),
823                )),
824                Box_::into_raw(f),
825            )
826        }
827    }
828
829    #[doc(alias = "num-lock-state")]
830    fn connect_num_lock_state_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
831        unsafe extern "C" fn notify_num_lock_state_trampoline<
832            P: IsA<Device>,
833            F: Fn(&P) + 'static,
834        >(
835            this: *mut ffi::GdkDevice,
836            _param_spec: glib::ffi::gpointer,
837            f: glib::ffi::gpointer,
838        ) {
839            unsafe {
840                let f: &F = &*(f as *const F);
841                f(Device::from_glib_borrow(this).unsafe_cast_ref())
842            }
843        }
844        unsafe {
845            let f: Box_<F> = Box_::new(f);
846            connect_raw(
847                self.as_ptr() as *mut _,
848                c"notify::num-lock-state".as_ptr() as *const _,
849                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
850                    notify_num_lock_state_trampoline::<Self, F> as *const (),
851                )),
852                Box_::into_raw(f),
853            )
854        }
855    }
856
857    #[doc(alias = "scroll-lock-state")]
858    fn connect_scroll_lock_state_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
859        unsafe extern "C" fn notify_scroll_lock_state_trampoline<
860            P: IsA<Device>,
861            F: Fn(&P) + 'static,
862        >(
863            this: *mut ffi::GdkDevice,
864            _param_spec: glib::ffi::gpointer,
865            f: glib::ffi::gpointer,
866        ) {
867            unsafe {
868                let f: &F = &*(f as *const F);
869                f(Device::from_glib_borrow(this).unsafe_cast_ref())
870            }
871        }
872        unsafe {
873            let f: Box_<F> = Box_::new(f);
874            connect_raw(
875                self.as_ptr() as *mut _,
876                c"notify::scroll-lock-state".as_ptr() as *const _,
877                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
878                    notify_scroll_lock_state_trampoline::<Self, F> as *const (),
879                )),
880                Box_::into_raw(f),
881            )
882        }
883    }
884
885    #[doc(alias = "seat")]
886    fn connect_seat_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
887        unsafe extern "C" fn notify_seat_trampoline<P: IsA<Device>, F: Fn(&P) + 'static>(
888            this: *mut ffi::GdkDevice,
889            _param_spec: glib::ffi::gpointer,
890            f: glib::ffi::gpointer,
891        ) {
892            unsafe {
893                let f: &F = &*(f as *const F);
894                f(Device::from_glib_borrow(this).unsafe_cast_ref())
895            }
896        }
897        unsafe {
898            let f: Box_<F> = Box_::new(f);
899            connect_raw(
900                self.as_ptr() as *mut _,
901                c"notify::seat".as_ptr() as *const _,
902                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
903                    notify_seat_trampoline::<Self, F> as *const (),
904                )),
905                Box_::into_raw(f),
906            )
907        }
908    }
909
910    #[doc(alias = "tool")]
911    fn connect_tool_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
912        unsafe extern "C" fn notify_tool_trampoline<P: IsA<Device>, F: Fn(&P) + 'static>(
913            this: *mut ffi::GdkDevice,
914            _param_spec: glib::ffi::gpointer,
915            f: glib::ffi::gpointer,
916        ) {
917            unsafe {
918                let f: &F = &*(f as *const F);
919                f(Device::from_glib_borrow(this).unsafe_cast_ref())
920            }
921        }
922        unsafe {
923            let f: Box_<F> = Box_::new(f);
924            connect_raw(
925                self.as_ptr() as *mut _,
926                c"notify::tool".as_ptr() as *const _,
927                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
928                    notify_tool_trampoline::<Self, F> as *const (),
929                )),
930                Box_::into_raw(f),
931            )
932        }
933    }
934}
935
936impl<O: IsA<Device>> DeviceExt for O {}