Patch settings-only bar config changes in place instead of rebuilding every widget

A shell.json write used to reassign the whole layout, and the module
Repeaters recreate every delegate when their array model changes — so
toggling an inline widget setting (battery percentage, clock format,
tray pinning) tore down and rebuilt every widget on every monitor,
closing any open panel along the way. When the layout structure is
unchanged, hand the new settings to the running widgets instead.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
David Heinemeier Hansson
2026-08-01 15:36:34 -05:00
co-authored by Claude Fable 5
parent c0d4037237
commit 1f10c78c6a
3 changed files with 107 additions and 1 deletions
+26 -1
View File
@@ -350,10 +350,35 @@ Item {
position = normalizePosition(config.position)
setRequestedTransparency(config.transparent === true)
centerAnchor = Util.canonicalWidgetId(config.centerAnchor || "")
layoutConfig = normalizeLayout(config.layout)
// layoutEntries feeds plain JS arrays to the module Repeaters, and QML
// cannot diff those: reassigning layoutConfig rebuilds every widget on
// every monitor. When a shell.json write only changed inline widget
// settings, patch the live layout and running widgets in place instead.
var next = normalizeLayout(config.layout)
var delta = BarModel.inlineSettingsDelta(layoutConfig, next)
if (delta) {
applySettingsDelta(delta)
return
}
layoutConfig = next
barConfigSerial++
}
function applySettingsDelta(delta) {
for (var i = 0; i < delta.length; i++) {
var change = delta[i]
layoutConfig[change.region][change.index] = change.entry
var settings = entrySettings(change.entry)
for (var s = 0; s < moduleSlots.length; s++) {
var slot = moduleSlots[s]
if (!slot || slot.region !== change.region || slot.moduleName !== entryId(change.entry)) continue
var item = slot.activeItem
if (item && "settings" in item) item.settings = settings
}
}
}
onBarConfigChanged: applyBarConfig()
function layoutEntries(region) {