gtk: make requesting attention configurable (#7521)

Partially fixes #7520
pull/7527/head
Mitchell Hashimoto 2025-06-05 07:29:17 -07:00 committed by GitHub
commit 2e0a23aa77
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 33 additions and 13 deletions

View File

@ -2454,6 +2454,13 @@ pub fn ringBell(self: *Surface) !void {
media_stream.play();
}
if (features.attention) {
// Request user attention
window.winproto.setUrgent(true) catch |err| {
log.err("failed to request user attention={}", .{err});
};
}
// Mark tab as needing attention
if (self.container.tab()) |tab| tab: {
const page = window.notebook.getTabPage(tab) orelse break :tab;
@ -2461,11 +2468,6 @@ pub fn ringBell(self: *Surface) !void {
// Need attention if we're not the currently selected tab
if (page.getSelected() == 0) page.setNeedsAttention(@intFromBool(true));
}
// Request user attention
window.winproto.setUrgent(true) catch |err| {
log.err("failed to request user attention={}", .{err});
};
}
/// Handle a stream that is in an error state.

View File

@ -1963,7 +1963,7 @@ keybind: Keybinds = .{},
///
/// * `system`
///
/// Instructs the system to notify the user using built-in system functions.
/// Instruct 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,
@ -1973,15 +1973,31 @@ keybind: Keybinds = .{},
///
/// Play a custom sound. (GTK only)
///
/// Example: `audio`, `no-audio`, `system`, `no-system`:
/// * `attention` *(enabled by default)*
///
/// On macOS, if the app is unfocused, it will bounce the app icon in the dock
/// once. Additionally, the title of the window with the alerted terminal
/// surface will contain a bell emoji (🔔) until the terminal is focused
/// or a key is pressed. These are not currently configurable since they're
/// considered unobtrusive.
/// Request the user's attention when Ghostty is unfocused, until it has
/// received focus again. On macOS, this will bounce the app icon in the
/// dock once. On Linux, the behavior depends on the desktop environment
/// and/or the window manager/compositor:
///
/// By default, no bell features are enabled.
/// - On KDE, the background of the desktop icon in the task bar would be
/// highlighted;
///
/// - On GNOME, you may receive a notification that, when clicked, would
/// bring the Ghostty window into focus;
///
/// - On Sway, the window may be decorated with a distinctly colored border;
///
/// - On other systems this may have no effect at all.
///
/// * `title` *(enabled by default)*
///
/// Prepend a bell emoji (🔔) to the title of the alerted surface until the
/// terminal is re-focused or interacted with (such as on keyboard input).
///
/// Only implemented on macOS.
///
/// Example: `audio`, `no-audio`, `system`, `no-system`
@"bell-features": BellFeatures = .{},
/// If `audio` is an enabled bell feature, this is a path to an audio file. If
@ -5879,6 +5895,8 @@ pub const AppNotifications = packed struct {
pub const BellFeatures = packed struct {
system: bool = false,
audio: bool = false,
attention: bool = true,
title: bool = true,
};
/// See mouse-shift-capture