From 86cbc1d34bb0f551461dbd466cd9e4860ae01817 Mon Sep 17 00:00:00 2001 From: Nikos Tsipinakis Date: Wed, 19 Jul 2017 09:13:19 +0300 Subject: [PATCH] Make icon set via rules take priority over raw icons When a notification contains both a raw icon and an icon path according to the GNOME notification specification the raw icon should take priority over anything else. If, however, a user uses the new_icon rule to set a custom icon on a notification, that rule overwrote the icon path and not the raw icon and as a result the raw icon was displayed in place of the user specified one. As a simple fix, a new icon_overridden boolean was added to the notification struct indicating if a custom icon has been set. If so, the icon path should take priority over the raw icon. Fixes #339 --- CHANGELOG.md | 3 +++ src/notification.h | 1 + src/rules.c | 1 + src/x11/x.c | 5 ++++- 4 files changed, 9 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f8ee104..fb97a72 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,9 @@ ## Unreleased +### Fixed +- `new_icon` rule being ignored on notifications that had a raw icon + ## 1.2.0 - 2017-07-12 ### Added diff --git a/src/notification.h b/src/notification.h index e5731a8..df64d08 100644 --- a/src/notification.h +++ b/src/notification.h @@ -34,6 +34,7 @@ typedef struct _notification { char *appname; char *summary; char *body; + bool icon_overridden; char *icon; RawImage *raw_icon; char *msg; /* formatted message */ diff --git a/src/rules.c b/src/rules.c index a40fc55..6cc6871 100644 --- a/src/rules.c +++ b/src/rules.c @@ -24,6 +24,7 @@ void rule_apply(rule_t * r, notification * n) if(n->icon) g_free(n->icon); n->icon = g_strdup(r->new_icon); + n->icon_overridden = true; } if (r->fg) n->color_strings[ColFG] = r->fg; diff --git a/src/x11/x.c b/src/x11/x.c index 9f7ac20..57ca7b3 100644 --- a/src/x11/x.c +++ b/src/x11/x.c @@ -408,8 +408,11 @@ static colored_layout *r_init_shared(cairo_t *c, notification *n) GdkPixbuf *pixbuf = NULL; - if (n->raw_icon && settings.icon_position != icons_off) { + if (n->raw_icon && !n->icon_overridden && + settings.icon_position != icons_off) { + pixbuf = get_pixbuf_from_raw_image(n->raw_icon); + } else if (n->icon && settings.icon_position != icons_off) { pixbuf = get_pixbuf_from_path(n->icon); }