diff options
Diffstat (limited to 'src/clients')
-rw-r--r-- | src/clients/client.rs | 7 | ||||
-rw-r--r-- | src/clients/hints.rs | 21 | ||||
-rw-r--r-- | src/clients/mod.rs | 4 |
3 files changed, 27 insertions, 5 deletions
diff --git a/src/clients/client.rs b/src/clients/client.rs index 84f787a..c9fa645 100644 --- a/src/clients/client.rs +++ b/src/clients/client.rs @@ -215,9 +215,10 @@ impl Client { }) } - pub fn update_window_type(&mut self, conn: &Connection<'_>) { - // TODO: Fullscreen from net_wm_state - if hints::is_dialog(conn, self.window) { + pub fn update_window_type(&mut self, conn: &Connection<'_>, mon_geom: &MonitorGeometry) { + if hints::is_fullscreen(conn, self.window) { + self.set_fullscreen(conn, mon_geom); + } else if hints::is_dialog(conn, self.window) { self.set_floating(conn); } } diff --git a/src/clients/hints.rs b/src/clients/hints.rs index fdfbead..39003d2 100644 --- a/src/clients/hints.rs +++ b/src/clients/hints.rs @@ -235,3 +235,24 @@ pub fn is_dialog(conn: &Connection, window: Window) -> bool { && hints.format() == 32 && hints.value::<Atom>()[0] == conn.atoms.net_wm_window_type_dialog } + +/// Check if the given window wants to be fullscreen, using the `NET_WM_STATE` property +pub fn is_fullscreen(conn: &Connection, window: Window) -> bool { + let Ok(hints) = conn.wait_for_reply(conn.send_request(&GetProperty { + window, + delete: false, + property: conn.atoms.net_wm_state, + r#type: x::ATOM_ATOM, + long_offset: 0, + long_length: 9999, + })) else { + return false; + }; + + hints.r#type() == x::ATOM_ATOM + && hints.format() == 32 + && hints + .value::<Atom>() + .iter() + .any(|a| *a == conn.atoms.net_wm_fullscreen) +} diff --git a/src/clients/mod.rs b/src/clients/mod.rs index c370e04..37a88c0 100644 --- a/src/clients/mod.rs +++ b/src/clients/mod.rs @@ -193,7 +193,7 @@ impl ClientState { // TODO: inserting at index 0 is why dwm uses linked lists, maybe this can be improved self.mons[mon].clients.insert(0, Client::new(window)); - let MonitorGeometry { + let mon_geom @ MonitorGeometry { width: mon_width, height: mon_height, .. @@ -213,7 +213,7 @@ impl ClientState { if floating { c.set_floating(conn); } - c.update_window_type(conn); + c.update_window_type(conn, &mon_geom); c.ensure_mapped(conn); c.sync_properties(conn, true); |