gtk-ng: fix setting/unsetting of urgency (#8376)

- Don't set urgency on windows that are the topmost window.
- Turn off urgency on windows that become the topmost window.

Fixes #8373
This commit is contained in:
Mitchell Hashimoto
2025-08-25 07:20:15 -07:00
committed by GitHub
2 changed files with 23 additions and 2 deletions

View File

@@ -987,6 +987,22 @@ pub const Window = extern struct {
};
}
fn propIsActive(
_: *gtk.Window,
_: *gobject.ParamSpec,
self: *Self,
) callconv(.c) void {
// Don't change urgency if we're not the active window.
if (self.as(gtk.Window).isActive() == 0) return;
self.winproto().setUrgent(false) catch |err| {
log.warn(
"winproto failed to reset urgency={}",
.{err},
);
};
}
fn propGdkSurfaceWidth(
_: *gdk.Surface,
_: *gobject.ParamSpec,
@@ -1765,10 +1781,13 @@ pub const Window = extern struct {
native.beep();
}
if (config.@"bell-features".attention) {
if (config.@"bell-features".attention) attention: {
// Dont set urgency if the window is already active.
if (self.as(gtk.Window).isActive() != 0) break :attention;
// Request user attention
self.winproto().setUrgent(true) catch |err| {
log.warn("failed to request user attention={}", .{err});
log.warn("winproto failed to set urgency={}", .{err});
};
}
}
@@ -1912,6 +1931,7 @@ pub const Window = extern struct {
class.bindTemplateCallback("notify_selected_page", &tabViewSelectedPage);
class.bindTemplateCallback("notify_config", &propConfig);
class.bindTemplateCallback("notify_fullscreened", &propFullscreened);
class.bindTemplateCallback("notify_is_active", &propIsActive);
class.bindTemplateCallback("notify_maximized", &propMaximized);
class.bindTemplateCallback("notify_menu_active", &propMenuActive);
class.bindTemplateCallback("notify_quick_terminal", &propQuickTerminal);

View File

@@ -10,6 +10,7 @@ template $GhosttyWindow: Adw.ApplicationWindow {
realize => $realize();
notify::config => $notify_config();
notify::fullscreened => $notify_fullscreened();
notify::is-active => $notify_is_active();
notify::maximized => $notify_maximized();
notify::quick-terminal => $notify_quick_terminal();
notify::scale-factor => $notify_scale_factor();