module/i3: workaround 'workspace init' event being sent twice

Sway 1.4 sends two identical 'workspace init' events when a display is
plugged in.
This commit is contained in:
Daniel Eklöf 2020-04-28 18:56:39 +02:00
parent 3fae6c2734
commit c3b3d6a637
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F

View file

@ -247,13 +247,19 @@ handle_workspace_event(int type, const struct json_object *json, void *_mod)
mtx_lock(&mod->lock); mtx_lock(&mod->lock);
if (is_init) { 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; workspace_add(m, ws);
if (!workspace_from_json(current, &ws)) }
goto err;
workspace_add(m, ws);
} }
else if (is_empty) { else if (is_empty) {