module/i3: if a new workspace is created, but unfocused, assume it’s not empty

If a window is created on an unfocused workspace, yambar did not
update the empty tag correctly. At least not for persistent
workspaces.

This is because yambar relies on focus events to determine a
workspace's "empty" state. Since the new window, on the new workspace,
isn't focused, there's no focus event, and yambar thinks the workspace
is still empty.

This patch changes the logic slightly; a new workspace is considered
non-empty if it isn't focused (and has a non-zero node count).

Closes #191
This commit is contained in:
Daniel Eklöf 2022-06-02 21:26:39 +02:00
parent 03e1c7dc13
commit b0e132beaf
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F

View file

@ -139,7 +139,7 @@ workspace_from_json(const struct json_object *json, struct workspace *ws)
.visible = json_object_get_boolean(visible), .visible = json_object_get_boolean(visible),
.focused = json_object_get_boolean(focused), .focused = json_object_get_boolean(focused),
.urgent = json_object_get_boolean(urgent), .urgent = json_object_get_boolean(urgent),
.empty = is_empty, .empty = is_empty && json_object_get_boolean(focused),
.window = {.title = NULL, .pid = -1}, .window = {.title = NULL, .pid = -1},
}; };