1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files.git)
// DO NOT EDIT

use crate::Event;
use crate::TouchpadGesturePhase;
use glib::translate::*;
use glib::StaticType;
use std::fmt;
use std::mem;

glib::wrapper! {
    /// An event related to a gesture on a touchpad device.
    ///
    /// Unlike touchscreens, where the windowing system sends basic
    /// sequences of begin, update, end events, and leaves gesture
    /// recognition to the clients, touchpad gestures are typically
    /// processed by the system, resulting in these events.
    #[doc(alias = "GdkTouchpadEvent")]
    pub struct TouchpadEvent(Shared<ffi::GdkTouchpadEvent>);

    match fn {
        ref => |ptr| ffi::gdk_event_ref(ptr as *mut ffi::GdkEvent),
        unref => |ptr| ffi::gdk_event_unref(ptr as *mut ffi::GdkEvent),
    }
}

impl glib::StaticType for TouchpadEvent {
    fn static_type() -> glib::Type {
        unsafe { from_glib(ffi::gdk_touchpad_event_get_type()) }
    }
}

impl TouchpadEvent {
    /// Extracts delta information from a touchpad event.
    ///
    /// # Returns
    ///
    ///
    /// ## `dx`
    /// return location for x
    ///
    /// ## `dy`
    /// return location for y
    #[doc(alias = "gdk_touchpad_event_get_deltas")]
    #[doc(alias = "get_deltas")]
    pub fn deltas(&self) -> (f64, f64) {
        unsafe {
            let mut dx = mem::MaybeUninit::uninit();
            let mut dy = mem::MaybeUninit::uninit();
            ffi::gdk_touchpad_event_get_deltas(
                self.to_glib_none().0,
                dx.as_mut_ptr(),
                dy.as_mut_ptr(),
            );
            (dx.assume_init(), dy.assume_init())
        }
    }

    /// Extracts the touchpad gesture phase from a touchpad event.
    ///
    /// # Returns
    ///
    /// the gesture phase of @self
    #[doc(alias = "gdk_touchpad_event_get_gesture_phase")]
    #[doc(alias = "get_gesture_phase")]
    pub fn gesture_phase(&self) -> TouchpadGesturePhase {
        unsafe {
            from_glib(ffi::gdk_touchpad_event_get_gesture_phase(
                self.to_glib_none().0,
            ))
        }
    }

    /// Extracts the number of fingers from a touchpad event.
    ///
    /// # Returns
    ///
    /// the number of fingers for @self
    #[doc(alias = "gdk_touchpad_event_get_n_fingers")]
    #[doc(alias = "get_n_fingers")]
    pub fn n_fingers(&self) -> u32 {
        unsafe { ffi::gdk_touchpad_event_get_n_fingers(self.to_glib_none().0) }
    }

    /// Extracts the angle delta from a touchpad pinch event.
    ///
    /// # Returns
    ///
    /// the angle delta of @self
    #[doc(alias = "gdk_touchpad_event_get_pinch_angle_delta")]
    #[doc(alias = "get_pinch_angle_delta")]
    pub fn pinch_angle_delta(&self) -> f64 {
        unsafe { ffi::gdk_touchpad_event_get_pinch_angle_delta(self.to_glib_none().0) }
    }

    /// Extracts the scale from a touchpad pinch event.
    ///
    /// # Returns
    ///
    /// the scale of @self
    #[doc(alias = "gdk_touchpad_event_get_pinch_scale")]
    #[doc(alias = "get_pinch_scale")]
    pub fn pinch_scale(&self) -> f64 {
        unsafe { ffi::gdk_touchpad_event_get_pinch_scale(self.to_glib_none().0) }
    }
}

impl fmt::Display for TouchpadEvent {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        f.write_str("TouchpadEvent")
    }
}