From 89ae7bd74338206d8f14bb03082061275c76dd99 Mon Sep 17 00:00:00 2001 From: Haden Collins Date: Thu, 14 Mar 2024 16:14:53 -0500 Subject: [PATCH] Handle `reload` workspace events from sway correctly Closes #361 --- modules/i3.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/modules/i3.c b/modules/i3.c index a5af4f8..d62db5e 100644 --- a/modules/i3.c +++ b/modules/i3.c @@ -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", ¤t) || - !json_object_object_get_ex(current, "id", &_current_id)) + if ((!json_object_object_get_ex(json, "current", ¤t) || + !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); }