summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortcmal <me@aria.rip>2024-07-15 19:25:03 +0100
committertcmal <me@aria.rip>2024-07-15 20:29:54 +0100
commit4f97eac4f9983c8cfa6ee506a3a20b0abb33f2a3 (patch)
tree25110fdf536653d4b3a020461687286ebfb4aad7
parent1a87db1097d9d594c28963c66c627f3c66bcf6de (diff)
Fix crash when run with multiple monitors
-rw-r--r--src/clients/mod.rs14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/clients/mod.rs b/src/clients/mod.rs
index 37a88c0..053b4de 100644
--- a/src/clients/mod.rs
+++ b/src/clients/mod.rs
@@ -359,11 +359,17 @@ 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
- 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());
+ 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());
+ }
+ 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());
+ }
}
- self.mons[0].clients.extend(moved_clients);
}
/// Set the given screen's geometry, resizing the monitor list if necessary.