summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/desktop.rs11
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
};