aboutsummaryrefslogtreecommitdiffstats
path: root/zellij-server/src
diff options
context:
space:
mode:
authorAram Drevekenin <aram@poor.dev>2026-05-12 13:07:30 +0200
committerGitHub <noreply@github.com>2026-05-12 13:07:30 +0200
commit42496fa3248398b555f6d20a59e863a46d46f68d (patch)
tree2cedd47373a1fd6242703f48b12bcbcda55a74ec /zellij-server/src
parentWelcome screen del fix (#5160) (diff)
downloadsl0ppij-42496fa3248398b555f6d20a59e863a46d46f68d.tar.gz
sl0ppij-42496fa3248398b555f6d20a59e863a46d46f68d.tar.xz
sl0ppij-42496fa3248398b555f6d20a59e863a46d46f68d.zip
fix: clear bell when focusing with mouse (#5161)
* fix: clear bell when focusing with mouse * add pr
Diffstat (limited to 'zellij-server/src')
-rw-r--r--zellij-server/src/screen.rs13
-rw-r--r--zellij-server/src/unit/screen_tests.rs59
2 files changed, 72 insertions, 0 deletions
diff --git a/zellij-server/src/screen.rs b/zellij-server/src/screen.rs
index ea2ca4a3..9a648f0d 100644
--- a/zellij-server/src/screen.rs
+++ b/zellij-server/src/screen.rs
@@ -4908,6 +4908,10 @@ impl Screen {
&& !event.middle
&& !event.wheel_up
&& !event.wheel_down;
+ let active_pane_id_before = self
+ .get_active_tab(client_id)
+ .ok()
+ .and_then(|tab| tab.get_active_pane_id(client_id));
match self
.get_active_tab_mut(client_id)
.and_then(|tab| tab.handle_mouse_event(&event, client_id))
@@ -4936,6 +4940,15 @@ impl Screen {
if !is_bare_motion {
let _ = self.log_and_report_session_state();
}
+ let active_pane_id_after = self
+ .get_active_tab(client_id)
+ .ok()
+ .and_then(|tab| tab.get_active_pane_id(client_id));
+ if active_pane_id_before.is_some()
+ && active_pane_id_before != active_pane_id_after
+ {
+ self.clear_bell_for_focused_pane(client_id);
+ }
should_render = true;
}
if !mouse_effect.leave_clipboard_message && !is_bare_motion {
diff --git a/zellij-server/src/unit/screen_tests.rs b/zellij-server/src/unit/screen_tests.rs
index 3d2efa8a..18837be6 100644
--- a/zellij-server/src/unit/screen_tests.rs
+++ b/zellij-server/src/unit/screen_tests.rs
@@ -1974,6 +1974,65 @@ fn group_panes_with_mouse() {
}
#[test]
+fn mouse_focus_clears_bell_on_focused_pane() {
+ let size = Size {
+ cols: 121,
+ rows: 20,
+ };
+ let client_id = 1;
+ let mut screen = create_new_screen(size, true, true);
+
+ new_tab(&mut screen, 1, 0);
+
+ let new_pane_id = PaneId::Terminal(2);
+ {
+ let active_tab = screen.get_active_tab_mut(client_id).unwrap();
+ // Split horizontally: pane 1 on top, pane 2 on bottom; focus moves to pane 2
+ active_tab
+ .horizontal_split(new_pane_id, None, client_id, None, None)
+ .unwrap();
+ // Move focus back up to pane 1 so pane 2 is unfocused
+ active_tab.move_focus_up(client_id).unwrap();
+ // Plant a bell on the unfocused pane 2
+ active_tab.handle_pty_bytes(2, vec![7u8]).unwrap();
+ active_tab.check_and_handle_bell_notifications(false);
+ assert!(
+ active_tab.panes_with_pending_bell.contains(&new_pane_id),
+ "Pane 2 should have a pending bell before the click"
+ );
+ assert!(
+ active_tab.tab_has_pending_bell,
+ "Tab should have a pending bell before the click"
+ );
+ }
+
+ // Click somewhere in pane 2 (bottom half of the screen)
+ screen.handle_mouse_event(
+ MouseEvent::new_left_press_event(Position::new(15, 60)),
+ client_id,
+ );
+ screen.handle_mouse_event(
+ MouseEvent::new_left_release_event(Position::new(15, 60)),
+ client_id,
+ );
+
+ let active_tab = screen.get_active_tab(client_id).unwrap();
+ assert_eq!(
+ active_tab.get_active_pane_id(client_id),
+ Some(new_pane_id),
+ "Mouse click should have focused pane 2"
+ );
+ assert!(
+ !active_tab.panes_with_pending_bell.contains(&new_pane_id),
+ "Bell on pane 2 should be cleared after mouse focus"
+ );
+ assert!(
+ !active_tab.tab_has_pending_bell,
+ "Tab bell should be cleared after the last pane bell is cleared"
+ );
+}
+
+#[test]
fn group_panes_with_keyboard() {
let size = Size {
cols: 121,