Fix workspace index and update monitor IDs after deletion#516
Open
enklht wants to merge 2 commits intoforge-ext:mainfrom
Open
Fix workspace index and update monitor IDs after deletion#516enklht wants to merge 2 commits intoforge-ext:mainfrom
enklht wants to merge 2 commits intoforge-ext:mainfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
removeChildWhile investigating, I noticed a bug in
Node.removeChild.The code was assigning the result of
splice()torefNode, and then callingrefNode.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.