summaryrefslogtreecommitdiff
path: root/src/clients/mod.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/clients/mod.rs')
-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);