From 17b461c3e96a22cb6d4a1db079d8ab02383655c7 Mon Sep 17 00:00:00 2001 From: mattchristenson Date: Tue, 29 Sep 2026 21:39:59 -0500 Subject: [PATCH] fix: don't auto-split again for windows Forge already tracks After a workspace is added or removed, workareas-changed re-tracks every window (trackCurrentWindows), and trackWindow() ran the auto-split for the focused window each time, also for windows already in the tree: the focused window was wrapped in one more container per window re-tracked (the path in #540's stack trace). Auto-split only when a window is new to the tree. Also guard Node.set rect against a null rect for containers, as proposed in #540: a container split off a window that was never laid out has no rect until the next render. Fixes #540 Co-Authored-By: Claude Opus 5.5 --- lib/extension/tree.js | 4 +++- lib/extension/window.js | 6 +++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/extension/tree.js b/lib/extension/tree.js index ea957d29..903457af 100644 --- a/lib/extension/tree.js +++ b/lib/extension/tree.js @@ -125,7 +125,9 @@ export class Node extends GObject.Object { case NODE_TYPES.MONITOR: case NODE_TYPES.ROOT: case NODE_TYPES.WORKSPACE: - if (this.actor) { + // (a container split off a window that was never laid out gets no rect until the next + // render, #540) + if (this.actor && rect) { this.actor.set_size(rect.width, rect.height); this.actor.set_position(rect.x, rect.y); } diff --git a/lib/extension/window.js b/lib/extension/window.js index 61820e1e..8335489d 100644 --- a/lib/extension/window.js +++ b/lib/extension/window.js @@ -1408,7 +1408,11 @@ export class WindowManager extends GObject.Object { */ trackWindow(_display, metaWindow) { let autoSplit = this.ext.settings.get_boolean("auto-split-enabled"); - if (autoSplit && this.focusMetaWindow) { + // Only for a window that is new to the tree: trackCurrentWindows() re-tracks every window + // after a workspace is added or removed, and splitting again for each of them wrapped the + // focused window in one more container each time (#540) + const isNewWindow = this._validWindow(metaWindow) && !this.tree.findNode(metaWindow); + if (autoSplit && isNewWindow && this.focusMetaWindow) { let currentFocusNode = this.tree.findNode(this.focusMetaWindow); if (currentFocusNode) { let currentParentFocusNode = currentFocusNode.parentNode;