diff options
-rw-r--r-- | include/swaybar/tray/sni.h | 11 | ||||
-rw-r--r-- | swaybar/tray/sni.c | 11 | ||||
-rw-r--r-- | swaybar/tray/tray.c | 7 |
3 files changed, 27 insertions, 2 deletions
diff --git a/include/swaybar/tray/sni.h b/include/swaybar/tray/sni.h index 22991e53..95c10b9f 100644 --- a/include/swaybar/tray/sni.h +++ b/include/swaybar/tray/sni.h | |||
@@ -54,6 +54,17 @@ int sni_str_cmp(const void *item, const void *str); | |||
54 | */ | 54 | */ |
55 | int sni_uniq_cmp(const void *item, const void *str); | 55 | int sni_uniq_cmp(const void *item, const void *str); |
56 | 56 | ||
57 | |||
58 | struct ObjName { | ||
59 | const void *obj_path; | ||
60 | const void *name; | ||
61 | }; | ||
62 | /** | ||
63 | * Returns 0 if `item` has a name of `obj_name->name` and object path of | ||
64 | * `obj_name->obj_path`. | ||
65 | */ | ||
66 | int sni_obj_name_cmp(const void *item, const void *obj_name); | ||
67 | |||
57 | /** | 68 | /** |
58 | * Gets an icon for the given item if found. | 69 | * Gets an icon for the given item if found. |
59 | * | 70 | * |
diff --git a/swaybar/tray/sni.c b/swaybar/tray/sni.c index 44d7ad91..7e09f414 100644 --- a/swaybar/tray/sni.c +++ b/swaybar/tray/sni.c | |||
@@ -484,6 +484,17 @@ int sni_uniq_cmp(const void *_item, const void *_str) { | |||
484 | } | 484 | } |
485 | return strcmp(item->unique_name, str); | 485 | return strcmp(item->unique_name, str); |
486 | } | 486 | } |
487 | int sni_obj_name_cmp(const void *_item, const void *_obj_name) { | ||
488 | const struct StatusNotifierItem *item = _item; | ||
489 | const struct ObjName *obj_name = _obj_name; | ||
490 | |||
491 | if (strcmp(item->name, obj_name->name) == 0 && | ||
492 | strcmp(item->object_path, obj_name->obj_path) == 0) { | ||
493 | return 0; | ||
494 | } | ||
495 | return 1; | ||
496 | } | ||
497 | |||
487 | void sni_free(struct StatusNotifierItem *item) { | 498 | void sni_free(struct StatusNotifierItem *item) { |
488 | if (!item) { | 499 | if (!item) { |
489 | return; | 500 | return; |
diff --git a/swaybar/tray/tray.c b/swaybar/tray/tray.c index 01532e1c..5cc7e902 100644 --- a/swaybar/tray/tray.c +++ b/swaybar/tray/tray.c | |||
@@ -291,8 +291,11 @@ static DBusHandlerResult signal_handler(DBusConnection *connection, | |||
291 | return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; | 291 | return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; |
292 | } | 292 | } |
293 | 293 | ||
294 | // TODO allow one unique name to have multiple items | 294 | struct ObjName obj_name = { |
295 | if (list_seq_find(tray->items, sni_str_cmp, unique_name) == -1) { | 295 | object_path, |
296 | unique_name, | ||
297 | }; | ||
298 | if (list_seq_find(tray->items, sni_obj_name_cmp, &obj_name) == -1) { | ||
296 | struct StatusNotifierItem *item = | 299 | struct StatusNotifierItem *item = |
297 | sni_create_from_obj_path(unique_name, | 300 | sni_create_from_obj_path(unique_name, |
298 | object_path); | 301 | object_path); |