From c3b3d6a6370cc1832f74c4fe2a42d4156169169b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Tue, 28 Apr 2020 18:56:39 +0200 Subject: [PATCH] module/i3: workaround 'workspace init' event being sent twice Sway 1.4 sends two identical 'workspace init' events when a display is plugged in. --- modules/i3.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/modules/i3.c b/modules/i3.c index 00564ad..0f998de 100644 --- a/modules/i3.c +++ b/modules/i3.c @@ -247,13 +247,19 @@ handle_workspace_event(int type, const struct json_object *json, void *_mod) mtx_lock(&mod->lock); if (is_init) { - assert(workspace_lookup(m, current_name) == NULL); + struct workspace *already_exists = workspace_lookup(m, current_name); + if (already_exists != NULL) { + LOG_WARN("workspace 'init' event for already existing workspace: %s", current_name); + workspace_free(*already_exists); + if (!workspace_from_json(current, already_exists)) + goto err; + } else { + struct workspace ws; + if (!workspace_from_json(current, &ws)) + goto err; - struct workspace ws; - if (!workspace_from_json(current, &ws)) - goto err; - - workspace_add(m, ws); + workspace_add(m, ws); + } } else if (is_empty) {