Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions shell/Ui/OverlayWindow.qml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,38 @@ PanelWindow {

onShownChanged: if (shown) targetScreen = focusedScreen() || targetScreen

// The compositor closes a layer surface whose output goes away, and
// Quickshell answers by hiding the window for good. Unplugging the monitor
// an overlay last opened on -- or the last monitor, leaving no output at all
// -- would otherwise leave that overlay dead until the shell restarted. Map
// it again once a real screen is there to hold it; Qt's placeholder screen
// is not one, and the compositor would only close the surface again.
function hasRealScreen() {
for (var i = 0; i < Quickshell.screens.length; i++) {
var candidate = Quickshell.screens[i]
if (candidate && candidate.name && candidate.width > 0 && candidate.height > 0) return true
}
return false
}

function remap() {
if (visible || !hasRealScreen()) return
// Quickshell can keep the closed window, whose layer surface is gone, and
// show that again; hiding it explicitly makes it build a fresh one.
visible = false
if (Quickshell.screens.indexOf(targetScreen) < 0) targetScreen = null
visible = true
}

// Deferred: showing the window again inside the close would reuse the
// surface Qt is still tearing down.
onVisibleChanged: if (!visible) Qt.callLater(remap)

Connections {
target: Quickshell
function onScreensChanged() { window.remap() }
}

visible: true
screen: targetScreen
anchors { top: true; left: true; bottom: shown; right: shown }
Expand Down
11 changes: 11 additions & 0 deletions test/shell.d/overlay-window-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,17 @@ assert(
'overlay window follows the focused monitor each time it is shown'
)

// The compositor closes the surface when its output goes away, which hides the
// window for good; it must map again once a real screen is back, or unplugging
// a monitor leaves the menu and its siblings dead until the shell restarts.
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'
Comment on lines +41 to +46

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.

)

const overlays = {
'shell/plugins/menu/Menu.qml': 'shown: root.opened && root.rowsLoaded',
'shell/plugins/emojis/Emojis.qml': 'shown: root.opened',
Expand Down