1use crate::ffi;
4use glib::translate::*;
5
6#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
8pub struct EventCrossing(crate::Event);
9
10event_wrapper!(EventCrossing, GdkEventCrossing);
11event_subtype!(EventCrossing, ffi::GDK_ENTER_NOTIFY | ffi::GDK_LEAVE_NOTIFY);
12
13impl EventCrossing {
14 #[doc(alias = "get_position")]
15 pub fn position(&self) -> (f64, f64) {
16 let x = self.as_ref().x;
17 let y = self.as_ref().y;
18 (x, y)
19 }
20
21 #[doc(alias = "get_subwindow")]
22 pub fn subwindow(&self) -> Option<crate::Window> {
23 unsafe { from_glib_none(self.as_ref().subwindow) }
24 }
25
26 #[doc(alias = "get_mode")]
27 pub fn mode(&self) -> crate::CrossingMode {
28 unsafe { from_glib(self.as_ref().mode) }
29 }
30
31 #[doc(alias = "get_detail")]
32 pub fn detail(&self) -> crate::NotifyType {
33 unsafe { from_glib(self.as_ref().detail) }
34 }
35
36 #[doc(alias = "get_state")]
37 pub fn state(&self) -> crate::ModifierType {
38 unsafe { from_glib(self.as_ref().state) }
39 }
40
41 #[doc(alias = "get_time")]
42 pub fn time(&self) -> u32 {
43 self.as_ref().time
44 }
45
46 #[doc(alias = "get_root")]
47 pub fn 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 #[doc(alias = "get_focus")]
54 pub fn gets_focus(&self) -> bool {
55 unsafe { from_glib(self.as_ref().focus) }
56 }
57}