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.rs24
1 files changed, 14 insertions, 10 deletions
diff --git a/src/clients/mod.rs b/src/clients/mod.rs
index 597a336..04355fd 100644
--- a/src/clients/mod.rs
+++ b/src/clients/mod.rs
@@ -1,6 +1,6 @@
//! Tracking and managing windows.
-use std::cmp::min;
+use std::cmp::{min, Ordering};
use crate::{
config::BORDER_WIDTH,
@@ -360,17 +360,21 @@ impl ClientState {
/// Set the new amount of screens, without unmanaging any clients.
fn truncate_screens(&mut self, new_size: usize) {
- // hack: working around double borrow stuff
- if new_size < self.mons.len() {
- let mut moved_clients = vec![];
- for old in self.mons.drain(new_size - self.mons.len()..self.mons.len()) {
- moved_clients.extend(old.clients.into_iter());
+ // HACK: working around double borrow stuff
+ match new_size.cmp(&self.mons.len()) {
+ Ordering::Greater => {
+ for _ in 0..new_size - self.mons.len() {
+ self.mons.push(MonitorInfo::default());
+ }
}
- self.mons[0].clients.extend(moved_clients);
- } else if new_size > self.mons.len() {
- for _ in 0..new_size - self.mons.len() {
- self.mons.push(MonitorInfo::default());
+ Ordering::Less => {
+ let mut moved_clients = vec![];
+ for old in self.mons.drain(new_size - self.mons.len()..self.mons.len()) {
+ moved_clients.extend(old.clients.into_iter());
+ }
+ self.mons[0].clients.extend(moved_clients);
}
+ Ordering::Equal => (),
}
}