fix more laggy invalidations

in the same vein as d657721163, 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.
This commit is contained in:
Wez Furlong committed 2021-05-29 09:36:30 -07:00
1 parent de4ba46731
commit 8931afba5c
1 file changed
+26 -19
+26 -19
View File
@@ -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 {