mirror of
https://github.com/wez/wezterm.git
synced 2024-09-20 03:09:06 +03:00
avoid ping-ponging focus updates with multiple windows
The bug here was that each paint call in a window would update the focus state of its panes to reflect the one that had focus. However, it didn't account for the actual window focus; it would just assume that it was focused. The result was that the perceived focus would alternate between each of the windows in the wezterm process, and if you were running an application that had enabled focus tracking, those events could cause a repaint and drive up the CPU utilization. This commit addresses that by gating the focus update to only occur when we have the focus, and for extra safety, avoid generating focus events at the terminal layer if the new state matches the current state. refs: https://github.com/wez/wezterm/issues/1838
This commit is contained in:
parent
a2da7efbf7
commit
d8cfdae27b
@ -719,6 +719,9 @@ impl TerminalState {
|
||||
|
||||
/// Advise the terminal about a change in its focus state
|
||||
pub fn focus_changed(&mut self, focused: bool) {
|
||||
if focused == self.focused {
|
||||
return;
|
||||
}
|
||||
if !focused {
|
||||
// notify app of release of buttons
|
||||
let buttons = self.current_mouse_buttons.clone();
|
||||
|
@ -1614,14 +1614,17 @@ impl super::TermWindow {
|
||||
|
||||
let panes = self.get_panes_to_render();
|
||||
let num_panes = panes.len();
|
||||
let focused = self.focused.is_some();
|
||||
|
||||
for pos in panes {
|
||||
if pos.is_active {
|
||||
self.update_text_cursor(&pos.pane);
|
||||
pos.pane.advise_focus();
|
||||
mux::Mux::get()
|
||||
.expect("called on mux thread")
|
||||
.record_focus_for_current_identity(pos.pane.pane_id());
|
||||
if focused {
|
||||
pos.pane.advise_focus();
|
||||
mux::Mux::get()
|
||||
.expect("called on mux thread")
|
||||
.record_focus_for_current_identity(pos.pane.pane_id());
|
||||
}
|
||||
}
|
||||
self.paint_pane_opengl(&pos, num_panes)?;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user