summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortcmal <me@aria.rip>2024-08-25 21:10:02 +0100
committertcmal <me@aria.rip>2024-08-26 15:50:17 +0100
commitac4eee711e313c1dbcdd3fdf7fb13c3ad360eabd (patch)
treefd6edc3ad3bfef4da9750ac9d1621d72c72e3feb
parent19829472eef038c189637d50f4406e54bfe8460e (diff)
Deal with focused window being destroyed better
-rw-r--r--src/clients/mod.rs13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/clients/mod.rs b/src/clients/mod.rs
index 750a30a..c42a385 100644
--- a/src/clients/mod.rs
+++ b/src/clients/mod.rs
@@ -222,12 +222,19 @@ impl ClientState {
self.clients.remove(i);
- self.focused_client = self.focused_client.filter(|f| *f < self.clients.len());
+ self.focused_client = self.focused_client.and_then(|f| match f.cmp(&i) {
+ Ordering::Less => Some(f),
+ Ordering::Greater => Some(f - 1),
+ Ordering::Equal => None,
+ });
if self.focused_client.is_none() {
- self.focused_client = self
+ if let Some(i) = self
.clients
.iter()
- .position(|c| focused_mon.contains(c.x(), c.y()));
+ .position(|c| focused_mon.contains(c.x(), c.y()))
+ {
+ self.refocus(conn, i);
+ }
}
self.rearrange(conn);