From 5f0e2b01da74e37e45f74e16e7815f4a88ae9918 Mon Sep 17 00:00:00 2001 From: Wez Furlong Date: Sat, 11 Jan 2020 11:48:00 -0800 Subject: [PATCH] Mux: add window invalidation concept This fixes a problem where a closed tab would linger until a subsequent input event. The issue was that the layer at which we detect the tab closure didn't have a way to signal the gui layer to repaint. This commit adds an invalidated flag to the mux window object that is updated when structural changes occur to its tabs; added, deleted, activated and so on. We check that flag in our periodic function in the gui layer and then trigger a gui level invalidation if we see that it is set. --- src/frontend/gui/termwindow.rs | 6 ++++++ src/mux/window.rs | 16 ++++++++++++++-- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/frontend/gui/termwindow.rs b/src/frontend/gui/termwindow.rs index 2287b1a64..952bca468 100644 --- a/src/frontend/gui/termwindow.rs +++ b/src/frontend/gui/termwindow.rs @@ -630,6 +630,12 @@ impl TermWindow { if !render.get_dirty_lines(visible_range).is_empty() { myself.window.as_ref().unwrap().invalidate(); } + + if let Some(mut mux_window) = mux.get_window_mut(mux_window_id) { + if mux_window.check_and_reset_invalidated() { + myself.window.as_ref().unwrap().invalidate(); + } + } } else { myself.window.as_ref().unwrap().close(); } diff --git a/src/mux/window.rs b/src/mux/window.rs index 4dc9b75f1..e62695bc4 100644 --- a/src/mux/window.rs +++ b/src/mux/window.rs @@ -11,6 +11,7 @@ pub struct Window { tabs: Vec>, active: usize, clipboard: Option>, + invalidated: bool, } impl Window { @@ -20,6 +21,7 @@ impl Window { tabs: vec![], active: 0, clipboard: None, + invalidated: false, } } @@ -46,13 +48,15 @@ impl Window { pub fn insert(&mut self, index: usize, tab: &Rc) { self.check_that_tab_isnt_already_in_window(tab); self.assign_clipboard_to_tab(tab); - self.tabs.insert(index, Rc::clone(tab)) + self.tabs.insert(index, Rc::clone(tab)); + self.invalidated = true; } pub fn push(&mut self, tab: &Rc) { self.check_that_tab_isnt_already_in_window(tab); self.assign_clipboard_to_tab(tab); - self.tabs.push(Rc::clone(tab)) + self.tabs.push(Rc::clone(tab)); + self.invalidated = true; } pub fn is_empty(&self) -> bool { @@ -77,6 +81,7 @@ impl Window { } pub fn remove_by_idx(&mut self, idx: usize) -> Rc { + self.invalidated = true; self.tabs.remove(idx) } @@ -93,6 +98,12 @@ impl Window { } } + pub fn check_and_reset_invalidated(&mut self) -> bool { + let res = self.invalidated; + self.invalidated = false; + res + } + pub fn get_active(&self) -> Option<&Rc> { self.get_by_idx(self.active) } @@ -104,6 +115,7 @@ impl Window { pub fn set_active(&mut self, idx: usize) { assert!(idx < self.tabs.len()); + self.invalidated = true; self.active = idx; }