mirror of
https://github.com/swaywm/sway.git
synced 2026-03-30 11:10:59 -04:00
Allow multiple object paths for each connection
This commit is contained in:
parent
bd121999ca
commit
4231061e4d
3 changed files with 27 additions and 2 deletions
|
|
@ -54,6 +54,17 @@ int sni_str_cmp(const void *item, const void *str);
|
||||||
*/
|
*/
|
||||||
int sni_uniq_cmp(const void *item, const void *str);
|
int sni_uniq_cmp(const void *item, const void *str);
|
||||||
|
|
||||||
|
|
||||||
|
struct ObjName {
|
||||||
|
const void *obj_path;
|
||||||
|
const void *name;
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* Returns 0 if `item` has a name of `obj_name->name` and object path of
|
||||||
|
* `obj_name->obj_path`.
|
||||||
|
*/
|
||||||
|
int sni_obj_name_cmp(const void *item, const void *obj_name);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets an icon for the given item if found.
|
* Gets an icon for the given item if found.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -484,6 +484,17 @@ int sni_uniq_cmp(const void *_item, const void *_str) {
|
||||||
}
|
}
|
||||||
return strcmp(item->unique_name, str);
|
return strcmp(item->unique_name, str);
|
||||||
}
|
}
|
||||||
|
int sni_obj_name_cmp(const void *_item, const void *_obj_name) {
|
||||||
|
const struct StatusNotifierItem *item = _item;
|
||||||
|
const struct ObjName *obj_name = _obj_name;
|
||||||
|
|
||||||
|
if (strcmp(item->name, obj_name->name) == 0 &&
|
||||||
|
strcmp(item->object_path, obj_name->obj_path) == 0) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
void sni_free(struct StatusNotifierItem *item) {
|
void sni_free(struct StatusNotifierItem *item) {
|
||||||
if (!item) {
|
if (!item) {
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
|
|
@ -291,8 +291,11 @@ static DBusHandlerResult signal_handler(DBusConnection *connection,
|
||||||
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
|
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO allow one unique name to have multiple items
|
struct ObjName obj_name = {
|
||||||
if (list_seq_find(tray->items, sni_str_cmp, unique_name) == -1) {
|
object_path,
|
||||||
|
unique_name,
|
||||||
|
};
|
||||||
|
if (list_seq_find(tray->items, sni_obj_name_cmp, &obj_name) == -1) {
|
||||||
struct StatusNotifierItem *item =
|
struct StatusNotifierItem *item =
|
||||||
sni_create_from_obj_path(unique_name,
|
sni_create_from_obj_path(unique_name,
|
||||||
object_path);
|
object_path);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue