gdk/event_grab_broken.rs
1// Take a look at the license at the top of the repository in the LICENSE file.
2
3use glib::translate::*;
4
5/// Generated when a pointer or keyboard grab is broken. On X11, this happens
6/// when the grab window becomes unviewable (i.e. it or one of its ancestors
7/// is unmapped), or if the same application grabs the pointer or keyboard
8/// again. Note that implicit grabs (which are initiated by button presses)
9/// can also cause [`EventGrabBroken`][crate::EventGrabBroken] events.
10#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
11pub struct EventGrabBroken(crate::Event);
12
13event_wrapper!(EventGrabBroken, GdkEventGrabBroken);
14event_subtype!(EventGrabBroken, ffi::GDK_GRAB_BROKEN);
15
16impl EventGrabBroken {
17 pub fn is_keyboard(&self) -> bool {
18 unsafe { from_glib(self.as_ref().keyboard) }
19 }
20
21 pub fn is_implicit(&self) -> bool {
22 unsafe { from_glib(self.as_ref().implicit) }
23 }
24
25 #[doc(alias = "get_grab_window")]
26 pub fn grab_window(&self) -> Option<crate::Window> {
27 unsafe { from_glib_none(self.as_ref().grab_window) }
28 }
29}