From 6f311498aeeb27c0973781961ef94e8d0016ed17 Mon Sep 17 00:00:00 2001 From: akbash Date: Sat, 8 Aug 2026 02:15:56 +0300 Subject: fix: forward pane terminal bells (#2498) refs #2453 Co-authored-by: akbash-bot <300245827+akbash-bot@users.noreply.github.com> --- src/ghostty/mod.rs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'src/ghostty/mod.rs') diff --git a/src/ghostty/mod.rs b/src/ghostty/mod.rs index 04ad87af..93efbd76 100644 --- a/src/ghostty/mod.rs +++ b/src/ghostty/mod.rs @@ -470,12 +470,22 @@ const MAX_CLIPBOARD_BYTES: usize = 192 * 1024; #[derive(Default)] struct TerminalCallbackState { write_pty: Option>, + bell_count: u16, pwd_changes: Vec>, clipboard_writes: Vec>, size_report: ffi::GhosttySizeReportSize, color_scheme: Option, } +unsafe extern "C" fn bell_trampoline(_terminal: ffi::GhosttyTerminal, userdata: *mut c_void) { + if userdata.is_null() { + return; + } + // SAFETY: userdata is the TerminalCallbackState installed with this terminal. + let state = unsafe { &mut *userdata.cast::() }; + state.bell_count = state.bell_count.saturating_add(1); +} + unsafe extern "C" fn color_scheme_trampoline( _terminal: ffi::GhosttyTerminal, userdata: *mut c_void, @@ -820,6 +830,12 @@ impl Terminal { (size_trampoline as *const ()).cast(), ) .into_result()?; + ffi::ghostty_terminal_set( + terminal.raw, + ffi::GhosttyTerminalOption_GHOSTTY_TERMINAL_OPT_BELL, + (bell_trampoline as *const ()).cast(), + ) + .into_result()?; ffi::ghostty_terminal_set( terminal.raw, ffi::GhosttyTerminalOption_GHOSTTY_TERMINAL_OPT_PWD_CHANGED, @@ -979,6 +995,10 @@ impl Terminal { mem::replace(&mut self.callback_state.color_scheme, color_scheme) } + pub fn take_bell_count(&mut self) -> u16 { + mem::take(&mut self.callback_state.bell_count) + } + pub fn take_pwd_changes(&mut self) -> Vec> { mem::take(&mut self.callback_state.pwd_changes) } -- cgit v1.2.3