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