Skip to content

Commit 7020a6e

Browse files
dhhclaude
andcommitted
Span the power widget's open-panel mark across the percentage block
The widget declared no indicator hint, so the mark fell back to 55% of the slot — sized for a lone icon, too short once the percentage doubles the block. Hint the glyph's painted width, the way the clock hints its label width. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent 1f10c78 commit 7020a6e

3 files changed

Lines changed: 6 additions & 0 deletions

File tree

‎shell/Ui/BarIconButton.qml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ WidgetButton {
1010
property real opticalSize: Style.bar.iconCanvas
1111
property bool debugOpticalBounds: Quickshell.env("OMARCHY_DEBUG_BAR_ICONS") === "1"
1212
readonly property real opticalCenterErrorX: glyph.visible ? glyph.paintedCenterX - opticalCanvas.width / 2 : 0
13+
readonly property real glyphPaintedWidth: glyph.visible ? glyph.tightWidth : 0
1314
readonly property real glyphBaselineY: glyph.visible ? glyph.baselineY : 0
1415
readonly property int glyphFontSize: glyph.visible ? glyph.renderedFontSize : 0
1516

‎shell/plugins/panels/power/Panel.qml‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ Panel {
1717
property int profileIndex: 0
1818
property bool cursorActive: false
1919
readonly property bool showPercentage: setting("showPercentage", false) === true
20+
// With the percentage shown the button paints a text block wider than an
21+
// icon, so the open-panel mark takes the painted width instead of the
22+
// icon-sized fraction of the slot the fallback assumes.
23+
readonly property real openPanelIndicatorWidth: showPercentage && !button.vertical ? button.glyphPaintedWidth : 0
2024
readonly property bool batteryPresent: {
2125
var device = UPower.displayDevice
2226
return !!(device && device.isPresent)

‎test/shell.d/power-test.sh‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,5 @@ assertEqual(
4545
assert(/if \(b === Qt\.RightButton\) root\.togglePercentage\(\)/.test(panelSource), 'power right click toggles the bar percentage')
4646
assert(/Object\.assign\([^\n]+showPercentage: !root\.showPercentage[^\n]+\)[\s\S]*updateEntryInline/.test(panelSource), 'power persists the bar percentage setting')
4747
assert(/Math\.round\(root\.batteryFraction \* 100\) \+ "% " \+ root\.batteryIcon\(\)/.test(panelSource), 'power places the percentage before the battery icon')
48+
assert(/openPanelIndicatorWidth:.*showPercentage.*button\.glyphPaintedWidth : 0/.test(panelSource), 'power spans the open-panel mark across the painted percentage block')
4849
JS

0 commit comments

Comments
 (0)