Skip to content

Fix workspace index and update monitor IDs after deletion#516

Open
enklht wants to merge 2 commits intoforge-ext:mainfrom
enklht:fix-workspace-remove
Open

Fix workspace index and update monitor IDs after deletion#516
enklht wants to merge 2 commits intoforge-ext:mainfrom
enklht:fix-workspace-remove

Conversation

@enklht
Copy link
Copy Markdown

@enklht enklht commented Apr 9, 2026

This PR addresses the layout breaking when a workspace is dynamically deleted by GNOME (#470), and fixes a reference bug related to node detachment.

Fixes #470

Details

workspace index desync on deletion

When an empty workspace is closed, GNOME dynamically deletes it and shifts the indices of the remaining workspaces down.
Previously, the extension's internal tree removed the target workspace node but left the subsequent ws{n} nodes unchanged. This desync caused the window manager to mistakenly group windows from different workspaces into the same container, breaking their fullscreen state.

Fix: Added logic in removeWorkspace to iterate through the remaining workspaces and decrement the IDs (e.g., ws2 -> ws1) of any workspaces and child monitors that come after the deleted index.

dangling parentNode reference in removeChild

While investigating, I noticed a bug in Node.removeChild.
The code was assigning the result of splice() to refNode, and then calling refNode.parentNode = null.
Because splice() returns an array, this was just setting a useless property on the array object, leaving the actual node's parent reference completely intact.

Fix: Extracted the actual node via its index before calling splice(), ensuring the tree reference is properly severed.

Notes

Full disclosure: I personally encountered the issue #470 and wanted to fix, but I don't usually write JavaScript, so I used an AI assistant to help trace the root cause of the tree desync and draft this fix.
I've tested it locally and it resolves the issue described in #470, but I would really appreciate it if an experienced extension could give this a close review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: Closing All Windows In A Workspace Disrupts Tiling In The Next Two Workspaces

1 participant