Make the open-panel mark find and fit its module
A center-anchored module is mounted twice: the copy that is drawn, and a zero-size placeholder holding its place in the flow beside the anchor. findPanelWidget returned whichever registered first, and that order is not stable across a live bar reconfiguration, so a panel could open anchored to the invisible copy -- mispositioned, with the drawn slot never lighting up and switchPanelFrom unable to find it again. The mark was also always 55% of the slot, which fits an icon but underlines only a fraction of a text label, and runs the full height of a multi-line module on a vertical bar. Modules can now say how long the mark should be along the bar; anything that does not answer keeps the old proportion. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5
parent
d4c835afb5
commit
6d4fa7acaf
@@ -15,7 +15,47 @@ fi
|
||||
pass "bar move outline has no post-release settling state"
|
||||
|
||||
run_node_test <<'JS'
|
||||
const fs = require('fs')
|
||||
const bar = requireFromRoot('shell/plugins/bar/BarModel.js')
|
||||
const barSource = fs.readFileSync(root + '/shell/plugins/bar/Bar.qml', 'utf8')
|
||||
|
||||
// A center module is mounted twice — drawn copy plus zero-size placeholder —
|
||||
// and the order they register in is not stable across a live reconfiguration,
|
||||
// so panel routing has to pick the one that is actually on screen.
|
||||
const drawn = { moduleName: 'omarchy.clock', visible: true, width: 28, height: 81 }
|
||||
const placeholder = { moduleName: 'omarchy.clock', visible: false, width: 0, height: 0 }
|
||||
assertEqual(bar.isDrawnSlot(drawn), true, 'bar recognises a drawn slot')
|
||||
assertEqual(bar.isDrawnSlot(placeholder), false, 'bar recognises a layout placeholder')
|
||||
assertEqual(bar.pickDrawnSlot([placeholder, drawn]), drawn, 'bar picks the drawn slot when the placeholder registers first')
|
||||
assertEqual(bar.pickDrawnSlot([drawn, placeholder]), drawn, 'bar picks the drawn slot when it registers first')
|
||||
assertEqual(bar.pickDrawnSlot([placeholder]), placeholder, 'bar falls back to the placeholder when nothing is drawn')
|
||||
assertEqual(bar.pickDrawnSlot([]), null, 'bar reports no slot when there are none')
|
||||
assertEqual(bar.pickDrawnSlot(null), null, 'bar tolerates a missing slot list')
|
||||
assert(
|
||||
/BarModel\.pickDrawnSlot\(candidates\)/.test(barSource),
|
||||
'bar routes panels through the drawn-slot picker'
|
||||
)
|
||||
|
||||
// The open-panel mark sits on the module's desktop-facing edge at every
|
||||
// position: under a top bar, over a bottom one, inward from left and right.
|
||||
const indicator = barSource.slice(barSource.indexOf('id: openPanelIndicator'), barSource.indexOf('id: openPanelIndicator') + 1600)
|
||||
assert(
|
||||
/x: root\.vertical\s*\n\s*\? \(root\.position === "left" \? parent\.width - width - inset : inset\)/.test(indicator),
|
||||
'bar pins the open-panel mark to the desktop-facing edge on vertical bars'
|
||||
)
|
||||
assert(
|
||||
/root\.position === "top" \? parent\.height - height - inset : inset/.test(indicator),
|
||||
'bar pins the open-panel mark to the desktop-facing edge on horizontal bars'
|
||||
)
|
||||
assert(
|
||||
/key in activeItem/.test(barSource),
|
||||
'bar asks whether a widget declares an indicator hint before reading it'
|
||||
)
|
||||
assert(
|
||||
/width: root\.vertical \? Style\.space\(2\) : slot\.panelIndicatorExtent/.test(indicator) &&
|
||||
/height: root\.vertical \? slot\.panelIndicatorExtent : Style\.space\(2\)/.test(indicator),
|
||||
'bar sizes the open-panel mark from the same content hint on both axes'
|
||||
)
|
||||
|
||||
assertEqual(bar.normalizePosition('left'), 'left', 'bar accepts valid positions')
|
||||
assertEqual(bar.normalizePosition('sideways'), 'top', 'bar defaults invalid positions')
|
||||
|
||||
Reference in New Issue
Block a user