Skip to content

Fix bar reposition-drag on an empty desktop (#11915) - #12184

Closed
thescurry wants to merge 2 commits into
omacom:quattrofrom
thescurry:cursor/bar-empty-desktop-drag-5800
Closed

thescurry wants to merge 2 commits into
omacom:quattrofrom
thescurry:cursor/bar-empty-desktop-drag-5800

Conversation

@thescurry

Copy link
Copy Markdown

Summary

Fixes #11915

Bar reposition-drag failed with zero mapped windows: after the pointer left the strip, Hyprland dropped the grab on wallpaper, and cancel aborted the move.

  • Screen-based eligibility (no toplevel required)
  • Overlay can take the pointer and finish after strip cancel
  • Handoff arms pointer; Escape / right-click / timeout abort so move cannot stick
  • Windowed path unchanged

Test plan

  • bash test/shell.d/bar-test.sh (incl. arm-on-handoff + abort locks)
  • Empty desktop: drag bar to reposition; release; no stuck overlay
  • With a window open: drag still works

Code QA Pass @ d71d46e (Fail 1 fixed). Fork review: thescurry#3

cursoragent and others added 2 commits September 16, 2026 17:56
The move gesture died with zero mapped clients because leaving the bar
strip handed the pointer to the wallpaper and cancelled the grab.
Eligibility no longer depends on toplevels, and a lost grab is handed
to the move overlay so the edge preview can finish the drag.

Co-authored-by: Steve Curry <thescurry@users.noreply.github.com>
Taking the pointer after a lost grab never armed the overlay, so a
still release at the strip edge left the ghost mapped. Handoff now
arms, a poll finishes a motionless button-up, and Escape, a secondary
click, or a short timeout abort the same stuck state.

Co-authored-by: Steve Curry <thescurry@users.noreply.github.com>
@paulogeyer

Copy link
Copy Markdown
Contributor

Live soak on my laptop (ASUS Vivobook, Intel Arc)

Against #11915 with this PR applied over tip:

Desktop Result
≥1 mapped window (terminal open) PASS — press-and-hold center strip, drag to another edge docks
Empty workspace (no windows) FAIL on this PR as-is — closed-hand appears, then the move dies as soon as the pointer leaves the strip

So the eligibility / “start the gesture without clients” part is real, but the empty-desktop handoff path does not survive Wayland grab cancel on Hyprland here.

What we think is going wrong

  1. False Released after handoff — when the overlay takes the pointer, the strip MouseArea can see a grab-steal as onReleased and call finishBarMove() while barMoveCandidate is still the current edge → immediate no-op clearBarMove(). Guarding onReleased with barMoveTakePointer / handoff-pending fixed the empty path in a local soak.
  2. Overlay mask — Quickshell appears to drive input masks via Region { item: … }. Bare width/height on the ghost Region did not receive motion here; switching to an item:-backed full-screen capture region was required for the overlay to track the pointer after handoff.
  3. Synthetic buttons=0 — right after grab cancel, overlay polls often report no pressed button; treating armed+buttons=0 as “finish” clears the move before the user can aim at another edge. A short handoff-pending / debounce-commit helped.

With those local adjustments (deferred takeBarMovePointer via Qt.callLater, onReleased guard, item: mask, handoff-pending), empty-desktop drag PASSed on the same machine. Clearing the move chrome after a successful dock is expected.

Ask

Please don’t merge on the windowed-only path alone — empty desktop is the bug in #11915. A small follow-up (or revision) covering the handoff/Released/mask issues above would make this solid.

Not a +1 yet for empty-desktop; happy to re-soak after a revision.

@omarchybot

Copy link
Copy Markdown
Collaborator

Reviewed at d71d46e by Claude Opus 5.5, with Codex Medium as a second opinion. Nothing was run on a worker: #12646 is a competing fix for #11915, and both reviews point to it as the one to bring forward, so this one was compared with it by reading the code rather than verified on its own.

Why the handoff here doesn't finish the move on an empty desktop. When the strip loses the grab, takeBarMovePointer() arms the overlay, and applyBarMovePointerButtons() finishes the move the first time it sees no left button (Bar.qml:530-538). The overlay never received the press, though. Qt Wayland clears its button state on wl_pointer.leave, and enter on the ghost doesn't replay it, so the first hover event or 32 ms poll reports buttons = 0 while the button is still held down. The move then finishes at whatever edge was already the candidate, usually the current one, and that is a no-op. This matches @paulogeyer's soak above: it works with a window open and dies on an empty workspace. Codex identified the Qt mechanism, and it holds up against the code. It also pointed out that the poll reads HoverHandler's stored event state rather than the physical button, and that the overlay MouseArea's onReleased can't fire for a press it never saw.

Why #12646. It doesn't hand off the grab at all. The panel that owns the gesture expands to fill its output while the move is active, so the pointer never leaves the surface that holds the press, and the original MouseArea receives the release. That works around the Hyprland behaviour behind the bug (it keeps a pressed surface only while a keyboard-focus surface exists) and needs no button-state guessing. It has open points of its own, which will be raised on that pull request.

One thing applies to both pull requests: barMoveEligible({ mappedClients: [] }) and resolveBarMoveScreen change nothing, because beginBarMove on quattro never gated on mapped clients. The tests that only assert those helpers exist don't guard against the bug either.

This waits on the maintainer to choose between the two. If it's this one, it needs a mechanism that doesn't depend on the overlay seeing button state.

@omarchybot

Copy link
Copy Markdown
Collaborator

Thank you for this, @thescurry. #12646 fixes the same problem in a way the review judged better, so this is closed in favour of it. If it does not cover your case, please say so there.

Closed at the maintainer's request. The review comment above has the details; it was done by Claude Opus 5.5 with Codex Medium as a second opinion, whose agreement is not independent.

@omarchybot omarchybot closed this Oct 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Dragging the bar only works when there is at least 1 window (broken on empty desktop)

4 participants