diff options
Diffstat (limited to 'swaybar/tray/sni.c')
-rw-r--r-- | swaybar/tray/sni.c | 33 |
1 files changed, 25 insertions, 8 deletions
diff --git a/swaybar/tray/sni.c b/swaybar/tray/sni.c index c9d00657..44d7ad91 100644 --- a/swaybar/tray/sni.c +++ b/swaybar/tray/sni.c | |||
@@ -179,7 +179,7 @@ static void send_icon_msg(struct StatusNotifierItem *item) { | |||
179 | DBusPendingCall *pending; | 179 | DBusPendingCall *pending; |
180 | DBusMessage *message = dbus_message_new_method_call( | 180 | DBusMessage *message = dbus_message_new_method_call( |
181 | item->name, | 181 | item->name, |
182 | "/StatusNotifierItem", | 182 | item->object_path, |
183 | "org.freedesktop.DBus.Properties", | 183 | "org.freedesktop.DBus.Properties", |
184 | "Get"); | 184 | "Get"); |
185 | const char *iface; | 185 | const char *iface; |
@@ -285,7 +285,7 @@ static void send_icon_name_msg(struct StatusNotifierItem *item) { | |||
285 | DBusPendingCall *pending; | 285 | DBusPendingCall *pending; |
286 | DBusMessage *message = dbus_message_new_method_call( | 286 | DBusMessage *message = dbus_message_new_method_call( |
287 | item->name, | 287 | item->name, |
288 | "/StatusNotifierItem", | 288 | item->object_path, |
289 | "org.freedesktop.DBus.Properties", | 289 | "org.freedesktop.DBus.Properties", |
290 | "Get"); | 290 | "Get"); |
291 | const char *iface; | 291 | const char *iface; |
@@ -324,7 +324,7 @@ void sni_activate(struct StatusNotifierItem *item, uint32_t x, uint32_t y) { | |||
324 | : "org.freedesktop.StatusNotifierItem"); | 324 | : "org.freedesktop.StatusNotifierItem"); |
325 | DBusMessage *message = dbus_message_new_method_call( | 325 | DBusMessage *message = dbus_message_new_method_call( |
326 | item->name, | 326 | item->name, |
327 | "/StatusNotifierItem", | 327 | item->object_path, |
328 | iface, | 328 | iface, |
329 | "Activate"); | 329 | "Activate"); |
330 | 330 | ||
@@ -342,9 +342,10 @@ void sni_context_menu(struct StatusNotifierItem *item, uint32_t x, uint32_t y) { | |||
342 | const char *iface = | 342 | const char *iface = |
343 | (item->kde_special_snowflake ? "org.kde.StatusNotifierItem" | 343 | (item->kde_special_snowflake ? "org.kde.StatusNotifierItem" |
344 | : "org.freedesktop.StatusNotifierItem"); | 344 | : "org.freedesktop.StatusNotifierItem"); |
345 | sway_log(L_INFO, "Activating context menu for item: (%s,%s)", item->name, item->object_path); | ||
345 | DBusMessage *message = dbus_message_new_method_call( | 346 | DBusMessage *message = dbus_message_new_method_call( |
346 | item->name, | 347 | item->name, |
347 | "/StatusNotifierItem", | 348 | item->object_path, |
348 | iface, | 349 | iface, |
349 | "ContextMenu"); | 350 | "ContextMenu"); |
350 | 351 | ||
@@ -363,7 +364,7 @@ void sni_secondary(struct StatusNotifierItem *item, uint32_t x, uint32_t y) { | |||
363 | : "org.freedesktop.StatusNotifierItem"); | 364 | : "org.freedesktop.StatusNotifierItem"); |
364 | DBusMessage *message = dbus_message_new_method_call( | 365 | DBusMessage *message = dbus_message_new_method_call( |
365 | item->name, | 366 | item->name, |
366 | "/StatusNotifierItem", | 367 | item->object_path, |
367 | iface, | 368 | iface, |
368 | "SecondaryActivate"); | 369 | "SecondaryActivate"); |
369 | 370 | ||
@@ -426,6 +427,8 @@ struct StatusNotifierItem *sni_create(const char *name) { | |||
426 | struct StatusNotifierItem *item = malloc(sizeof(struct StatusNotifierItem)); | 427 | struct StatusNotifierItem *item = malloc(sizeof(struct StatusNotifierItem)); |
427 | item->name = strdup(name); | 428 | item->name = strdup(name); |
428 | item->unique_name = NULL; | 429 | item->unique_name = NULL; |
430 | // TODO use static str if the default path instead of all these god-damn strdups | ||
431 | item->object_path = strdup("/StatusNotifierItem"); | ||
429 | item->image = NULL; | 432 | item->image = NULL; |
430 | item->dirty = false; | 433 | item->dirty = false; |
431 | 434 | ||
@@ -449,6 +452,21 @@ struct StatusNotifierItem *sni_create(const char *name) { | |||
449 | 452 | ||
450 | return item; | 453 | return item; |
451 | } | 454 | } |
455 | struct StatusNotifierItem *sni_create_from_obj_path(const char *unique_name, | ||
456 | const char *object_path) { | ||
457 | struct StatusNotifierItem *item = malloc(sizeof(struct StatusNotifierItem)); | ||
458 | // XXX strdup-ing twice to avoid a double-free; see above todo | ||
459 | item->name = strdup(unique_name); | ||
460 | item->unique_name = strdup(unique_name); | ||
461 | item->object_path = strdup(object_path); | ||
462 | item->image = NULL; | ||
463 | item->dirty = false; | ||
464 | // If they're registering by obj-path they're a special snowflake | ||
465 | item->kde_special_snowflake = true; | ||
466 | |||
467 | get_icon(item); | ||
468 | return item; | ||
469 | } | ||
452 | /* Return 0 if `item` has a name of `str` */ | 470 | /* Return 0 if `item` has a name of `str` */ |
453 | int sni_str_cmp(const void *_item, const void *_str) { | 471 | int sni_str_cmp(const void *_item, const void *_str) { |
454 | const struct StatusNotifierItem *item = _item; | 472 | const struct StatusNotifierItem *item = _item; |
@@ -471,9 +489,8 @@ void sni_free(struct StatusNotifierItem *item) { | |||
471 | return; | 489 | return; |
472 | } | 490 | } |
473 | free(item->name); | 491 | free(item->name); |
474 | if (item->unique_name) { | 492 | free(item->unique_name); |
475 | free(item->unique_name); | 493 | free(item->object_path); |
476 | } | ||
477 | if (item->image) { | 494 | if (item->image) { |
478 | cairo_surface_destroy(item->image); | 495 | cairo_surface_destroy(item->image); |
479 | } | 496 | } |