From 016cef6f72b0bf960218b8b487915c2a8b991ba4 Mon Sep 17 00:00:00 2001 From: Shawn Wallace Date: Mon, 20 May 2024 18:51:35 -0400 Subject: [PATCH] Reset _NET_ACTIVE_WINDOW when the active window is unmapped --- src/xstate.rs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/xstate.rs b/src/xstate.rs index e909c32..45fc97b 100644 --- a/src/xstate.rs +++ b/src/xstate.rs @@ -228,6 +228,29 @@ impl XState { Ok(_) | Err(xcb::ProtocolError::X(x::Error::Window(_), _)) => {} Err(other) => panic!("Error removing event mask from window: {other:?}"), } + + let active_win = self + .connection + .wait_for_reply(self.get_property_cookie( + self.root, + self.atoms.active_win, + x::ATOM_WINDOW, + 1, + )) + .unwrap(); + + let active_win: &[x::Window] = active_win.value(); + if active_win[0] == e.window() { + self.connection + .send_and_check_request(&x::ChangeProperty { + mode: x::PropMode::Replace, + window: self.root, + property: self.atoms.active_win, + r#type: x::ATOM_WINDOW, + data: &[x::Window::none()], + }) + .unwrap(); + } } xcb::Event::X(x::Event::DestroyNotify(e)) => { debug!("destroying window {:?}", e.window());