Repository navigation
Conversation
A Repeater compares its model by identity, not by contents: hand it a new array and it destroys every delegate and builds them again, however alike the two arrays are. The row's model was `root.workspaceIds()`, a function call in a binding that allocated a fresh array every time it ran, and it re-ran whenever Hyprland's workspace list changed. `columns:` called the same function a second time. Hyprland's workspace list changes when a workspace is created or destroyed, which is what happens the moment you touch an empty one. Moving between workspaces that hold windows changes nothing and is smooth. Pressing SUPER+4 from an occupied workspace created 4 and rebuilt the whole row, and leaving 4 empty destroyed it and rebuilt the row again. That is why the stutter came and went rather than being there every time. The waste is worse than it first looks. The row always offers 1 through 5, so creating workspace 4 does not change what it draws at all: the ids are [1,2,3,4,5] before and after. Every one of those rebuilds produced an identical row. It only genuinely changes when a workspace outside 1-5 appears or goes away. The ids now live in a property that is replaced only when the ids really differ, so the array's identity survives a change that does not alter the row. The delegate's `workspaceById()` went with it. Each delegate scanned the whole workspace list to find its own workspace, which made drawing the row O(n^2) every time it was rebuilt. The map is now built once per change. The model math moved to WorkspacesModel.js, matching MenuModel.js and NightlightModel.js, so it can be unit tested under node. It also holds a workspace list more defensively than the inline version did: a null entry in Hyprland.workspaces.values used to throw reading `.id`, and a non-numeric id used to be pushed into the row.
Member
|
Automated duplication check: this pull request looks similar to #8794, which covers the same workspace Repeater stability. I keep that one open and close this one to consolidate review. If you feel this is the wrong decision, please open the PR again with a note on the difference. |
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.
Creating or leaving an empty workspace rebuilds the whole workspace row, even when the visible IDs have not changed. The row always includes workspaces 1–5, but
workspaceIds()returns a new array whenever Hyprland's workspace list changes.Repeatertreats that as a new model and replaces every delegate.columnscalls the function again.The row now keeps the same array until its IDs change. Creating workspace 4 leaves
[1,2,3,4,5]intact; creating a workspace outside that range replaces it. A map built once per update also replaces the lookup each delegate used to perform over the workspace list.The ID and lookup logic lives in
WorkspacesModel.js, following the existing model modules so it can run under Node.workspaces-model-test.shchecks the fixed 1–5 range, additional workspaces arriving and leaving, invalid entries, and array identity. It also checks that different IDs with the same length are treated as a change and that the QML uses the stable array and lookup map. The test fails on the baseline, which has no model module../test/shellpassed 218 of 222 files. The four failures (config-test,runtime-smoke-test,snapper-test, andunowned-system-paths-test) also failed on unmodifiedquattro.This touches
Workspaces.qmlalongside #9419's click-dispatch change, so whichever lands second may need rebasing.