Repository navigation
Remap overlay surfaces after their output is removed - #13792
wesleycole wants to merge 2 commits into
Conversation
Amp-Thread-ID: https://ampcode.com/threads/T-01a0ef47-c8ee-720b-8af8-00d89e8a6d95 Co-authored-by: Amp <amp@ampcode.com>
|
Confirmed on another machine and filed as #13882. Omarchy 4.0.0.r6691.g8b4eae6-1, Quickshell 0.3.1, Hyprland 0.56.2, laptop panel plus one external output. Removing the external output logged |
|
I reproduced this on an RTX 4090 with a Dell monitor. The current patch still left the menu dead after removing a virtual display that had the menu open, even with the Dell connected. Explicitly unmapping the overlay and remapping it after a short delay worked here: three consecutive cycles recovered without restarting the shell. Happy to share the patch if useful. I haven’t tested the zero-output or sleep/wake cases yet. |
|
Triage (not posted): Remapping after output removal is the right diagnosis for dead overlays after unplug (also #13882). #13903 already combines unplug remap with the parked-surface / focus follow from #13809 (#13562), and commenters here report residual failures that #13903 aims to cover. Prefer consolidating on #13903 (or rebasing this into it) rather than landing three overlapping |
Moving the overlay to another screen leaves Quickshell's requested-visibility flag false while the window shows, so when the compositor later closes the surface the proxy keeps the old QQuickWindow instead of deleting it. Setting visible back to true then reuses that window, whose layer-shell integration went with its native window, and nothing reaches the compositor: QML reads visible, Hyprland lists no layer. Setting visible to false first runs the delete path, so the show that follows builds a fresh window and layer surface. Co-Authored-By: Codex Medium <noreply@openai.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Thanks for tracking this down to the layer surface close. The diagnosis is right, but the remap didn't bring the overlay back when one output stayed connected, so I pushed a three-line fix to your branch (3e6dba9). With it, the overlays recover in every case I tried. What was checked. I reproduced it on a worker VM built from the Omarchy ISO (Hyprland 0.56.2, Quickshell 0.3.1) by adding a headless output, opening the menu on it, then removing it with Why the remap didn't take. When the overlay moves to another screen, Quickshell's What changed. Results at 3e6dba9, on the worker:
Second opinion. Codex Medium supplied the mechanism above after reading Quickshell's source against the worker's evidence, and proposed the explicit hide. It then reviewed the pushed head and found nothing more. It judged the synchronous Competing fixes. #13903 carries the same remap and, on the same worker, did not recover with the menu open on the removed output. Its parked case recovered, because its focus following had already moved the surface off that output. #13783 and #13809 don't restore visibility. I've linked #13882, which this fixes. #13562 is a separate bug that this doesn't touch. What's next. This waits on CI and then on the maintainer. Nothing is needed from you. |
|
| assert( | ||
| /onVisibleChanged: if \(!visible\) Qt\.callLater\(remap\)/.test(overlay) && | ||
| /function remap\(\) \{\s*if \(visible \|\| !hasRealScreen\(\)\) return[\s\S]*?visible = false[\s\S]*?visible = true\s*\}/.test(overlay) && | ||
| /target: Quickshell\s*function onScreensChanged\(\) \{ window\.remap\(\) \}/.test(overlay) && | ||
| /candidate\.name && candidate\.width > 0 && candidate\.height > 0/.test(overlay), | ||
| 'overlay window maps again after its output is removed' |
There was a problem hiding this comment.
Output recovery lacks runtime coverage
This assertion only matches text in the QML file. It never removes an output or checks that the overlay appears again, so a broken remap could still pass the test. A compositor-backed check would cover the behavior this change is meant to protect.
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
There was a problem hiding this comment.
Submitted compositor-backed coverage directly to the existing fix branch: wesleycole#1 (test commit 31a3e0e0014a295c13d1256b7b4a677e0a0c265b, based on this PR's exact head 3e6dba9152a4be3e99f8ad196ff89e0eb256c206).
The fixture imports the production OverlayWindow into an isolated nested Hyprland compositor. It removes actual outputs and checks namespace, output, layer, dimensions, keyboard mode and key delivery. All 18 checks passed, including three parked and three open removals per run and loss/restoration of the only output while parked or open. Neither a shell restart nor a plugin reload is used for recovery.
Two negative controls fail at the first parked-output removal with no remaining overlay surface: unchanged current quattro (81145eb1) and this fix with only visible = false removed. This catches the backing-window reuse failure discussed by omarchybot, rather than matching QML source text.
The test PR includes usage, artifact capture and cleanup details. The first-show focus issue #13562 is kept outside this recovery test. The contribution is ready to consolidate here; this review thread should stay open until those tests are integrated and the updated upstream head is reviewed.
There was a problem hiding this comment.
Thanks — this directly addresses the runtime-coverage gap I raised. The nested-compositor fixture is substantially stronger than the source-text assertion: it exercises real output removal/recovery, including zero-output and parked/open cases, while the negative controls demonstrate that the regression is observable without the fix.
Please consolidate 31a3e0e0014a295c13d1256b7b4a677e0a0c265b into this PR, keeping the first-show focus behavior separate as noted. I’ll keep this thread open and re-review once the tests are integrated and the upstream head is updated.
Tip: You can customize Greptile's behavior for this repo with .greptile/rules.md and .greptile/config.json.
|
Tested 3e6dba9 on the machine from my earlier comment (RTX 4090, Dell on DP-1, Hyprland 0.56.2, Quickshell 0.3.1), running the installed shell with only #13903's |
|
Confirming this fixes it on real hardware, for a different trigger than the lid/unplug case in the description: a single DisplayPort monitor that drops its link when it goes into standby. Setup: desktop, NVIDIA RTX 5080, one monitor on DP-1. quickshell 0.3.1-1, hyprland 0.56.2-4. Tested as this PR's two commits cherry-picked onto Before: every time the monitor slept, aquamarine logged After: the same DP-1 disconnect, with the same two shell warnings, happened twice with this applied. All six parked overlays (menu, clipboard, emojis, image-selector, OSD, reminders) were still mapped afterwards, and the menu opened normally, with no restart. I also reproduced it with a headless output ( |
|
This matches a real reproduction on my machine and appears to cover issue #13072:
After locking and unlocking, I also ran the focused regression test on this PR head ( |
|
Opened #14363 as a complete upstream PR for #13882, carrying your remapping commit This is an overlapping, independently mergeable option so the runtime coverage does not depend on a separate merge into the fork before the fix lands upstream. The runtime implementation is the same corrected implementation here. All 18 recovery checks pass, both buggy negative controls fail, and the full current-upstream comparison has no candidate-only failures (baseline failures and an isolated Hermes retry are disclosed in the PR). I closed the test-only fork PR with a redirect to #14363. The separate first-show focus issue #13562 remains outside this recovery change. |
|
This no longer merges cleanly, and when I checked why, I found that What was checked. I reran the reproduction on a worker VM built from the Omarchy ISO, with the shell linked to the tree under test. Each cycle adds a headless output, opens the menu on it, and removes the output, once with the menu closed first and once with it left open, three times each. On the parent of #14458, the menu never came back after the first removal. On Why not port it. On Thanks for the diagnosis, @wesleycole. Tracing the bug to the layer surface being closed is what the fix on |
Unplugging the external monitor with the lid closed leaves the Omarchy menu dead: clicking the bar icon or pressing Super+Space does nothing until the shell is restarted. The same happens to every other overlay built on
OverlayWindow(OSD, emojis, clipboard, image picker, reminders, Wi-Fi QR).omarchy menu summonstill returnsok, but no surface is ever shown.Since #13419,
OverlayWindowkeeps one surface mapped for the life of the shell. When that surface's output goes away, Hyprland closes the layer surface. Quickshell handleszwlr_layer_surface_v1.closedby callingQWindow::close(), and the proxy then drops tovisible: falseand deletes its backing window.OverlayWindow's constantvisible: truebinding is never evaluated again, so the overlay stays unmapped. Per-screen windows like the bar and background are unaffected, because theirVariantsrebuild them whenQuickshell.screenschanges.This affects more than the no-outputs case. Removing whichever output an overlay last opened on (an external monitor unplugged with the lid open, for example) kills that overlay as well.
The fix: when the window goes invisible, and whenever the screen list changes,
OverlayWindowmaps itself again as soon as a real screen exists. A staletargetScreenis cleared first, so the compositor picks the output. Qt's nameless placeholder screen doesn't count as a real screen, because a surface created for it would only be closed again. The remap is deferred withQt.callLater, so a new surface isn't created in the middle of Qt tearing down the old one.Reproduction and verification
Verified on Hyprland with a patched shell, using a headless output so the screen only goes dark for a few seconds:
omarchy-backgroundandomarchy-barare mapped.omarchy-menu,-osd,-emojis,-clipboard,-image-selectorand-remindersare gone, and the menu never opens.FALLBACKand then on eDP-1, and the menu opens full size. The lid-open case also recovers: an overlay whose output is removed while another output remains maps again. The shell idles at about 1.6% CPU afterwards, so there's no remap loop.test/shell.d/overlay-window-test.shgets an assertion for the remap. It fails without this change and passes with it../test/allshows no new failures: the 11 test files and 1 CLI check that fail on this machine fail the same way on unmodifiedquattro(they need things like anomarchy-pkgscheckout).Related: #13163, #13300, #13562
Fixes #13882