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