From 9d751ec06312d0e98a9336f1539da59dec457146 Mon Sep 17 00:00:00 2001 From: bbb651 Date: Fri, 21 Mar 2025 20:38:58 +0200 Subject: [PATCH] Fix black screen on minimize Thanks @UjinT34 for the hint Fixes #54. --- src/xstate/mod.rs | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/src/xstate/mod.rs b/src/xstate/mod.rs index 13143d1..2b3ce91 100644 --- a/src/xstate/mod.rs +++ b/src/xstate/mod.rs @@ -741,6 +741,7 @@ xcb::atoms_struct! { wm_protocols => b"WM_PROTOCOLS" only_if_exists = false, wm_delete_window => b"WM_DELETE_WINDOW" only_if_exists = false, wm_transient_for => b"WM_TRANSIENT_FOR" only_if_exists = false, + wm_state => b"WM_STATE" only_if_exists = false, wm_check => b"_NET_SUPPORTING_WM_CHECK" only_if_exists = false, net_wm_name => b"_NET_WM_NAME" only_if_exists = false, wm_pid => b"_NET_WM_PID" only_if_exists = false, @@ -867,6 +868,25 @@ impl TryFrom for SetState { } } +#[derive(Debug, Clone, Copy)] +pub enum WmState { + Withdrawn = 0, + Normal = 1, + Iconic = 3, +} + +impl TryFrom for WmState { + type Error = (); + fn try_from(value: u32) -> Result { + match value { + 0 => Ok(Self::Withdrawn), + 1 => Ok(Self::Normal), + 3 => Ok(Self::Iconic), + _ => Err(()), + } + } +} + pub struct RealConnection { atoms: Atoms, connection: Rc, @@ -985,6 +1005,15 @@ impl XConnection for RealConnection { }) { debug!("ChangeProperty failed ({:?}: {:?})", window, e); } + if let Err(e) = self.connection.send_and_check_request(&x::ChangeProperty { + mode: x::PropMode::Replace, + window, + property: self.atoms.wm_state, + r#type: self.atoms.wm_state, + data: &[WmState::Normal as u32, 0], + }) { + debug!("ChangeProperty failed ({:?}: {:?})", window, e); + } if let Some(name) = output_name { let Some(output) = self.outputs.get(&name).copied() else {