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