1use crate::ffi;
4use glib::translate::*;
5
6#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
17pub struct EventTouch(crate::Event);
18
19event_wrapper!(EventTouch, GdkEventTouch);
20event_subtype!(
21 EventTouch,
22 ffi::GDK_TOUCH_BEGIN | ffi::GDK_TOUCH_UPDATE | ffi::GDK_TOUCH_END | ffi::GDK_TOUCH_CANCEL
23);
24
25impl EventTouch {
26 #[doc(alias = "get_time")]
27 pub fn time(&self) -> u32 {
28 self.as_ref().time
29 }
30
31 #[doc(alias = "get_position")]
32 pub fn position(&self) -> (f64, f64) {
33 let x = self.as_ref().x;
34 let y = self.as_ref().y;
35 (x, y)
36 }
37
38 #[doc(alias = "get_state")]
39 pub fn state(&self) -> crate::ModifierType {
40 unsafe { from_glib(self.as_ref().state) }
41 }
42
43 pub fn is_emulating_pointer(&self) -> bool {
44 unsafe { from_glib(self.as_ref().emulating_pointer) }
45 }
46
47 #[doc(alias = "get_device")]
48 pub fn device(&self) -> Option<crate::Device> {
49 unsafe { from_glib_none(self.as_ref().device) }
50 }
51
52 #[doc(alias = "get_axes")]
53 pub fn axes(&self) -> Option<(f64, f64)> {
54 let axes = self.as_ref().axes;
55
56 if axes.is_null() {
57 None
58 } else {
59 unsafe { Some((*axes, *axes.offset(1))) }
60 }
61 }
62
63 #[doc(alias = "get_root")]
64 pub fn root(&self) -> (f64, f64) {
65 let x_root = self.as_ref().x_root;
66 let y_root = self.as_ref().y_root;
67 (x_root, y_root)
68 }
69
70 #[doc(alias = "get_event_sequence")]
71 pub fn event_sequence(&self) -> Option<crate::EventSequence> {
72 unsafe { from_glib_none(self.as_ref().sequence) }
73 }
74}