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