diff options
Diffstat (limited to 'src/clients')
-rw-r--r-- | src/clients/hints.rs | 20 | ||||
-rw-r--r-- | src/clients/mod.rs | 9 |
2 files changed, 27 insertions, 2 deletions
diff --git a/src/clients/hints.rs b/src/clients/hints.rs index bd3ef76..f59794a 100644 --- a/src/clients/hints.rs +++ b/src/clients/hints.rs @@ -102,3 +102,23 @@ impl Ewm { } } } + +/// Gets the `WM_TRANSIENT_FOR` hint set on a window +pub fn transient_for(conn: &Connection, window: Window) -> Option<Window> { + let hints = conn + .wait_for_reply(conn.send_request(&GetProperty { + window, + delete: false, + property: x::ATOM_WM_TRANSIENT_FOR, + r#type: x::ATOM_WINDOW, + long_offset: 0, + long_length: 1, + })) + .ok()?; + + if hints.r#type() != x::ATOM_WINDOW || hints.length() < 1 || hints.format() != 32 { + return None; + } + + Some(hints.value::<Window>()[0]) +} diff --git a/src/clients/mod.rs b/src/clients/mod.rs index 4b5754b..fe0a4d3 100644 --- a/src/clients/mod.rs +++ b/src/clients/mod.rs @@ -173,8 +173,12 @@ impl ClientState { /// Start managing the given window, adding it to the client list and ensuring its configuration is valid. pub fn manage(&mut self, conn: &Connection<'_>, window: Window) { - // TODO: inherit from parent if window is transient - let mon = self.focused_mon(); + let mut mon = self.focused_mon(); + if let Some(parent) = hints::transient_for(conn, window) { + if let Some((parent_mon, _)) = self.find_client_pos(parent) { + mon = parent_mon; + } + } let Ok(geom) = conn.wait_for_reply(conn.send_request(&GetGeometry { drawable: Drawable::Window(window), @@ -194,6 +198,7 @@ impl ClientState { } = self.mons[mon].screen_info; let c = &mut self.mons[mon].clients[0]; + #[allow(clippy::cast_sign_loss)] c.set_geom( conn, geom.x(), |