From 6c9de72c7d3b74abb6d34767d854776c63203ba8 Mon Sep 17 00:00:00 2001 From: Nikos Tsipinakis Date: Thu, 22 Dec 2016 19:09:16 +0200 Subject: [PATCH] Don't consider notifications duplicate if icon or urgency differ Expand the duplication checking functionality to also check for urgency and icons. If icons are turned off in the settings the icon check is skipped. Icons matching is done based on the given path, if the path differs or an icon name is used for one notification but an absolute path for another, the icons are considered different even if they refer to the same file. --- src/notification.c | 17 +++++++++++------ src/notification.h | 1 + 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/notification.c b/src/notification.c index 61c1b51..6a67381 100644 --- a/src/notification.c +++ b/src/notification.c @@ -143,6 +143,15 @@ int notification_cmp_data(const void *va, const void *vb, void *data) return notification_cmp(va, vb); } +int notification_is_duplicate(const notification *a, const notification *b) +{ + return strcmp(a->appname, b->appname) == 0 + && strcmp(a->summary, b->summary) == 0 + && strcmp(a->body, b->body) == 0 + && (settings.icon_position != icons_off ? strcmp(a->icon, b->icon) == 0 : 1) + && a->urgency == b->urgency; +} + /* * Free the memory used by the given notification. */ @@ -373,9 +382,7 @@ int notification_init(notification * n, int id) for (GList * iter = g_queue_peek_head_link(queue); iter; iter = iter->next) { notification *orig = iter->data; - if (strcmp(orig->appname, n->appname) == 0 - && strcmp(orig->summary, n->summary) == 0 - && strcmp(orig->body, n->body) == 0) { + if (notification_is_duplicate(orig, n)) { /* If the progress differs this was probably intended to replace the notification * but notify-send was used. So don't increment dup_count in this case */ @@ -398,9 +405,7 @@ int notification_init(notification * n, int id) for (GList * iter = g_queue_peek_head_link(displayed); iter; iter = iter->next) { notification *orig = iter->data; - if (strcmp(orig->appname, n->appname) == 0 - && strcmp(orig->summary, n->summary) == 0 - && strcmp(orig->body, n->body) == 0) { + if (notification_is_duplicate(orig, n)) { /* notifications that differ only in progress hints should be expected equal, * but we want the latest message, with the latest hint value */ diff --git a/src/notification.h b/src/notification.h index b15a6ac..5a06d24 100644 --- a/src/notification.h +++ b/src/notification.h @@ -59,6 +59,7 @@ void notification_free(notification * n); int notification_close_by_id(int id, int reason); int notification_cmp(const void *a, const void *b); int notification_cmp_data(const void *a, const void *b, void *data); +int notification_is_duplicate(const notification *a, const notification *b); void notification_run_script(notification * n); int notification_close(notification * n, int reason); void notification_print(notification * n);