Skip to content

Remap overlay surfaces after their output is removed - #13792

Open
wesleycole wants to merge 2 commits into
omacom:quattrofrom
wesleycole:fix-overlay-remap-after-output-loss
Open

wesleycole wants to merge 2 commits into
omacom:quattrofrom
wesleycole:fix-overlay-remap-after-output-loss

Conversation

@wesleycole

@wesleycole wesleycole commented Sep 29, 2026 •

Copy link
Copy Markdown

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 summon still returns ok, but no surface is ever shown.

Since #13419, OverlayWindow keeps one surface mapped for the life of the shell. When that surface's output goes away, Hyprland closes the layer surface. Quickshell handles zwlr_layer_surface_v1.closed by calling QWindow::close(), and the proxy then drops to visible: false and deletes its backing window. OverlayWindow's constant visible: true binding is never evaluated again, so the overlay stays unmapped. Per-screen windows like the bar and background are unaffected, because their Variants rebuild them when Quickshell.screens changes.

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, OverlayWindow maps itself again as soon as a real screen exists. A stale targetScreen is 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 with Qt.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:

hyprctl output create headless TEST
hyprctl eval 'hl.monitor({ output = "eDP-1", disabled = true })'
hyprctl output remove TEST        # zero outputs -> FALLBACK
hyprctl reload                    # eDP-1 back
hyprctl layers -j | jq '[.[].levels[][]?.namespace] | unique'
omarchy menu summon
  • Before: after eDP-1 returns, only omarchy-background and omarchy-bar are mapped. omarchy-menu, -osd, -emojis, -clipboard, -image-selector and -reminders are gone, and the menu never opens.
  • After: all overlays map again, first on FALLBACK and 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.sh gets an assertion for the remap. It fails without this change and passes with it. ./test/all shows no new failures: the 11 test files and 1 CLI check that fail on this machine fail the same way on unmodified quattro (they need things like an omarchy-pkgs checkout).

Related: #13163, #13300, #13562

Fixes #13882

@shawnyeager

shawnyeager commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

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 closelayer>>omarchy-menu and closelayer>>omarchy-osd in the same burst as the bar and background. After that output came back, openlayer>>omarchy-bar and openlayer>>omarchy-background fired and openlayer>>omarchy-menu / openlayer>>omarchy-osd never did. With both outputs connected, hyprctl layers has no omarchy-menu surface, and summon still returns ok.

@jdvmi00

jdvmi00 commented Sep 30, 2026

Copy link
Copy Markdown
Contributor

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.

@shawnyeager

Copy link
Copy Markdown
Contributor

The unplug remap and the parked-surface follow are together in #13903, which closes #13882 and #13562.

@jandrusk

jandrusk commented Oct 1, 2026

