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