diff options
author | Matias Linares <matiaslina@openmailbox.org> | 2016-06-04 16:33:19 -0300 |
---|---|---|
committer | Matias Linares <matiaslina@openmailbox.org> | 2016-06-04 16:33:19 -0300 |
commit | 2937bd454b52886927a80c90ab83389ea04f85ea (patch) | |
tree | 2576c8249b1db670c93b108f38ac04142d43b5bf /src/desktop.rs | |
parent | 379f60f20a5105f55a348b56a77504af101473e7 (diff) | |
download | dotwm-2937bd454b52886927a80c90ab83389ea04f85ea.tar.gz |
Fix unfocused window bug.
Diffstat (limited to 'src/desktop.rs')
-rw-r--r-- | src/desktop.rs | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/desktop.rs b/src/desktop.rs index aac472f..454c05b 100644 --- a/src/desktop.rs +++ b/src/desktop.rs @@ -62,16 +62,23 @@ impl Desktop { self.window_list.push(w); // Last windows get focus. self.focus_current_window(); + } else { + println!("XWindow::new responded None"); } } - /// Remove a window. + /// Remove a window focusing the previous one on the list. pub fn remove_window(&mut self, w: xlib::Window) { + // Get the position of this window. let pos = self.window_list.iter().position(|xw| xw.inner == w); + // Only remove it if we found the position of the window. if let Some(idx) = pos { + // Get the index of the previous window. Keep it in 0 if it's the + // first window. + // NOTE: maybe we should do something if the window_list.len() is 1 let new_idx = if idx == 0 { - if self.window_list.len() == 1 { usize::max_value() } else { 0 } + 0 } else { idx - 1 }; |