diff --git a/docs/changelog.md b/docs/changelog.md index 84bd8448f..888d761db 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -175,6 +175,8 @@ As features stabilize some brief notes about them will accumulate here. accounts for window padding. Thanks to @jknockel! #4824 * Bar shaped text cursors are now rendered above text. Thanks to @ErrorNoInternet! #4850 +* `format-tab-title` event was triggered excessively for background tabs/panes. + Thanks to @crides for investigating! #4788 #### Updated * Bundled harfbuzz to 8.3.0 diff --git a/term/src/terminalstate/mod.rs b/term/src/terminalstate/mod.rs index f18ad0b6b..c85c10424 100644 --- a/term/src/terminalstate/mod.rs +++ b/term/src/terminalstate/mod.rs @@ -378,7 +378,10 @@ pub struct TerminalState { accumulating_title: Option, + /// seqno when we last lost focus lost_focus_seqno: SequenceNo, + /// seqno when we last emitted Alert::OutputSinceFocusLost + lost_focus_alerted_seqno: SequenceNo, focused: bool, /// True if lines should be marked as bidi-enabled, and thus @@ -575,6 +578,7 @@ impl TerminalState { enable_conpty_quirks: false, accumulating_title: None, lost_focus_seqno: seqno, + lost_focus_alerted_seqno: seqno, focused: true, bidi_enabled: None, bidi_hint: None, @@ -795,8 +799,15 @@ impl TerminalState { pub(crate) fn trigger_unseen_output_notif(&mut self) { if self.has_unseen_output() { - if let Some(handler) = self.alert_handler.as_mut() { - handler.alert(Alert::OutputSinceFocusLost); + // We want to avoid over-notifying about output events, + // so here we gate the notification to the case where + // we have lost the focus more recently than the last + // time we notified about it + if self.lost_focus_seqno > self.lost_focus_alerted_seqno { + self.lost_focus_alerted_seqno = self.seqno; + if let Some(handler) = self.alert_handler.as_mut() { + handler.alert(Alert::OutputSinceFocusLost); + } } } } diff --git a/wezterm-gui/src/termwindow/mod.rs b/wezterm-gui/src/termwindow/mod.rs index fbb2431d8..d04aa7109 100644 --- a/wezterm-gui/src/termwindow/mod.rs +++ b/wezterm-gui/src/termwindow/mod.rs @@ -1228,7 +1228,8 @@ impl TermWindow { // Handled by frontend } MuxNotification::PaneFocused(_) => { - // Handled by clientpane + // Also handled by clientpane + self.update_title_post_status(); } MuxNotification::TabResized(_) => { // Handled by wezterm-client diff --git a/wezterm-gui/src/termwindow/render/paint.rs b/wezterm-gui/src/termwindow/render/paint.rs index f3a161e3e..a33f8d352 100644 --- a/wezterm-gui/src/termwindow/render/paint.rs +++ b/wezterm-gui/src/termwindow/render/paint.rs @@ -114,7 +114,6 @@ impl crate::TermWindow { ); metrics::histogram!("gui.paint.impl", self.last_frame_duration); metrics::histogram!("gui.paint.impl.rate", 1.); - self.update_title_post_status(); // If self.has_animation is some, then the last render detected // image attachments with multiple frames, so we also need to