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:
co-authored by
Claude Fable 5
parent
c0d4037237
commit
1f10c78c6a
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user