From fcbede75592b4c39e7fa6f92e509a8cb5ead4327 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ole=20J=C3=B8rgen=20Br=C3=B8nner?= Date: Mon, 24 Jun 2019 22:28:26 +0200 Subject: [PATCH] Sync space settings on workspace changes If the indices isn't synced a disable/enable cycle will jumple the workspace names/backgrounds --- tiling.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tiling.js b/tiling.js index b40c78e..f38be7a 100644 --- a/tiling.js +++ b/tiling.js @@ -1366,12 +1366,25 @@ class Spaces extends Map { } } + let nextUnusedWorkspaceIndex = nWorkspaces; for (let [workspace, space] of this) { if (workspaces[space.workspace] !== true) { debug('workspace removed', space.workspace); this.removeSpace(space); + + // Maps in javascript (and thus Spaces) remember insertion order + // so the workspaces are sorted by index. The relative ordering + // of the removed workspaces will thus be preserved when resurrected. + space.settings.set_int('index', nextUnusedWorkspaceIndex); + nextUnusedWorkspaceIndex++; } } + + // Ensure the live spaces have correct indices + for (let [workspace, space] of this) { + space.settings.set_int('index', workspace.index()); + Meta.prefs_change_workspace_name(workspace.index(), space.name); + } }; switchWorkspace(wm, fromIndex, toIndex) {