From 6f720d9c2e5e766679bfaa5f77484be5a393b664 Mon Sep 17 00:00:00 2001 From: enklht Date: Thu, 9 Apr 2026 14:33:17 +0900 Subject: [PATCH 1/2] fix: correct workspace index after deletion and update monitor IDs --- lib/extension/tree.js | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/lib/extension/tree.js b/lib/extension/tree.js index 7d2c169..ff4ec10 100644 --- a/lib/extension/tree.js +++ b/lib/extension/tree.js @@ -363,7 +363,9 @@ export class Node extends GObject.Object { // Since contains() tries to find node on all descendants, // detach only from the immediate parent let parentNode = node.parentNode; - refNode = parentNode.childNodes.splice(node.index, 1); + refNode = parentNode.childNodes[node.index] + + parentNode.childNodes.splice(node.index, 1); refNode.parentNode = null; } if (!refNode) { @@ -709,6 +711,28 @@ export class Tree extends Node { global.window_group.remove_child(existingWsNode.actorBin); this.removeChild(existingWsNode); + + let workspaces = this.nodeWorkpaces; + workspaces.forEach((wsNode) => { + // Extract the current integer index from "ws{n}" + let currentIndex = parseInt(wsNode.nodeValue.replace("ws", "")); + + // If the workspace was after the deleted one, shift it down + if (currentIndex > wsIndex) { + let newIndex = currentIndex - 1; + wsNode._data = `ws${newIndex}`; + + // Also update the IDs of the Monitor children + wsNode.childNodes.forEach((child) => { + if (child.nodeType === NODE_TYPES.MONITOR) { + // Monitor node values look like "mo{m}ws{n}" + let parts = child.nodeValue.split("ws"); + child._data = `${parts[0]}ws${newIndex}`; + } + }); + } + }); + return true; } From 7072133393af19e6b8ac729faf846917d77c321a Mon Sep 17 00:00:00 2001 From: enklht Date: Fri, 10 Apr 2026 11:17:45 +0900 Subject: [PATCH 2/2] refactor: fix formatting issues in tree.js --- lib/extension/tree.js | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/lib/extension/tree.js b/lib/extension/tree.js index ff4ec10..a9a18ba 100644 --- a/lib/extension/tree.js +++ b/lib/extension/tree.js @@ -363,7 +363,7 @@ export class Node extends GObject.Object { // Since contains() tries to find node on all descendants, // detach only from the immediate parent let parentNode = node.parentNode; - refNode = parentNode.childNodes[node.index] + refNode = parentNode.childNodes[node.index]; parentNode.childNodes.splice(node.index, 1); refNode.parentNode = null; @@ -1319,8 +1319,7 @@ export class Tree extends Node { let metaWin = w.nodeValue; try { this.extWm.move(metaWin, w.renderRect); - } catch (e) { - } + } catch (e) {} } else { Logger.debug(`ignoring apply for ${w.renderRect.width}x${w.renderRect.height}`); } @@ -1431,17 +1430,19 @@ export class Tree extends Node { } // Skip windows whose actors were destroyed mid-render - tiledChildren.filter((c) => c.isNodeValid()).forEach((child, index) => { - // A monitor can contain a window or container child - if (node.layout === LAYOUT_TYPES.HSPLIT || node.layout === LAYOUT_TYPES.VSPLIT) { - this.processSplit(node, child, params, index); - } else if (node.layout === LAYOUT_TYPES.STACKED) { - this.processStacked(node, child, params, index); - } else if (node.layout === LAYOUT_TYPES.TABBED) { - this.processTabbed(node, child, params, index); - } - this.processNode(child); - }); + tiledChildren + .filter((c) => c.isNodeValid()) + .forEach((child, index) => { + // A monitor can contain a window or container child + if (node.layout === LAYOUT_TYPES.HSPLIT || node.layout === LAYOUT_TYPES.VSPLIT) { + this.processSplit(node, child, params, index); + } else if (node.layout === LAYOUT_TYPES.STACKED) { + this.processStacked(node, child, params, index); + } else if (node.layout === LAYOUT_TYPES.TABBED) { + this.processTabbed(node, child, params, index); + } + this.processNode(child); + }); } if (node.isWindow()) { @@ -1582,8 +1583,7 @@ export class Tree extends Node { if (child.actor?.border) { borderWidth = child.actor.border.get_theme_node().get_border_width(St.Side.TOP); } - } catch (e) { - } + } catch (e) {} // Make adjustments to the gaps let adjust = 4 * Utils.dpi(); @@ -1608,8 +1608,7 @@ export class Tree extends Node { if (child.tab && !decoration.contains(child.tab)) { try { decoration.add_child(child.tab); - } catch (e) { - } + } catch (e) {} } }