summaryrefslogtreecommitdiff
path: root/src/clients/hints.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/clients/hints.rs')
-rw-r--r--src/clients/hints.rs21
1 files changed, 20 insertions, 1 deletions
diff --git a/src/clients/hints.rs b/src/clients/hints.rs
index f59794a..182c655 100644
--- a/src/clients/hints.rs
+++ b/src/clients/hints.rs
@@ -1,5 +1,5 @@
use xcb::{
- x::{self, ChangeProperty, GetProperty, Pixmap, PropMode, Window},
+ x::{self, Atom, ChangeProperty, GetProperty, Gravity, Pixmap, PropMode, Window},
Xid, XidNew,
};
@@ -122,3 +122,22 @@ pub fn transient_for(conn: &Connection, window: Window) -> Option<Window> {
Some(hints.value::<Window>()[0])
}
+
+/// Check if the given window is flagged as a dialog with the `NET_WM_WINDOW_TYPE` property
+pub fn is_dialog(conn: &Connection, window: Window) -> bool {
+ let Ok(hints) = conn.wait_for_reply(conn.send_request(&GetProperty {
+ window,
+ delete: false,
+ property: conn.atoms.net_wm_window_type,
+ r#type: x::ATOM_ATOM,
+ long_offset: 0,
+ long_length: 1,
+ })) else {
+ return false;
+ };
+
+ hints.r#type() == x::ATOM_ATOM
+ && hints.length() == 1
+ && hints.format() == 32
+ && hints.value::<Atom>()[0] == conn.atoms.net_wm_window_type_dialog
+}