aboutsummaryrefslogtreecommitdiffstats
path: root/swaybar/tray/host.c
diff options
context:
space:
mode:
Diffstat (limited to 'swaybar/tray/host.c')
-rw-r--r--swaybar/tray/host.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/swaybar/tray/host.c b/swaybar/tray/host.c
index 3cc90254..8ab896d4 100644
--- a/swaybar/tray/host.c
+++ b/swaybar/tray/host.c
@@ -5,6 +5,7 @@
5#include <string.h> 5#include <string.h>
6#include <unistd.h> 6#include <unistd.h>
7#include "swaybar/tray/host.h" 7#include "swaybar/tray/host.h"
8#include "swaybar/tray/item.h"
8#include "swaybar/tray/tray.h" 9#include "swaybar/tray/tray.h"
9#include "list.h" 10#include "list.h"
10#include "log.h" 11#include "log.h"
@@ -12,15 +13,15 @@
12static const char *watcher_path = "/StatusNotifierWatcher"; 13static const char *watcher_path = "/StatusNotifierWatcher";
13 14
14static int cmp_sni_id(const void *item, const void *cmp_to) { 15static int cmp_sni_id(const void *item, const void *cmp_to) {
15 const char *sni = item; 16 const struct swaybar_sni *sni = item;
16 return strcmp(sni, cmp_to); 17 return strcmp(sni->watcher_id, cmp_to);
17} 18}
18 19
19static void add_sni(struct swaybar_tray *tray, char *id) { 20static void add_sni(struct swaybar_tray *tray, char *id) {
20 int idx = list_seq_find(tray->items, cmp_sni_id, id); 21 int idx = list_seq_find(tray->items, cmp_sni_id, id);
21 if (idx == -1) { 22 if (idx == -1) {
22 wlr_log(WLR_DEBUG, "Registering Status Notifier Item '%s'", id); 23 wlr_log(WLR_DEBUG, "Registering Status Notifier Item '%s'", id);
23 char *sni = strdup(id); 24 struct swaybar_sni *sni = create_sni(id, tray);
24 if (sni) { 25 if (sni) {
25 list_add(tray->items, sni); 26 list_add(tray->items, sni);
26 } 27 }
@@ -53,7 +54,7 @@ static int handle_sni_unregistered(sd_bus_message *msg, void *data,
53 int idx = list_seq_find(tray->items, cmp_sni_id, id); 54 int idx = list_seq_find(tray->items, cmp_sni_id, id);
54 if (idx != -1) { 55 if (idx != -1) {
55 wlr_log(WLR_DEBUG, "Unregistering Status Notifier Item '%s'", id); 56 wlr_log(WLR_DEBUG, "Unregistering Status Notifier Item '%s'", id);
56 free(tray->items->items[idx]); 57 destroy_sni(tray->items->items[idx]);
57 list_del(tray->items, idx); 58 list_del(tray->items, idx);
58 } 59 }
59 return ret; 60 return ret;