From 8931afba5cee07ab12990f06c2ff34d6f8426b19 Mon Sep 17 00:00:00 2001 From: Wez Furlong Date: Sat, 29 May 2021 09:36:30 -0700 Subject: [PATCH] fix more laggy invalidations in the same vein as d6577211639fc6218bce4e35cac3394f72b641bc, the increased idle loop means we need to be careful not to suppress invalidation events. In this case, overlays aren't from the window in the mux model, so we'd ignore invalidations for those. While looking at this I realized that we'd also do the same for output being emitted in panes that were not the active pane, so tidy that up. --- wezterm-gui/src/termwindow/mod.rs | 45 ++++++++++++++++++------------- 1 file changed, 26 insertions(+), 19 deletions(-) diff --git a/wezterm-gui/src/termwindow/mod.rs b/wezterm-gui/src/termwindow/mod.rs index b0609d235..a09743c24 100644 --- a/wezterm-gui/src/termwindow/mod.rs +++ b/wezterm-gui/src/termwindow/mod.rs @@ -805,12 +805,25 @@ impl TermWindow { } } + fn is_pane_visible(&mut self, pane_id: PaneId) -> bool { + let mux = Mux::get().unwrap(); + let tab = match mux.get_active_tab_for_window(self.mux_window_id) { + Some(tab) => tab, + None => return false, + }; + + let tab_id = tab.tab_id(); + if let Some(tab_overlay) = self.tab_state(tab_id).overlay.clone() { + return tab_overlay.pane_id() == pane_id; + } + + tab.contains_pane(pane_id) + } + fn mux_pane_output_event(&mut self, pane_id: PaneId) { - if let Some(pane) = self.get_active_pane_or_overlay() { - if pane.pane_id() == pane_id { - if let Some(ref win) = self.window { - win.invalidate(); - } + if self.is_pane_visible(pane_id) { + if let Some(ref win) = self.window { + win.invalidate(); } } } @@ -832,24 +845,18 @@ impl TermWindow { alert: Alert::TitleMaybeChanged, } | MuxNotification::PaneOutput(pane_id) => { - let mut pane_in_window = false; - + // Ideally we'd check to see if pane_id is part of this window, + // but overlays may not be 100% associated with the window + // in the mux and we don't want to lose the invalidation + // signal for that case, so we just check window validity + // here and propagate to the window event handler that + // will then do the check with full context. let mux = Mux::get().expect("mux is calling us"); - if let Some(mux_window) = mux.get_window(mux_window_id) { - for tab in mux_window.iter() { - if tab.contains_pane(pane_id) { - pane_in_window = true; - break; - } - } - } else { + if mux.get_window(mux_window_id).is_none() { // Something inconsistent: cancel subscription return false; } - - if !pane_in_window { - return true; - } + let _ = pane_id; } MuxNotification::WindowInvalidated(window_id) => { if window_id != mux_window_id {