summaryrefslogtreecommitdiff
path: root/src/clients
diff options
context:
space:
mode:
Diffstat (limited to 'src/clients')
-rw-r--r--src/clients/mod.rs26
1 files changed, 21 insertions, 5 deletions
diff --git a/src/clients/mod.rs b/src/clients/mod.rs
index 47eb094..dcce37a 100644
--- a/src/clients/mod.rs
+++ b/src/clients/mod.rs
@@ -16,7 +16,7 @@ use xcb::{
GetWindowAttributes, InputFocus, MapRequestEvent, PropMode, SetInputFocus,
UnmapNotifyEvent, Window,
},
- xinerama, Extension,
+ xinerama, BaseEvent, Extension,
};
pub use client::*;
@@ -118,10 +118,19 @@ impl WM<'_> {
/// When a window is unmapped, update its state.
pub(crate) fn handle_unmap_notify(&mut self, e: &UnmapNotifyEvent) {
- if let Some(c) = self.clients.find_client_mut(e.window()) {
- let cookie = c.set_withdrawn(&self.conn, true);
- // The above may fail if the window has already been destroyed - just discard the error here.
- let _ = self.conn.check_request(cookie);
+ if !e.is_from_send_event() {
+ if let Some(c) = self.clients.find_client_mut(e.window()) {
+ let cookie = c.set_withdrawn(&self.conn, true);
+ // The above may fail if the window has already been destroyed - just discard the error here.
+ let _ = self.conn.check_request(cookie);
+ }
+ if self
+ .clients
+ .focused()
+ .is_some_and(|c| c.window() == e.window())
+ {
+ self.clients.unfocus_destroyed();
+ }
}
}
}
@@ -263,6 +272,13 @@ impl ClientState {
old.set_border(conn, conn.colours.border_normal());
buttons::grab(conn, old.window(), false);
}
+ self.focused_client = None;
+ }
+
+ /// Unfocus the currently focused window, if it exists, without doing any of the X11 parts.
+ /// This is used when a focused window is destroyed or unmapped
+ pub fn unfocus_destroyed(&mut self) {
+ self.focused_client = None;
}
/// Go to the next or previous window in the current monitor, looping around if needed