diff options
author | tcmal <me@aria.rip> | 2024-07-05 15:34:03 +0100 |
---|---|---|
committer | tcmal <me@aria.rip> | 2024-07-15 15:29:53 +0100 |
commit | 6d586c8156c20b3dbf7e10e4dae5e14fd34618a5 (patch) | |
tree | ea1a757f4cb844ee079655ac09d0e4a8c3b78b8d /src/clients/hints.rs | |
parent | 51567ba6c3e41a51a73b439c31c836eb39850fed (diff) |
Set dialog windows to floating when first
Diffstat (limited to 'src/clients/hints.rs')
-rw-r--r-- | src/clients/hints.rs | 21 |
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 +} |