1use gdk_sys;
6use glib::translate::*;
7
8#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
9pub struct EventTouch(::Event);
10
11event_wrapper!(EventTouch, GdkEventTouch);
12event_subtype!(
13 EventTouch,
14 gdk_sys::GDK_TOUCH_BEGIN
15 | gdk_sys::GDK_TOUCH_UPDATE
16 | gdk_sys::GDK_TOUCH_END
17 | gdk_sys::GDK_TOUCH_CANCEL
18);
19
20impl EventTouch {
21 pub fn get_time(&self) -> u32 {
22 self.as_ref().time
23 }
24
25 pub fn get_position(&self) -> (f64, f64) {
26 let x = self.as_ref().x;
27 let y = self.as_ref().y;
28 (x, y)
29 }
30
31 pub fn get_state(&self) -> ::ModifierType {
32 from_glib(self.as_ref().state)
33 }
34
35 pub fn is_emulating_pointer(&self) -> bool {
36 from_glib(self.as_ref().emulating_pointer)
37 }
38
39 pub fn get_device(&self) -> Option<::Device> {
40 unsafe { from_glib_none(self.as_ref().device) }
41 }
42
43 pub fn get_axes(&self) -> Option<(f64, f64)> {
44 let axes = self.as_ref().axes;
45
46 if axes.is_null() {
47 None
48 } else {
49 unsafe { Some((*axes, *axes.offset(1))) }
50 }
51 }
52
53 pub fn get_root(&self) -> (f64, f64) {
54 let x_root = self.as_ref().x_root;
55 let y_root = self.as_ref().y_root;
56 (x_root, y_root)
57 }
58
59 pub fn get_event_sequence(&self) -> Option<::EventSequence> {
60 unsafe { from_glib_none(self.as_ref().sequence) }
61 }
62}