Implement empty flag for workspaces in ipc

This commit is contained in:
Marko 2023-06-09 20:15:58 +02:00
parent f57149dedd
commit d3ac856688
2 changed files with 5 additions and 1 deletions

View file

@ -506,6 +506,8 @@ static void ipc_json_describe_workspace(struct sway_workspace *workspace,
json_object_new_string(workspace->output->wlr_output->name) : NULL); json_object_new_string(workspace->output->wlr_output->name) : NULL);
json_object_object_add(object, "urgent", json_object_object_add(object, "urgent",
json_object_new_boolean(workspace->urgent)); json_object_new_boolean(workspace->urgent));
json_object_object_add(object, "empty",
json_object_new_boolean(workspace_is_empty(workspace)));
json_object_object_add(object, "representation", workspace->representation ? json_object_object_add(object, "representation", workspace->representation ?
json_object_new_string(workspace->representation) : NULL); json_object_new_string(workspace->representation) : NULL);

View file

@ -355,7 +355,7 @@ bool ipc_get_workspaces(struct swaybar *bar) {
bar->visible_by_urgency = false; bar->visible_by_urgency = false;
size_t length = json_object_array_length(results); size_t length = json_object_array_length(results);
json_object *ws_json; json_object *ws_json;
json_object *num, *name, *visible, *focused, *out, *urgent; json_object *num, *name, *visible, *focused, *out, *urgent, *empty;
for (size_t i = 0; i < length; ++i) { for (size_t i = 0; i < length; ++i) {
ws_json = json_object_array_get_idx(results, i); ws_json = json_object_array_get_idx(results, i);
@ -365,6 +365,7 @@ bool ipc_get_workspaces(struct swaybar *bar) {
json_object_object_get_ex(ws_json, "focused", &focused); json_object_object_get_ex(ws_json, "focused", &focused);
json_object_object_get_ex(ws_json, "output", &out); json_object_object_get_ex(ws_json, "output", &out);
json_object_object_get_ex(ws_json, "urgent", &urgent); json_object_object_get_ex(ws_json, "urgent", &urgent);
json_object_object_get_ex(ws_json, "empty", &empty);
wl_list_for_each(output, &bar->outputs, link) { wl_list_for_each(output, &bar->outputs, link) {
const char *ws_output = json_object_get_string(out); const char *ws_output = json_object_get_string(out);
@ -399,6 +400,7 @@ bool ipc_get_workspaces(struct swaybar *bar) {
if (ws->urgent) { if (ws->urgent) {
bar->visible_by_urgency = true; bar->visible_by_urgency = true;
} }
ws->empty = json_object_get_boolean(empty);
wl_list_insert(output->workspaces.prev, &ws->link); wl_list_insert(output->workspaces.prev, &ws->link);
} }
} }