Hold the indicator peek open while the pointer is on the bar (#6663)

* Hold the indicator peek open while the pointer is on the bar

Revealing the hidden indicators widens their section, and a section that
grows can slide a neighbouring widget under a pointer that never moved.
Collapsing the peek on that un-hover narrowed the section again, moved the
neighbour back out, and re-opened the peek, so a pointer resting in the bar
space beside a grown section stuttered the bar until it moved away.

Hold the peek while the pointer is anywhere on the bar and close it only
once the pointer has left, which keeps the reveal-on-empty-space gesture
and drops the feedback loop.

Fixes #6581

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* Assert the whole-bar hover helper does what the peek depends on

The earlier assertions all held against a no-op setBarHovered, which would
leave barHovered false and let the oscillation straight back in. Pin the
assignment and the collapse re-run too, so the helper cannot be emptied
without the suite noticing.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* Let the delayed peek re-check collapse only, never open

The timer assigned centerSectionRevealHeld outright, so it opened the peek
from bar hover alone. A pointer resting on the left section that dipped off
the bar and returned inside 120ms left the timer pending with barHovered
true again, and the indicators revealed without the pointer ever touching
the center section.

Opening stays the center section's own gesture in setCenterSectionHovered.
The timer now only closes what that opened, and the test asserts the
invariant against the whole file rather than one helper body that never
had the offending assignment in it.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* Tally bar hover per monitor instead of sharing one flag

Every screen's bar wrote the same barHovered bool, last writer wins. Sliding
along the top edge from one monitor's bar to the next can deliver the enter
before the leave, leaving the flag false under a live pointer; the collapse
then fired on a peek the user was still hovering, and no further hover change
arrived to correct it until the pointer left and came back.

Counting each surface's hover makes the order irrelevant. A bar destroyed
mid-hover — unplugging a monitor — never sends a leave, so it hands its
tally back on destruction rather than holding the peek open for good.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
Co-authored-by: David Heinemeier Hansson <david@hey.com>
This commit is contained in:
Scott Jones
2026-08-10 19:35:46 +02:00
committed by GitHub
co-authored by Claude Opus 5 David Heinemeier Hansson
parent 199bd01f94
commit 567e24cd90
2 changed files with 90 additions and 1 deletions
+29 -1
View File
@@ -45,6 +45,13 @@ Item {
property bool useTransparentForeground: false
property bool transparent: false
property bool centerSectionHovered: false
// 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
property bool centerSectionRevealHeld: false
property bool centerHoverRevealSuppressed: false
property int barConfigSerial: 0
@@ -559,6 +566,9 @@ Item {
Component.onCompleted: applyBarConfig()
// Revealing the indicators widens their section, which can slide a neighbour
// under a stationary pointer. Collapsing on that un-hover would move it back
// out and re-open the peek, so hold until the pointer leaves the bar.
function setCenterSectionHovered(hovered) {
centerSectionHovered = hovered
if (hovered) {
@@ -569,10 +579,18 @@ Item {
}
}
function setBarHovered(hovered) {
barHoverCount = Math.max(0, barHoverCount + (hovered ? 1 : -1))
if (barHoverCount === 0) centerSectionRevealTimer.restart()
}
Timer {
id: centerSectionRevealTimer
interval: 120
onTriggered: root.centerSectionRevealHeld = root.centerSectionHovered
// Collapse only. Opening the peek is the center section's own gesture, done
// in setCenterSectionHovered, so a timer left pending by a pointer that dipped
// off the bar and came back cannot reveal indicators it never pointed at.
onTriggered: if (!root.centerSectionHovered && !root.barHovered) root.centerSectionRevealHeld = false
}
function run(command) {
@@ -993,6 +1011,16 @@ 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 {
onHoveredChanged: root.setBarHovered(hovered)
// 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 (hovered) root.setBarHovered(false)
}
}
PopupWindow {