diff --git a/manual/05-the-top-bar.md b/manual/05-the-top-bar.md index 1eeda96e9814..d03703237800 100644 --- a/manual/05-the-top-bar.md +++ b/manual/05-the-top-bar.md @@ -74,7 +74,7 @@ Removing either service takes its widget back off the bar. ## Indicators -The little cluster in the center is the indicators widget. These are status glyphs for modes you've turned on: do not disturb, night light, a queued [reminder](09-reminders.md), an active screen recording, stay awake, and [dictation](11-text-extraction-dictation.md). They light up when the mode is active and otherwise stay out of the way — hover anywhere on the bar to peek at the inactive ones. Clicking an indicator toggles that mode. One more is status only: a remote session lights up red while someone is connected to this machine through gliff. +The little cluster in the center is the indicators widget. These are status glyphs for modes you've turned on: do not disturb, night light, a queued [reminder](09-reminders.md), an active screen recording, stay awake, and [dictation](11-text-extraction-dictation.md). They light up when the mode is active and otherwise stay out of the way — hover just beside them, where the inactive ones would sit, to peek at those. Clicking an indicator toggles that mode. One more is status only: a remote session lights up red while someone is connected to this machine through gliff. If you'd rather they were always visible, set `alwaysShow` to `true` on the widget. And if you only care about some of them, list the ones you want in `items`: `["Dnd", "Reminder", "NightLight"]`. You can have more than one indicators widget, so different sections can show different subsets. diff --git a/shell/Ui/BarWidget.qml b/shell/Ui/BarWidget.qml index 69fa9b6cf78d..9f858a9d8f48 100644 --- a/shell/Ui/BarWidget.qml +++ b/shell/Ui/BarWidget.qml @@ -11,6 +11,8 @@ import qs.Commons // "start" (left, or top on a vertical bar), "end", or // "center" when it grows both ways. Content laid out // against it stays put while the widget grows. +// inTraySection - whether it sits in the tray's drawer, which already +// hides it until hovered. // // Widgets are free to add their own properties, signals, and child items. Item { @@ -20,6 +22,7 @@ Item { property string moduleName: "" property var settings: ({}) property string fixedEdge: "center" + property bool inTraySection: false // Bar geometry, lifted off the host. Widgets read these constantly to pick // between horizontal/vertical layouts; defining them on the base keeps the diff --git a/shell/Ui/PluginBarApi.qml b/shell/Ui/PluginBarApi.qml index 6400a1e6332e..2d6a84e33efb 100644 --- a/shell/Ui/PluginBarApi.qml +++ b/shell/Ui/PluginBarApi.qml @@ -21,11 +21,8 @@ QtObject { property int barSize: 0 property bool transparent: false property bool foregroundAnimationEnabled: true - property bool centerSectionRevealHeld: false property bool traySectionDragActive: false property bool traySectionPopoutOpen: false - property bool _centerHoverRevealSuppressed: false - readonly property bool centerHoverRevealSuppressed: _centerHoverRevealSuppressed property var activePopout: null property var clickTargets: [] property var layoutConfig: ({}) @@ -43,11 +40,6 @@ QtObject { property var _targetBelongsToWindow: null property var _moduleWidgets: null property var _run: null - property var _setCenterHoverRevealSuppressed: null - - function setCenterHoverRevealSuppressed(value) { - if (_setCenterHoverRevealSuppressed) _setCenterHoverRevealSuppressed(!!value) - } function showTooltip(target, text) { if (_showTooltip) _showTooltip(target, String(text || "")) diff --git a/shell/plugins/bar/Bar.qml b/shell/plugins/bar/Bar.qml index af39ddf27120..b3ebdac9cfcd 100644 --- a/shell/plugins/bar/Bar.qml +++ b/shell/plugins/bar/Bar.qml @@ -60,17 +60,6 @@ Item { // The look the blur behind the bar was last synced for. A background set by // editing shell.json skips the CLI, so the bar syncs Hyprland's blur itself. property string glassSyncedLook: "" - // One bar surface exists per monitor and each reports into this count, so a - // pointer crossing from one monitor's bar to another's stays counted however - // the enter and leave interleave. A single shared bool would be left false by - // whichever event landed last. - property int barHoverCount: 0 - // True while the pointer is over any bar, widgets included. - readonly property bool barHovered: barHoverCount > 0 - // The indicator peek, open while the pointer is on any bar. Plugins read it - // by this name through their bar API. - property bool centerSectionRevealHeld: false - property bool centerHoverRevealSuppressed: false property int barConfigSerial: 0 property string position: "top" // Resolves through fontconfig at paint time (Style.font.family defaults @@ -240,8 +229,6 @@ Item { api.barSize = Qt.binding(function() { return root.barSize }) api.transparent = Qt.binding(function() { return root.transparent }) api.foregroundAnimationEnabled = Qt.binding(function() { return root.foregroundAnimationEnabled }) - api.centerSectionRevealHeld = Qt.binding(function() { return root.centerSectionRevealHeld }) - api._centerHoverRevealSuppressed = Qt.binding(function() { return root.centerHoverRevealSuppressed }) api.traySectionDragActive = Qt.binding(function() { return root.traySectionDragActive }) api.traySectionPopoutOpen = Qt.binding(function() { return root.traySectionPopoutOpen }) root.syncPluginBarApiObjects(api) @@ -385,10 +372,7 @@ Item { return String(requestedId || "") === String(moduleName || "") ? root.moduleWidgets(moduleName) : [] }, - _run: function(command) { root.run(command) }, - _setCenterHoverRevealSuppressed: function(value) { - root.centerHoverRevealSuppressed = !!value - } + _run: function(command) { root.run(command) } }) if (!api) return null root.bindPluginBarApi(api) @@ -1007,34 +991,6 @@ Item { Component.onCompleted: applyBarConfig() - // The indicator peek opens as the pointer comes onto the bar and holds until - // it leaves, or crosses onto the clock at the start of the center box - // (BarModel.peeksAt). Revealing the indicators widens their section, which - // can slide a widget under a stationary pointer, so nothing narrower than the - // stretch of bar up to that edge, held still while the peek is open - // (BarModel.nextPeekEdge), can hold it without opening and closing it in a - // loop. - function setBarHovered(hovered) { - barHoverCount = Math.max(0, barHoverCount + (hovered ? 1 : -1)) - if (barHoverCount > 0) { - centerSectionRevealTimer.stop() - centerSectionRevealHeld = true - } else { - centerSectionRevealTimer.restart() - } - } - - function setCenterHoverRevealSuppressed(value) { - centerHoverRevealSuppressed = !!value - } - - Timer { - id: centerSectionRevealTimer - interval: 120 - // A pointer that dips off the bar and straight back leaves the peek open. - onTriggered: if (!root.barHovered) root.centerSectionRevealHeld = false - } - function run(command) { if (!command) return @@ -1134,7 +1090,7 @@ Item { } // A dragged widget that changes size, as a clock ticking over or the - // indicator peek does, takes its room and its ghost with it. The ghost's + // indicators revealing do, takes its room and its ghost with it. The ghost's // copy of it is taken again once the size settles, rather than on every // frame of a widget animating its size. function resizeBarDrag() { @@ -1773,10 +1729,6 @@ Item { // The same thickness the bar publishes for its screen (screenBarSizes). readonly property int thickness: root.thicknessFor(screen) - // Where the center box starts along the bar, set by the drawn center - // sections. Hovering past it, over the clock, its trailing widgets and the - // right section, leaves the indicator peek shut. - property real peekEdge: 0 // The surface spans its screen at all times, transparent past the strip // it paints; a drag toggles only its input region. Growing the surface @@ -1836,17 +1788,6 @@ Item { Loader { anchors.fill: parent sourceComponent: root.vertical ? verticalBar : horizontalBar - - // A child of the loader, not a sibling of the sections: an ancestor stays - // hovered while the pointer is over a widget, where a sibling would lose - // hover to the section the pointer entered. - HoverHandler { - readonly property bool peeking: hovered && BarModel.peeksAt(point.position, barWindow.peekEdge, root.vertical) - onPeekingChanged: root.setBarHovered(peeking) - // Unplugging a monitor destroys its bar without a leave event, which - // would strand this surface's tally and hold the peek open for good. - Component.onDestruction: if (peeking) root.setBarHovered(false) - } } } @@ -2311,23 +2252,6 @@ Item { implicitWidth: root.vertical ? root.barSize : beginList.width + centerBox.width + endList.width implicitHeight: root.vertical ? beginList.height + centerBox.height + endList.height : root.barSize - // Both placements sit at the bar surface's origin or anchor off its edge, - // so the box's start in the sections is its start on the surface. - readonly property real boxStart: root.vertical ? y + centerBox.y : x + centerBox.x - onBoxStartChanged: syncPeekEdge() - onActiveChanged: syncPeekEdge() - onWindowChanged: syncPeekEdge() - Component.onCompleted: syncPeekEdge() - - function syncPeekEdge() { - if (active && window) window.peekEdge = BarModel.nextPeekEdge(window.peekEdge, boxStart, root.centerSectionRevealHeld) - } - - Connections { - target: root - function onCenterSectionRevealHeldChanged() { sections.syncPeekEdge() } - } - ModuleList { id: beginList keys: sections.active ? root.layoutWidgets.sections.centerBegin : [] @@ -2716,6 +2640,8 @@ Item { readonly property bool dragSource: !!owner && owner.dragSource // The edge it grows from, as the slot that last held it says. property string fixedEdge: "center" + // Whether that slot is in the tray's drawer. + property bool inTraySection: false readonly property string moduleName: root.entryId(entry) readonly property var moduleSettings: root.entrySettings(entry) readonly property string customType: root.customModuleType(entry) @@ -2763,6 +2689,7 @@ Item { return } fixedEdge = owner.fixedEdge + inTraySection = owner.region === "tray" placed = true } // One no slot takes up again by the time the update is over, as one in @@ -2821,6 +2748,7 @@ Item { onActiveItemChanged: Qt.callLater(injectProps) onModuleSettingsChanged: injectProps() onFixedEdgeChanged: injectProps() + onInTraySectionChanged: injectProps() function injectProps() { var target = activeItem @@ -2828,6 +2756,7 @@ Item { // Ahead of bar: a widget can start laying itself out the moment it has // a bar, as the indicators do by reporting which are already active. if ("fixedEdge" in target) target.fixedEdge = fixedEdge + if ("inTraySection" in target) target.inTraySection = inTraySection if ("bar" in target) target.bar = firstParty ? root : root.pluginBarApiFor(pluginApiId, moduleName, registered) if ("moduleName" in target) target.moduleName = moduleName diff --git a/shell/plugins/bar/BarModel.js b/shell/plugins/bar/BarModel.js index 8d3c9d6eaadc..95fcb8f38a1f 100644 --- a/shell/plugins/bar/BarModel.js +++ b/shell/plugins/bar/BarModel.js @@ -653,24 +653,6 @@ function barSizeFor(sizes, screenName, fallback) { return size > 0 ? size : fallback } -// The indicator peek opens over the bar from its start up to where the center -// box starts, and stays shut past it, over the clock and the panel icons. -// `position` is the pointer's point on the bar surface. -function peeksAt(position, edge, vertical) { - if (!position) return false - return (vertical ? position.y : position.x) < edge -} - -// Revealing the indicators can move the center box's start: beside a display -// notch the center sections hang off the right section, so indicators in -// centerEnd or the right section pull it toward the start. An edge that -// followed would slip out from under a stationary pointer and close the peek, -// and closing would slide it back and reopen it. So the edge is measured only -// while the peek is shut and held where it was while it is open. -function nextPeekEdge(edge, measured, held) { - return held ? edge : measured -} - // Whether a workspace holds a real fullscreen window, which fades the bar out // and has to take the clicks along its edge. Hyprland reports a maximized // window as fullscreen 1 and a real one with bit 2 set; only the latter hides @@ -689,8 +671,6 @@ function fullscreenOn(toplevels, workspaceId) { if (typeof module !== "undefined") { module.exports = { barSizeFor: barSizeFor, - nextPeekEdge: nextPeekEdge, - peeksAt: peeksAt, fullscreenOn: fullscreenOn, centerBesideRight: centerBesideRight, cutoutPending: cutoutPending, diff --git a/shell/plugins/bar/widgets/Indicators.qml b/shell/plugins/bar/widgets/Indicators.qml index 82c82f1fcd45..fab88ea5a877 100644 --- a/shell/plugins/bar/widgets/Indicators.qml +++ b/shell/plugins/bar/widgets/Indicators.qml @@ -14,8 +14,13 @@ BarWidget { property var indicatorActiveStates: ({}) property bool indicatorAreaHovered: false property bool indicatorItemHovered: false + // Held a moment after the pointer leaves, so crossing between icons, or a + // frame where the widget moves under a still pointer, doesn't flicker them. + property bool hoverRevealHeld: false readonly property bool alwaysShowIndicators: setting("alwaysShow", false) === true - readonly property bool revealInactiveIndicators: alwaysShowIndicators || indicatorAreaHovered || indicatorItemHovered || (bar && bar.centerSectionRevealHeld === true && bar.centerHoverRevealSuppressed !== true) + // The tray's drawer already hides them until hovered, and an empty widget + // there would leave no room to hover for a second reveal. + readonly property bool revealInactiveIndicators: alwaysShowIndicators || inTraySection || hoverRevealHeld // The active block sits against the widget's fixed edge, and everything that // grows the widget (revealed inactive icons, newly active ones) goes on its // far side, so the icons already showing keep their click targets. A @@ -75,14 +80,18 @@ BarWidget { function setIndicatorAreaHovered(hovered) { indicatorAreaHovered = hovered - if (hovered) indicatorHideTimer.stop() - else indicatorHideTimer.restart() + syncHoverReveal() } function setIndicatorItemHovered(hovered) { - if (hovered) { - indicatorItemHovered = true + indicatorItemHovered = hovered + syncHoverReveal() + } + + function syncHoverReveal() { + if (indicatorAreaHovered || indicatorItemHovered) { indicatorHideTimer.stop() + hoverRevealHeld = true } else { indicatorHideTimer.restart() } @@ -210,10 +219,7 @@ BarWidget { Timer { id: indicatorHideTimer interval: 120 - onTriggered: { - if (!root.indicatorAreaHovered) - root.indicatorItemHovered = false - } + onTriggered: if (!root.indicatorAreaHovered && !root.indicatorItemHovered) root.hoverRevealHeld = false } Component.onCompleted: { @@ -229,6 +235,30 @@ BarWidget { sourceComponent: root.vertical ? verticalIndicatorsTree : horizontalIndicatorsTree } + // Where the hidden icons would show: hovering there reveals them, and the + // rest of the bar leaves them hidden. Hidden, they take no room, so the zone + // reaches past the widget on the side they grow toward. Revealed, it keeps + // half that reach: in the centered box the widget slides half its growth + // back the other way as the box re-centers, and a zone that stopped at the + // widget's edge would lose the pointer that opened it, closing and + // reopening in a loop. Above the icons, which a hover handler doesn't block. + Item { + objectName: "hiddenBlockZone" + + readonly property real reach: (orientationLoader.item ? orientationLoader.item.inactiveLength : 0) * (root.revealInactiveIndicators ? 0.5 : 1) + readonly property real alongStart: root.fixedAtStart ? 0 : -reach + readonly property real alongLength: (root.vertical ? root.implicitHeight : root.implicitWidth) + reach + + x: root.vertical ? 0 : alongStart + y: root.vertical ? alongStart : 0 + width: root.vertical ? root.implicitWidth : alongLength + height: root.vertical ? alongLength : root.implicitHeight + + HoverHandler { + onHoveredChanged: root.setIndicatorAreaHovered(hovered) + } + } + // The two blocks are placed by hand rather than by a Row or Column: a // Column cannot reverse its order, and the inactive area has to go on // whichever side is away from the fixed edge. @@ -236,15 +266,13 @@ BarWidget { id: horizontalIndicatorsTree Item { + readonly property real inactiveLength: inactiveHorizontalBlock.implicitWidth + implicitWidth: activeHorizontalBlock.implicitWidth + inactiveHorizontalArea.implicitWidth implicitHeight: Math.max(activeHorizontalBlock.implicitHeight, inactiveHorizontalArea.implicitHeight) width: implicitWidth height: implicitHeight - HoverHandler { - onHoveredChanged: root.setIndicatorAreaHovered(hovered) - } - Item { id: inactiveHorizontalArea @@ -264,10 +292,6 @@ BarWidget { horizontal: true reportActiveState: !root.vertical } - - HoverHandler { - onHoveredChanged: root.setIndicatorAreaHovered(hovered) - } } ActiveIndicatorBlock { @@ -285,15 +309,13 @@ BarWidget { id: verticalIndicatorsTree Item { + readonly property real inactiveLength: inactiveVerticalBlock.implicitHeight + implicitWidth: Math.max(activeVerticalBlock.implicitWidth, inactiveVerticalArea.implicitWidth) implicitHeight: activeVerticalBlock.implicitHeight + inactiveVerticalArea.implicitHeight width: implicitWidth height: implicitHeight - HoverHandler { - onHoveredChanged: root.setIndicatorAreaHovered(hovered) - } - Item { id: inactiveVerticalArea @@ -313,10 +335,6 @@ BarWidget { horizontal: false reportActiveState: root.vertical } - - HoverHandler { - onHoveredChanged: root.setIndicatorAreaHovered(hovered) - } } ActiveIndicatorBlock { @@ -330,10 +348,6 @@ BarWidget { } } - HoverHandler { - onHoveredChanged: root.setIndicatorAreaHovered(hovered) - } - component ActiveIndicatorBlock: Item { id: activeIndicatorBlockRoot diff --git a/shell/plugins/panels/clock/Panel.qml b/shell/plugins/panels/clock/Panel.qml index 348db12e9ae9..6b9fcd244207 100644 --- a/shell/plugins/panels/clock/Panel.qml +++ b/shell/plugins/panels/clock/Panel.qml @@ -95,18 +95,9 @@ Panel { function open() { refresh() root.controller.show() - // Set after showing, not before: showing hands the popout coordinator - // over, which closes whichever panel was open, and that close clears the - // shared flag. Deferring means the panel taking over always wins, while - // a handoff to a panel that does not manage the flag still leaves it - // cleared rather than stuck on. - Qt.callLater(function() { - if (root.opened) setCenterHoverRevealSuppressed(true) - }) } function close() { - setCenterHoverRevealSuppressed(false) // Dismissing the panel mid-edit would otherwise leave the inputs up, // waiting behind a closed popup for the next time it opens. if (root.editingLife) root.cancelEditingLife() @@ -124,15 +115,6 @@ Panel { return false } - // Summoning by hotkey moves no pointer, so a hover the bar was still - // holding must not keep the center indicators revealed behind the panel. - function setCenterHoverRevealSuppressed(value) { - if (root.bar && typeof root.bar.setCenterHoverRevealSuppressed === "function") - root.bar.setCenterHoverRevealSuppressed(value) - else if (root.bar && "centerHoverRevealSuppressed" in root.bar) - root.bar.centerHoverRevealSuppressed = value - } - function refresh() { root.today = new Date() root.goToToday() diff --git a/shell/plugins/panels/weather/Panel.qml b/shell/plugins/panels/weather/Panel.qml index a1b495147e53..7607a923f810 100644 --- a/shell/plugins/panels/weather/Panel.qml +++ b/shell/plugins/panels/weather/Panel.qml @@ -26,7 +26,6 @@ Panel { function open() { openedFromHotkey = false - setCenterHoverRevealSuppressed(false) root.controller.show() locationFile.reload() root.refresh() @@ -37,18 +36,9 @@ Panel { root.controller.show() locationFile.reload() root.refresh() - // Set after showing, not before: showing hands the popout coordinator - // over, which closes whichever panel was open, and that close clears the - // shared flag. Deferring means the panel taking over always wins, while - // a handoff to a panel that does not manage the flag still leaves it - // cleared rather than stuck on. - Qt.callLater(function() { - if (root.opened) setCenterHoverRevealSuppressed(true) - }) } function close() { - setCenterHoverRevealSuppressed(false) if (root.editingLocation) root.cancelEditingLocation() root.controller.hide() } @@ -64,13 +54,6 @@ Panel { return false } - function setCenterHoverRevealSuppressed(value) { - if (root.bar && typeof root.bar.setCenterHoverRevealSuppressed === "function") - root.bar.setCenterHoverRevealSuppressed(value) - else if (root.bar && "centerHoverRevealSuppressed" in root.bar) - root.bar.centerHoverRevealSuppressed = value - } - // Parsed wttr.in j1 response. Kept on failure so stale data stays visible. property var report: null property var dailyForecastReport: null diff --git a/test/shell.d/bar-test.sh b/test/shell.d/bar-test.sh index a36941383995..4f5708159d84 100644 --- a/test/shell.d/bar-test.sh +++ b/test/shell.d/bar-test.sh @@ -26,14 +26,6 @@ assertEqual(bar.pickDrawnSlot([undrawn]), undrawn, 'bar falls back to an undrawn assertEqual(bar.pickDrawnSlot([]), null, 'bar reports no slot when there are none') assertEqual(bar.pickDrawnSlot(null), null, 'bar tolerates a missing slot list') -// Hovering the clock, or anything past it, leaves the indicators hidden; the -// rest of the bar up to the clock's start opens them. -assertEqual(bar.peeksAt({ x: 400, y: 10 }, 1000, false), true, 'the peek opens left of the clock') -assertEqual(bar.peeksAt({ x: 1200, y: 10 }, 1000, false), false, 'the peek stays shut over and right of the clock') -assertEqual(bar.peeksAt({ x: 1200, y: 400 }, 600, true), true, 'a vertical bar opens the peek above the clock') -assertEqual(bar.peeksAt({ x: 10, y: 800 }, 600, true), false, 'a vertical bar keeps the peek shut below the clock') -assertEqual(bar.peeksAt(null, 1000, false), false, 'no pointer opens no peek') - // The bar drops its input under a real fullscreen window on its workspace, so // the window gets the clicks along the edge; a maximized one keeps the bar. const toplevel = (id, fullscreen) => ({ workspace: { id }, lastIpcObject: { fullscreen } }) @@ -42,22 +34,6 @@ assertEqual(bar.fullscreenOn([toplevel(4, 1)], 4), false, 'a maximized window le assertEqual(bar.fullscreenOn([toplevel(9, 2)], 4), false, 'fullscreen on another workspace leaves the bar clickable') assertEqual(bar.fullscreenOn([{ workspace: null, lastIpcObject: null }], 4), false, 'a toplevel without a workspace is ignored') -// Beside a display notch, indicators right of the clock pull its end toward -// the start as they reveal. A stationary pointer between the two ends has to -// keep the peek open rather than close it, slide the clock back and reopen it. -const notchBoxEnd = revealed => revealed ? 900 : 1000 -function peekRun(pointers) { - let edge = notchBoxEnd(false) - return pointers.map(pointer => { - const held = bar.peeksAt(pointer, edge, false) - edge = bar.nextPeekEdge(edge, notchBoxEnd(held), held) - return held - }) -} -const between = { x: 950, y: 10 } -assertEqual(peekRun([between, between, between, between]).join(), 'true,true,true,true', 'a reveal that moves the clock does not close the peek under a still pointer') -assertEqual(peekRun([between, { x: 1050, y: 10 }, { x: 1050, y: 10 }]).join(), 'true,false,false', 'leaving past the clock closes the peek for good') - // A bar surface is built per monitor, so a panel hotkey has one live copy of // the widget per screen to choose between. const internal = { moduleName: 'omarchy.audio', visible: true, width: 28, height: 81 } diff --git a/test/shell.d/fixtures/indicator-contract/shell.qml b/test/shell.d/fixtures/indicator-contract/shell.qml index b77b956d2640..d849fd982649 100644 --- a/test/shell.d/fixtures/indicator-contract/shell.qml +++ b/test/shell.d/fixtures/indicator-contract/shell.qml @@ -17,6 +17,16 @@ ShellRoot { if (!condition) fail(message) } + function after(interval, callback) { + var timer = Qt.createQmlObject("import QtQuick; Timer {}", root) + timer.interval = interval + timer.triggered.connect(function() { + timer.destroy() + callback() + }) + timer.start() + } + QtObject { id: notificationService property bool doNotDisturb: false @@ -71,8 +81,6 @@ ShellRoot { property color barForeground: "white" property color urgent: "red" property bool foregroundAnimationEnabled: false - property bool centerSectionRevealHeld: false - property bool centerHoverRevealSuppressed: false property var shell: mockShell function run(command) { root.commands.push(String(command)) @@ -157,13 +165,13 @@ ShellRoot { Qt.callLater(function() { root.assertTrue(tray.implicitWidth === 0, "inactive indicator tray starts collapsed") - mockBar.centerSectionRevealHeld = true + tray.setIndicatorAreaHovered(true) Qt.callLater(function() { - root.assertTrue(tray.implicitWidth > 0, "inactive indicator tray expands on center hover") - mockBar.centerSectionRevealHeld = false + root.assertTrue(tray.implicitWidth > 0, "inactive indicator tray expands on hover") + tray.setIndicatorAreaHovered(false) - Qt.callLater(function() { + root.after(200, function() { root.assertTrue(tray.implicitWidth === 0, "inactive indicator tray collapses after hover") tray.destroy() root.checkFixedEdges([["start", false], ["end", false], ["start", true], ["end", true]]) @@ -203,7 +211,7 @@ ShellRoot { function checkInactiveOrders(cases) { if (cases.length === 0) { - writeResult() + checkTraySection(writeResult) return } checkInactiveOrder(cases[0], function() { @@ -211,6 +219,35 @@ ShellRoot { }) } + // In the tray's drawer, an idle widget with its icons hidden takes no room, + // leaving nothing to hover, so there it shows them without one. + function checkTraySection(done) { + notificationService.doNotDisturb = false + remoteSessionService.active = false + nightlightService.setNightlight(false) + idleService.setIdleEnabled(true) + + var component = Qt.createComponent("file://" + rootPath + "/shell/plugins/bar/widgets/Indicators.qml") + var tray = component.createObject(root) + if (!tray) { + fail("tray section: Indicators failed to instantiate: " + component.errorString()) + done() + return + } + tray.fixedEdge = "start" + tray.inTraySection = true + tray.bar = mockBar + tray.moduleName = "omarchy.indicators" + tray.settings = { items: ["Dnd", "NightLight"] } + + Qt.callLater(function() { + root.layOut(tray) + root.assertTrue(tray.implicitWidth > 0, "tray section: idle indicators show without a hover, got width " + tray.implicitWidth) + tray.destroy() + done() + }) + } + // Facing the other way, the widget mirrors its inactive icons along with its // blocks, so they read outward from the active block from either side. // Turning around moves the icons; it builds none of them again. @@ -221,7 +258,6 @@ ShellRoot { remoteSessionService.active = false nightlightService.setNightlight(false) idleService.setIdleEnabled(true) - mockBar.centerSectionRevealHeld = true mockBar.vertical = vertical var component = Qt.createComponent("file://" + rootPath + "/shell/plugins/bar/widgets/Indicators.qml") @@ -236,6 +272,7 @@ ShellRoot { tray.bar = mockBar tray.moduleName = "omarchy.indicators" tray.settings = { items: ids } + tray.setIndicatorAreaHovered(true) function slots() { return ids.map(function(id) { return root.indicatorSlot(tray, "inactive", id) }) @@ -252,7 +289,6 @@ ShellRoot { } function finish() { - mockBar.centerSectionRevealHeld = false mockBar.vertical = false tray.destroy() done() @@ -286,7 +322,6 @@ ShellRoot { remoteSessionService.active = false nightlightService.setNightlight(true) idleService.setIdleEnabled(false) - mockBar.centerSectionRevealHeld = false mockBar.vertical = vertical var component = Qt.createComponent("file://" + rootPath + "/shell/plugins/bar/widgets/Indicators.qml") @@ -319,8 +354,21 @@ ShellRoot { return edge === "start" ? slotSpan.start : extent() - slotSpan.end } + // A span as distances from the fixed edge, which holds still on the bar + // while the widget grows. + function fromEdge(itemSpan) { + return edge === "start" ? itemSpan : { start: extent() - itemSpan.end, end: extent() - itemSpan.start } + } + + function hiddenBlockZone() { + var children = tray.children || [] + for (var i = 0; i < children.length; i++) { + if (children[i].objectName === "hiddenBlockZone") return children[i] + } + return null + } + function finish() { - mockBar.centerSectionRevealHeld = false mockBar.vertical = false idleService.setIdleEnabled(true) tray.destroy() @@ -342,12 +390,21 @@ ShellRoot { } var collapsedExtent = extent() var collapsedDistance = distance(nightLight) - mockBar.centerSectionRevealHeld = true + var zone = hiddenBlockZone() + var hiddenZone = zone ? fromEdge(span(zone)) : null + root.assertTrue(!!zone, label + ": the widget has a hover zone for its hidden icons") + tray.setIndicatorAreaHovered(true) Qt.callLater(function() { root.layOut(tray) var stayAwake = root.indicatorSlot(tray, "inactive", "StayAwake") var revealedDistance = distance(nightLight) + if (hiddenZone && stayAwake) { + var revealedAt = fromEdge(span(stayAwake)) + root.assertTrue(hiddenZone.start <= revealedAt.start && hiddenZone.end >= revealedAt.end, + label + ": hovering where a hidden icon reveals reaches the zone (zone " + hiddenZone.start + "-" + hiddenZone.end + + ", icon " + revealedAt.start + "-" + revealedAt.end + " from the fixed edge)") + } root.assertTrue(extent() > collapsedExtent, label + ": revealing grows the widget") root.assertTrue(revealedDistance === collapsedDistance, label + ": revealing keeps the active icon " + collapsedDistance + "px from the fixed edge, got " + revealedDistance) @@ -360,7 +417,7 @@ ShellRoot { } else { root.fail(label + ": Stay Awake shows in the revealed inactive block") } - mockBar.centerSectionRevealHeld = false + tray.setIndicatorAreaHovered(false) idleService.setIdleEnabled(false) Qt.callLater(function() {