gdk/
event_touchpad_swipe.rs

1// Copyright 2018, The Gtk-rs Project Developers.
2// See the COPYRIGHT file at the top-level directory of this distribution.
3// Licensed under the MIT license, see the LICENSE file or <http://opensource.org/licenses/MIT>
4
5use gdk_sys;
6use glib::translate::*;
7
8#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
9pub struct EventTouchpadSwipe(::Event);
10
11event_wrapper!(EventTouchpadSwipe, GdkEventTouchpadSwipe);
12event_subtype!(EventTouchpadSwipe, gdk_sys::GDK_TOUCHPAD_SWIPE);
13
14impl EventTouchpadSwipe {
15    pub fn is_phase(&self) -> bool {
16        from_glib(self.as_ref().phase as _)
17    }
18
19    pub fn get_n_fingers(&self) -> i8 {
20        self.as_ref().n_fingers
21    }
22
23    pub fn get_time(&self) -> u32 {
24        self.as_ref().time
25    }
26
27    pub fn get_position(&self) -> (f64, f64) {
28        let x = self.as_ref().x;
29        let y = self.as_ref().y;
30        (x, y)
31    }
32
33    pub fn get_delta(&self) -> (f64, f64) {
34        let dx = self.as_ref().dx;
35        let dy = self.as_ref().dy;
36        (dx, dy)
37    }
38
39    pub fn get_root(&self) -> (f64, f64) {
40        let x_root = self.as_ref().x_root;
41        let y_root = self.as_ref().y_root;
42        (x_root, y_root)
43    }
44
45    pub fn get_state(&self) -> ::ModifierType {
46        from_glib(self.as_ref().state)
47    }
48}