diff --git a/src/dbus.c b/src/dbus.c index 9af7c2e..bbf5a12 100644 --- a/src/dbus.c +++ b/src/dbus.c @@ -124,10 +124,7 @@ static void on_get_capabilities(GDBusConnection *connection, g_dbus_connection_flush(connection, NULL, NULL, NULL); } -static void on_notify(GDBusConnection *connection, - const gchar *sender, - GVariant *parameters, - GDBusMethodInvocation *invocation) +static notification *dbus_message_to_notification(const gchar *sender, GVariant *parameters) { gchar *appname = NULL; @@ -265,6 +262,7 @@ static void on_notify(GDBusConnection *connection, notification *n = notification_create(); + n->id = replaces_id; n->appname = appname; n->summary = summary; n->body = body; @@ -287,7 +285,16 @@ static void on_notify(GDBusConnection *connection, n->colors[ColBG] = bgcolor; notification_init(n); - int id = queues_notification_insert(n, replaces_id); + return n; +} + +static void on_notify(GDBusConnection *connection, + const gchar *sender, + GVariant *parameters, + GDBusMethodInvocation *invocation) +{ + notification *n = dbus_message_to_notification(sender, parameters); + int id = queues_notification_insert(n); GVariant *reply = g_variant_new("(u)", id); g_dbus_method_invocation_return_value(invocation, reply); diff --git a/src/dunst.c b/src/dunst.c index 5d55467..c8e15ba 100644 --- a/src/dunst.c +++ b/src/dunst.c @@ -151,6 +151,7 @@ int dunst_main(int argc, char *argv[]) if (settings.startup_notification) { notification *n = notification_create(); + n->id = 0; n->appname = g_strdup("dunst"); n->summary = g_strdup("startup"); n->body = g_strdup("dunst is up and running"); @@ -159,7 +160,7 @@ int dunst_main(int argc, char *argv[]) n->markup = MARKUP_NO; n->urgency = URG_LOW; notification_init(n); - queues_notification_insert(n, 0); + queues_notification_insert(n); // we do not call wakeup now, wake_up does not work here yet } diff --git a/src/queues.c b/src/queues.c index fa9da51..924b646 100644 --- a/src/queues.c +++ b/src/queues.c @@ -51,7 +51,7 @@ unsigned int queues_length_history() return history->length; } -int queues_notification_insert(notification *n, int replaces_id) +int queues_notification_insert(notification *n) { /* do not display the message, if the message is empty */ @@ -72,12 +72,11 @@ int queues_notification_insert(notification *n, int replaces_id) return 0; } - if (replaces_id == 0) { + if (n->id == 0) { n->id = ++next_notification_id; if (!settings.stack_duplicates || !queues_stack_duplicate(n)) g_queue_insert_sorted(waiting, n, notification_cmp_data, NULL); } else { - n->id = replaces_id; if (!queues_notification_replace_id(n)) g_queue_insert_sorted(waiting, n, notification_cmp_data, NULL); } diff --git a/src/queues.h b/src/queues.h index f280cd5..dab452b 100644 --- a/src/queues.h +++ b/src/queues.h @@ -34,13 +34,13 @@ unsigned int queues_length_history(); * Insert a fully initialized notification into queues * Respects stack_duplicates, and notification replacement * - * If replaces_id != 0, n replaces notification with id replaces_id - * If replaces_id == 0, n gets occupies a new position + * If n->id != 0, n replaces notification with id n->id + * If n->id == 0, n gets a new id assigned * * Returns the assigned notification id * If returned id == 0, the message was dismissed */ -int queues_notification_insert(notification *n, int replaces_id); +int queues_notification_insert(notification *n); /* * Replace the notification which matches the id field of