Handle reload workspace events from sway correctly

Closes #361
This commit is contained in:
Haden Collins 2024-03-14 16:14:53 -05:00
parent f2d25c8341
commit 89ae7bd743
No known key found for this signature in database
GPG key ID: E25D679AF73C6D2F

View file

@ -418,10 +418,12 @@ handle_workspace_event(int sock, int type, const struct json_object *json, void
bool is_rename = strcmp(change_str, "rename") == 0;
bool is_move = strcmp(change_str, "move") == 0;
bool is_urgent = strcmp(change_str, "urgent") == 0;
bool is_reload = strcmp(change_str, "reload") == 0;
struct json_object *current, *_current_id;
if (!json_object_object_get_ex(json, "current", &current) ||
!json_object_object_get_ex(current, "id", &_current_id))
if ((!json_object_object_get_ex(json, "current", &current) ||
!json_object_object_get_ex(current, "id", &_current_id)) &&
!is_reload)
{
LOG_ERR("workspace event without 'current' and/or 'id' properties");
return false;
@ -543,6 +545,12 @@ handle_workspace_event(int sock, int type, const struct json_object *json, void
w->urgent = json_object_get_boolean(urgent);
}
else if (is_reload) {
/* Schedule full update to check if anything was changed
* during reload */
i3_send_pkg(sock, I3_IPC_MESSAGE_TYPE_GET_WORKSPACES, NULL);
}
else {
LOG_WARN("unimplemented workspace event '%s'", change_str);
}