gdk4/auto/
touchpad_event.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, TouchpadGesturePhase};
6use glib::{prelude::*, translate::*};
7
8glib::wrapper! {
9    /// An event related to a gesture on a touchpad device.
10    ///
11    /// Unlike touchscreens, where the windowing system sends basic
12    /// sequences of begin, update, end events, and leaves gesture
13    /// recognition to the clients, touchpad gestures are typically
14    /// processed by the system, resulting in these events.
15    #[doc(alias = "GdkTouchpadEvent")]
16    pub struct TouchpadEvent(Shared<ffi::GdkTouchpadEvent>);
17
18    match fn {
19        ref => |ptr| ffi::gdk_event_ref(ptr as *mut ffi::GdkEvent),
20        unref => |ptr| ffi::gdk_event_unref(ptr as *mut ffi::GdkEvent),
21    }
22}
23
24impl StaticType for TouchpadEvent {
25    fn static_type() -> glib::Type {
26        unsafe { from_glib(ffi::gdk_touchpad_event_get_type()) }
27    }
28}
29
30impl TouchpadEvent {
31    /// Extracts delta information from a touchpad event.
32    ///
33    /// # Returns
34    ///
35    ///
36    /// ## `dx`
37    /// return location for x
38    ///
39    /// ## `dy`
40    /// return location for y
41    #[doc(alias = "gdk_touchpad_event_get_deltas")]
42    #[doc(alias = "get_deltas")]
43    pub fn deltas(&self) -> (f64, f64) {
44        unsafe {
45            let mut dx = std::mem::MaybeUninit::uninit();
46            let mut dy = std::mem::MaybeUninit::uninit();
47            ffi::gdk_touchpad_event_get_deltas(
48                self.to_glib_none().0,
49                dx.as_mut_ptr(),
50                dy.as_mut_ptr(),
51            );
52            (dx.assume_init(), dy.assume_init())
53        }
54    }
55
56    /// Extracts the touchpad gesture phase from a touchpad event.
57    ///
58    /// # Returns
59    ///
60    /// the gesture phase of @self
61    #[doc(alias = "gdk_touchpad_event_get_gesture_phase")]
62    #[doc(alias = "get_gesture_phase")]
63    pub fn gesture_phase(&self) -> TouchpadGesturePhase {
64        unsafe {
65            from_glib(ffi::gdk_touchpad_event_get_gesture_phase(
66                self.to_glib_none().0,
67            ))
68        }
69    }
70
71    /// Extracts the number of fingers from a touchpad event.
72    ///
73    /// # Returns
74    ///
75    /// the number of fingers for @self
76    #[doc(alias = "gdk_touchpad_event_get_n_fingers")]
77    #[doc(alias = "get_n_fingers")]
78    pub fn n_fingers(&self) -> u32 {
79        unsafe { ffi::gdk_touchpad_event_get_n_fingers(self.to_glib_none().0) }
80    }
81
82    /// Extracts the angle delta from a touchpad pinch event.
83    ///
84    /// # Returns
85    ///
86    /// the angle delta of @self
87    #[doc(alias = "gdk_touchpad_event_get_pinch_angle_delta")]
88    #[doc(alias = "get_pinch_angle_delta")]
89    pub fn pinch_angle_delta(&self) -> f64 {
90        unsafe { ffi::gdk_touchpad_event_get_pinch_angle_delta(self.to_glib_none().0) }
91    }
92
93    /// Extracts the scale from a touchpad pinch event.
94    ///
95    /// # Returns
96    ///
97    /// the scale of @self
98    #[doc(alias = "gdk_touchpad_event_get_pinch_scale")]
99    #[doc(alias = "get_pinch_scale")]
100    pub fn pinch_scale(&self) -> f64 {
101        unsafe { ffi::gdk_touchpad_event_get_pinch_scale(self.to_glib_none().0) }
102    }
103}