Copy link
Copy Markdown

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 OverlayWindow.qml PRs (#13792 / #13809 / #13783).

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>
@omarchybot omarchybot added the verified Omarchy Triage has verified that this issue is ready for final review label Oct 3, 2026
@omarchybot

Copy link
Copy Markdown
Collaborator

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 hyprctl output remove. On quattro, omarchy-menu disappears from hyprctl layers and omarchy menu summon shows nothing. At b5eb31b the result was the same, whether the menu was parked or open when its output went away. That matches what @jdvmi00 reported above.

Why the remap didn't take. When the overlay moves to another screen, Quickshell's ProxyWindowBase::setScreen() hides and reshows the window internally. That leaves its requested-visibility flag false while the window is showing. So when the compositor closes the surface, the proxy keeps the old QQuickWindow instead of deleting it. visible = true then shows that same window again, but its layer-shell integration died with its native window. QML reads visible: true, and Hyprland has no layer. Deferring the remap, even by 500 ms, changed nothing.

What changed. remap() now sets visible = false before visible = true (shell/Ui/OverlayWindow.qml:55). This forces Quickshell's delete path, so the show after it builds a fresh window and layer surface. The assertion in test/shell.d/overlay-window-test.sh now requires that line.

Results at 3e6dba9, on the worker:

  • The menu recovered on the remaining output after its output was removed: twice while parked and twice while open. It reopened full size on the overlay layer.
  • The clipboard overlay, open on the removed output, came back on the remaining one.
  • The zero-output case worked: only a headless output, removed, leaving FALLBACK, then the real output restored. Every overlay stayed mapped and the menu opened afterwards.
  • The shell used no CPU over 10 seconds afterwards, so there is no remap loop.
  • test/shell.d/overlay-window-test.sh passes 21 of 21, and fails with OverlayWindow.qml reverted.
  • ./test/cli has one failure, vscode generated theme references current theme file, which fails the same way on quattro.

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 onScreensChanged remap an ordering preference rather than a defect.

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.

@greptile-apps

greptile-apps Bot commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 4/5

[Medium risk] Adds recovery logic for overlay windows when monitors disconnect.

The PR appears safe to merge, with a non-blocking gap in runtime coverage for output-removal recovery.

Findings

  1. P2 Output recovery lacks runtime coverage ▶

Summary

The PR adds recovery for persistent overlay surfaces after their output disappears, guarding remapping until a real screen is available and clearing stale screen selection.

  • Defers recovery after a visibility change and also responds to screen-list changes.
  • Adds a source-level assertion for the new path; it does not exercise output removal at runtime.
Diagram
%%{init: {'theme': 'neutral'}}%%
flowchart LR
  A[Output removed] --> B[Overlay becomes invisible]
  B --> C[Deferred remap]
  D[Screen list changes] --> E[Remap check]
  C --> E
  E --> F{Real screen available?}
  F -->|No| G[Wait for screen change]
  F -->|Yes| H[Clear stale target and remap]
Loading

Reviews (1) · Last reviewed commit: "Hide the overlay before remapping it aft..."

Comment on lines +41 to +46
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'

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 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!

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@jdvmi00

jdvmi00 commented Oct 3, 2026

Copy link
Copy Markdown
Contributor

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 OverlayWindow.qml swapped. I added a headless output, opened the menu on it and removed the output, three times with the menu open and three times parked. On quattro the menu never came back after the first removal. At 3e6dba9 it reappeared on DP-1 and opened full size every time, and the shell sat at 0% CPU afterwards. That covers the case I reported, so the unmap-and-delay patch I offered isn't needed.

#13903's remap() doesn't have the visible = false step, so if these are consolidated there, that line needs to come along.

@londospark

Copy link
Copy Markdown

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 quattro at 81145eb, since the branch is a fair way behind.

Before: every time the monitor slept, aquamarine logged Connector DP-1 disconnected, and the shell logged Layershell screen does not correspond to a real screen and Got removal for monitor "FALLBACK" which was not previously tracked. After that, the menu and every other OverlayWindow overlay were missing from hyprctl layers. omarchy menu summon still returned ok, and only a shell restart brought them back.

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 (hyprctl output create headless / hyprctl output remove). On unmodified quattro the overlay surface stayed gone. With this PR it mapped again on DP-1, opened full-size on the overlay layer, and parked again afterwards. The shell sat at 0% CPU afterwards, so there's no remap loop.

@niendicker

Copy link
Copy Markdown

This matches a real reproduction on my machine and appears to cover issue #13072:

  • Omarchy 4.0.0.r6663.g3faafba-1
  • Hyprland 0.56.2
  • Dell Inspiron 5402, Intel Iris Xe/i915
  • Three active outputs

After locking and unlocking, Super+Space becomes a no-op while Super+W continues to work. The Hyprland binding remains present, there are no config errors, and the menu IPC (ping/summon) still responds. omarchy restart shell restores the menu, which points to the overlay surface rather than the keybinding being lost.

I also ran the focused regression test on this PR head (3e6dba9): all 21 overlay-window assertions pass. The full shell suite has unrelated environment failures because this checkout is not a complete installed Omarchy test environment.

@sprajs

sprajs commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

Opened #14363 as a complete upstream PR for #13882, carrying your remapping commit b5eb31bd and omarchybot's explicit-hide correction 3e6dba91 with original authorship, co-authors and cherry-pick provenance. It adds the compositor-backed tests previously submitted in wesleycole#1 and is based on current quattro (81145eb1).

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.

@omarchybot

Copy link
Copy Markdown
Collaborator

This no longer merges cleanly, and when I checked why, I found that quattro has already fixed the bug a different way. #14458 (0a55a3c, merged today) removed the parked overlay surface that this pull request was keeping alive. OverlayWindow now maps a fresh surface each time it opens (visible: shown && !!targetScreen && !!targetMonitor) and moves an open overlay to a connected screen when its own output goes away (shell/Ui/OverlayWindow.qml:60-74 on quattro). So I haven't ported this branch, and I'd recommend closing it in favour of what landed.

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 quattro at 060c57b, the open menu moved to the remaining output and the menu reopened there in all six cycles. I didn't retest the zero-output case on the worker.

Why not port it. On quattro, visible is a binding. remap() assigns visible = false and then visible = true, which would replace that binding with a constant. And because remap() never checks shown, it could put a closed overlay back on screen. Codex Medium reviewed the same question against the source. It reached the same conclusion, found no case that this branch covers and quattro misses, and raised the shown point. It could read this session's notes, so its agreement isn't guaranteed to be independent.

Thanks for the diagnosis, @wesleycole. Tracing the bug to the layer surface being closed is what the fix on quattro addresses. This is waiting on the maintainer to close it. #13882 should be fixed on quattro too, so it can probably be closed along with this one.

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.

Unplugging a monitor destroys overlay surfaces until the shell restarts

8 participants