diff options
author | Calvin Lee <cyrus296@gmail.com> | 2017-06-08 05:36:17 -0700 |
---|---|---|
committer | Calvin Lee <cyrus296@gmail.com> | 2017-06-08 08:24:35 -0700 |
commit | 0a71aa6e97a96ffbd34fe18ec42b27d8fe5952e8 (patch) | |
tree | e10916e6797debf9cbd4c2599259ea56646fd302 /swaybar/tray | |
parent | 1451ee8fd13dd35227d11e393c80871c70ad90f0 (diff) | |
download | sway-0a71aa6e97a96ffbd34fe18ec42b27d8fe5952e8.tar.xz |
Fix Catching NewIcon Signal
The unique name was not copied out of the wire marshalled DBus message
data so `sni_uniq_cmp` would always match against junk data.
Diffstat (limited to 'swaybar/tray')
-rw-r--r-- | swaybar/tray/sni.c | 16 | ||||
-rw-r--r-- | swaybar/tray/tray.c | 1 |
2 files changed, 13 insertions, 4 deletions
diff --git a/swaybar/tray/sni.c b/swaybar/tray/sni.c index f0638dca..0c46d5c0 100644 --- a/swaybar/tray/sni.c +++ b/swaybar/tray/sni.c @@ -397,11 +397,16 @@ static void get_unique_name(struct StatusNotifierItem *item) { return; } + char *unique_name; if (!dbus_message_get_args(reply, NULL, - DBUS_TYPE_STRING, &item->unique_name, + DBUS_TYPE_STRING, &unique_name, DBUS_TYPE_INVALID)) { - item->unique_name = NULL; sway_log(L_ERROR, "Error parsing method args"); + } else { + if (item->unique_name) { + free(item->unique_name); + } + item->unique_name = strdup(unique_name); } dbus_message_unref(reply); @@ -434,14 +439,14 @@ struct StatusNotifierItem *sni_create(const char *name) { return item; } -/* Return true if `item` has a name of `str` */ +/* Return 0 if `item` has a name of `str` */ int sni_str_cmp(const void *_item, const void *_str) { const struct StatusNotifierItem *item = _item; const char *str = _str; return strcmp(item->name, str); } -/* Returns true if `item` has a unique name of `str` */ +/* Returns 0 if `item` has a unique name of `str` */ int sni_uniq_cmp(const void *_item, const void *_str) { const struct StatusNotifierItem *item = _item; const char *str = _str; @@ -456,6 +461,9 @@ void sni_free(struct StatusNotifierItem *item) { return; } free(item->name); + if (item->unique_name) { + free(item->unique_name); + } if (item->image) { cairo_surface_destroy(item->image); } diff --git a/swaybar/tray/tray.c b/swaybar/tray/tray.c index ca8b1341..b2fa647e 100644 --- a/swaybar/tray/tray.c +++ b/swaybar/tray/tray.c @@ -179,6 +179,7 @@ static DBusHandlerResult signal_handler(DBusConnection *connection, name = dbus_message_get_sender(message); if ((index = list_seq_find(tray->items, sni_uniq_cmp, name)) != -1) { item = tray->items->items[index]; + sway_log(L_INFO, "NewIcon signal from item %s", item->name); get_icon(item); } |