diff --git a/shell/Ui/BarIconButton.qml b/shell/Ui/BarIconButton.qml index e2ea6358..e2af8808 100644 --- a/shell/Ui/BarIconButton.qml +++ b/shell/Ui/BarIconButton.qml @@ -10,6 +10,7 @@ WidgetButton { property real opticalSize: Style.bar.iconCanvas property bool debugOpticalBounds: Quickshell.env("OMARCHY_DEBUG_BAR_ICONS") === "1" readonly property real opticalCenterErrorX: glyph.visible ? glyph.paintedCenterX - opticalCanvas.width / 2 : 0 + readonly property real glyphPaintedWidth: glyph.visible ? glyph.tightWidth : 0 readonly property real glyphBaselineY: glyph.visible ? glyph.baselineY : 0 readonly property int glyphFontSize: glyph.visible ? glyph.renderedFontSize : 0 diff --git a/shell/plugins/panels/power/Panel.qml b/shell/plugins/panels/power/Panel.qml index 6c2fe91a..e03c31f6 100644 --- a/shell/plugins/panels/power/Panel.qml +++ b/shell/plugins/panels/power/Panel.qml @@ -17,6 +17,10 @@ Panel { property int profileIndex: 0 property bool cursorActive: false readonly property bool showPercentage: setting("showPercentage", false) === true + // With the percentage shown the button paints a text block wider than an + // icon, so the open-panel mark takes the painted width instead of the + // icon-sized fraction of the slot the fallback assumes. + readonly property real openPanelIndicatorWidth: showPercentage && !button.vertical ? button.glyphPaintedWidth : 0 readonly property bool batteryPresent: { var device = UPower.displayDevice return !!(device && device.isPresent) diff --git a/test/shell.d/power-test.sh b/test/shell.d/power-test.sh index c51cd46a..4d24f88f 100644 --- a/test/shell.d/power-test.sh +++ b/test/shell.d/power-test.sh @@ -45,4 +45,5 @@ assertEqual( assert(/if \(b === Qt\.RightButton\) root\.togglePercentage\(\)/.test(panelSource), 'power right click toggles the bar percentage') assert(/Object\.assign\([^\n]+showPercentage: !root\.showPercentage[^\n]+\)[\s\S]*updateEntryInline/.test(panelSource), 'power persists the bar percentage setting') assert(/Math\.round\(root\.batteryFraction \* 100\) \+ "% " \+ root\.batteryIcon\(\)/.test(panelSource), 'power places the percentage before the battery icon') +assert(/openPanelIndicatorWidth:.*showPercentage.*button\.glyphPaintedWidth : 0/.test(panelSource), 'power spans the open-panel mark across the painted percentage block') JS