Skip to content

Commit

Permalink
Restrict bell events to the proper window. (#6012)
Browse files Browse the repository at this point in the history
* Restrict bell events to the proper window.

As per the comment in mod.rs, bell events are sent to
all windows; not just the window containing the pane
which generated the event.

To prevent each bell ringing multiple times, the window
event handler must check if it has the pane, and ignore
the bell event if it doesn't.

This fixes bug #5985

Co-authored-by: Sean Estabrooks <sean.estabrooks@eztux.com>
  • Loading branch information
loops and loops authored Sep 14, 2024
1 parent 2bb1e75 commit e538799
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions wezterm-gui/src/termwindow/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1223,6 +1223,10 @@ impl TermWindow {
alert: Alert::Bell,
pane_id,
} => {
if !self.window_contains_pane(pane_id) {
return Ok(());
}

match self.config.audible_bell {
AudibleBell::SystemBeep => {
Connection::get().expect("on main thread").beep();
Expand Down Expand Up @@ -1878,20 +1882,23 @@ impl TermWindow {
self.update_title_impl();
}

fn emit_user_var_event(&mut self, pane_id: PaneId, name: String, value: String) {
fn window_contains_pane(&mut self, pane_id: PaneId) -> bool {
let mux = Mux::get();

let (_domain, window_id, _tab_id) = match mux.resolve_pane_id(pane_id) {
Some(tuple) => tuple,
None => return,
None => return false,
};

// We only want to emit the event for the window which contains
// this pane.
if window_id != self.mux_window_id {
return window_id == self.mux_window_id;
}

fn emit_user_var_event(&mut self, pane_id: PaneId, name: String, value: String) {
if !self.window_contains_pane(pane_id) {
return;
}

let mux = Mux::get();
let window = GuiWin::new(self);
let pane = match mux.get_pane(pane_id) {
Some(pane) => mux_lua::MuxPane(pane.pane_id()),
Expand Down

0 comments on commit e538799

Please sign in to comment.