gtk(bell): add `bell-features` config option

Co-authored-by: Jeffrey C. Ollie <jeff@ocjtech.us>
pull/7087/head
Leah Amelia Chen 2025-04-14 23:27:05 +08:00
parent abd7d9202b
commit 3a973c692a
No known key found for this signature in database
2 changed files with 24 additions and 1 deletions

View File

@ -2441,13 +2441,15 @@ pub fn setSecureInput(self: *Surface, value: apprt.action.SecureInput) void {
}
pub fn ringBell(self: *Surface) !void {
const features = self.app.config.@"bell-features";
const window = self.container.window() orelse {
log.warn("failed to ring bell: surface is not attached to any window", .{});
return;
};
// System beep
if (window.window.as(gtk.Native).getSurface()) |surface| {
if (features.system) system: {
const surface = window.window.as(gtk.Native).getSurface() orelse break :system;
surface.beep();
}

View File

@ -1848,6 +1848,22 @@ keybind: Keybinds = .{},
/// open terminals.
@"custom-shader-animation": CustomShaderAnimation = .true,
/// The list of enabled features that are activated after encountering
/// a bell character.
///
/// Valid values are:
///
/// * `system` (default)
///
/// Instructs the system to notify the user using built-in system functions.
/// This could result in an audiovisual effect, a notification, or something
/// else entirely. Changing these effects require altering system settings:
/// for instance under the "Sound > Alert Sound" setting in GNOME,
/// or the "Accessibility > System Bell" settings in KDE Plasma.
///
/// Currently only implemented on Linux.
@"bell-features": BellFeatures = .{},
/// Control the in-app notifications that Ghostty shows.
///
/// On Linux (GTK), in-app notifications show up as toasts. Toasts appear
@ -5669,6 +5685,11 @@ pub const AppNotifications = packed struct {
@"clipboard-copy": bool = true,
};
/// See bell-features
pub const BellFeatures = packed struct {
system: bool = false,
};
/// See mouse-shift-capture
pub const MouseShiftCapture = enum {
false,