diff options
Diffstat (limited to 'swaybar')
-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) { | |||
397 | return; | 397 | return; |
398 | } | 398 | } |
399 | 399 | ||
400 | char *unique_name; | ||
400 | if (!dbus_message_get_args(reply, NULL, | 401 | if (!dbus_message_get_args(reply, NULL, |
401 | DBUS_TYPE_STRING, &item->unique_name, | 402 | DBUS_TYPE_STRING, &unique_name, |
402 | DBUS_TYPE_INVALID)) { | 403 | DBUS_TYPE_INVALID)) { |
403 | item->unique_name = NULL; | ||
404 | sway_log(L_ERROR, "Error parsing method args"); | 404 | sway_log(L_ERROR, "Error parsing method args"); |
405 | } else { | ||
406 | if (item->unique_name) { | ||
407 | free(item->unique_name); | ||
408 | } | ||
409 | item->unique_name = strdup(unique_name); | ||
405 | } | 410 | } |
406 | 411 | ||
407 | dbus_message_unref(reply); | 412 | dbus_message_unref(reply); |
@@ -434,14 +439,14 @@ struct StatusNotifierItem *sni_create(const char *name) { | |||
434 | 439 | ||
435 | return item; | 440 | return item; |
436 | } | 441 | } |
437 | /* Return true if `item` has a name of `str` */ | 442 | /* Return 0 if `item` has a name of `str` */ |
438 | int sni_str_cmp(const void *_item, const void *_str) { | 443 | int sni_str_cmp(const void *_item, const void *_str) { |
439 | const struct StatusNotifierItem *item = _item; | 444 | const struct StatusNotifierItem *item = _item; |
440 | const char *str = _str; | 445 | const char *str = _str; |
441 | 446 | ||
442 | return strcmp(item->name, str); | 447 | return strcmp(item->name, str); |
443 | } | 448 | } |
444 | /* Returns true if `item` has a unique name of `str` */ | 449 | /* Returns 0 if `item` has a unique name of `str` */ |
445 | int sni_uniq_cmp(const void *_item, const void *_str) { | 450 | int sni_uniq_cmp(const void *_item, const void *_str) { |
446 | const struct StatusNotifierItem *item = _item; | 451 | const struct StatusNotifierItem *item = _item; |
447 | const char *str = _str; | 452 | const char *str = _str; |
@@ -456,6 +461,9 @@ void sni_free(struct StatusNotifierItem *item) { | |||
456 | return; | 461 | return; |
457 | } | 462 | } |
458 | free(item->name); | 463 | free(item->name); |
464 | if (item->unique_name) { | ||
465 | free(item->unique_name); | ||
466 | } | ||
459 | if (item->image) { | 467 | if (item->image) { |
460 | cairo_surface_destroy(item->image); | 468 | cairo_surface_destroy(item->image); |
461 | } | 469 | } |
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, | |||
179 | name = dbus_message_get_sender(message); | 179 | name = dbus_message_get_sender(message); |
180 | if ((index = list_seq_find(tray->items, sni_uniq_cmp, name)) != -1) { | 180 | if ((index = list_seq_find(tray->items, sni_uniq_cmp, name)) != -1) { |
181 | item = tray->items->items[index]; | 181 | item = tray->items->items[index]; |
182 | sway_log(L_INFO, "NewIcon signal from item %s", item->name); | ||
182 | get_icon(item); | 183 | get_icon(item); |
183 | } | 184 | } |
184 | 185 | ||