From 24562cc76211579c9169039dab5d337a4731cf6e Mon Sep 17 00:00:00 2001 From: Victor Kareh Date: Sat, 21 Mar 2026 12:06:06 -0400 Subject: daemon: Fix NotificationClosed signal reason for close button When clicking the close button on a notification, the D-Bus signal incorrectly sent reason=1 (expired) instead of reason=2 (dismissed). Fixed by setting a flag on the notification window in the close button callback before destroying it, and checking this flag in the callback to send the correct close reason. Fixes #129 --- src/daemon/daemon.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src/daemon/daemon.c') diff --git a/src/daemon/daemon.c b/src/daemon/daemon.c index e5033de..a7c63a6 100644 --- a/src/daemon/daemon.c +++ b/src/daemon/daemon.c @@ -756,8 +756,14 @@ static void _notification_destroyed_cb(GtkWindow* nw, NotifyDaemon* daemon) /* * This usually won't happen, but can if notification-daemon dies before * all notifications are closed. Mark them as expired. + * + * But if instead the notification's close button was clicked, the + * "_user_closed" flag will be set on the window, so we send the + * correct reason. */ - _close_notification(daemon, NW_GET_NOTIFY_ID(nw), FALSE, NOTIFYD_CLOSED_EXPIRED); + gboolean user_closed = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(nw), "_user_closed")); + _close_notification(daemon, NW_GET_NOTIFY_ID(nw), FALSE, + user_closed ? NOTIFYD_CLOSED_USER : NOTIFYD_CLOSED_EXPIRED); } #ifdef HAVE_X11 -- cgit v1.2.1