Skip to content

Force-clear zombie windows that ignore cooperative close - #13638

Open
AnPod wants to merge 2 commits into
omacom:quattrofrom
AnPod:cursor/fix-close-zombie-window-e0d3
Open

AnPod wants to merge 2 commits into
omacom:quattrofrom
AnPod:cursor/fix-close-zombie-window-e0d3

Conversation

@AnPod

@AnPod AnPod commented Sep 28, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes #13308

Some XWayland/JUCE apps (e.g. Surge XT) quit on Super+W but leave an empty mapped surface.

Change

  • Close cooperatively first, then destroy leftovers so the empty yellow window does not stick

Test plan

  • bash test/shell.d/hyprland-window-close-test.sh

Some XWayland/JUCE apps (e.g. Surge XT) quit their UI on Super+W but leave an
empty mapped surface. Close cooperatively first, then destroy leftover
surfaces so the yellow empty window does not stick around.

Fixes omacom#13308

Co-authored-by: AnPod <AnPod@users.noreply.github.com>
@cursor
cursor Bot force-pushed the cursor/fix-close-zombie-window-e0d3 branch from a8b447f to 84dc880 Compare September 29, 2026 21:11

@chessing234 chessing234 left a comment

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.

please preserve save-confirmation dialogs when closing windows.

Comment thread bin/omarchy-hyprland-window-close Outdated
fi
done

# Still mapped: either the client ignored close, or it died and left a ghost.

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.

please keep ordinary close requests cooperative: a window can still be mapped after 250 ms because it is waiting for the user to answer a save/discard dialog, and this path sends its entire process SIGTERM then SIGKILL (including native wayland clients). gate force-killing on an explicit user action or a positively identified zombie, otherwise super+w can discard unsaved work and close other windows of the same app.

@greptile-apps

greptile-apps Bot commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 4/5

[Medium risk] Changes window close behavior in the desktop environment.

The PR is not ready to merge because its force-clear path leaves the targeted zombie surface mapped.

Findings

  1. P1 Force close never runs ▶
  2. P2 Zombie test misses force close ▶
  3. P2 Query errors look like closure ▶

Summary

The PR routes Super+W and Super+Q through a new script that requests a cooperative close, waits briefly, and attempts to clear a remaining XWayland surface when its PID is gone.

  • The intended force-clear is bypassed by a second successful cooperative dispatch.
  • The zombie test does not distinguish that dispatch from a force-clear.
  • A failed client query is mistaken for a window that has closed.
Diagram
%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Close shortcut] --> B[Cooperative close]
  B --> C{Still mapped after polling?}
  C -- No --> D[Exit]
  C -- Yes --> E{XWayland and PID absent?}
  E -- No --> D
  E -- Yes --> F[Second cooperative close]
  F -- Dispatch succeeds --> D
  F -- Dispatch fails --> G[killwindow]
Loading

Reviews (1) · Last reviewed commit: "Keep window close cooperative and only r..."

Comment on lines +38 to +39
hyprctl dispatch "hl.dsp.window.close({ window = \"address:$addr\" })" >/dev/null 2>&1 ||
hyprctl dispatch killwindow "address:$addr" >/dev/null 2>&1 ||

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.

P1 Force close never runs When an XWayland surface remains mapped after the first close and its PID is gone, this branch sends another cooperative close. That dispatch can succeed even though the surface stays mapped, so || skips killwindow and the empty window remains.

Comment on lines +137 to +142
grep -q 'window.close({ window = "address:0xzombie" })' "$log_file" ||
fail "zombie close still sends an initial close" "log: $(< "$log_file")"
# Second close / killwindow after the surface refused to leave.
closes=$(grep -c '0xzombie' "$log_file" || true)
(( closes >= 2 )) ||
fail "zombie close force-targets the stuck surface" "log: $(< "$log_file")"

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 Zombie test misses force close The mock marks the window closed after any second dispatch, while this assertion only counts uses of the window address. Two cooperative closes therefore pass the test without calling killwindow, leaving the force-clear behavior untested.

Comment on lines +23 to +26
if ! hyprctl clients -j 2>/dev/null | jq -e --arg addr "$addr" \
'any(.[]; .address == $addr)' >/dev/null 2>&1; then
exit 0
fi

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 Query errors look like closure If hyprctl clients -j fails or returns malformed JSON, the failed check is treated as though the window disappeared. The script exits without checking whether a still-mapped surface needs cleanup, and gives no indication that the query failed.

@omarchybot omarchybot added the bug Something isn't working label Oct 1, 2026
@omarchybot

Copy link
Copy Markdown
Collaborator

Thanks for taking this on. I reviewed it at 3e619d6 and it isn't ready yet. Two things stand in the way: the bug doesn't reproduce, and the force path can never run.

The bug didn't reproduce. On a disposable worker built from the Omarchy ISO (Hyprland 0.56.2, surge-xt 1.3.4-7 from extra), I launched Surge XT, focused it and sent the base branch's hl.dsp.window.close() four times. Each time the window was gone from hyprctl clients within a second and its process had exited. No empty window was left. The fix rests on a case where an XWayland surface stays mapped after its process has exited. That isn't how XWayland normally behaves: when an X client exits, its connection closes and its windows are destroyed. A blank window whose process is still alive, but hung, is more likely. The PR leaves that case alone, because a live PID skips the force path at bin/omarchy-hyprland-window-close:31. What would settle it is the leftover window's entry from hyprctl clients -j and the output of pgrep -a surge, taken while the empty window is still showing, from @elallali on #13308 or anyone who can trigger it.

The force path never forces anything (bin/omarchy-hyprland-window-close:37-40). I tested each command on the worker:

  • hl.dsp.window.close({ window = "address:…" }) prints ok and exits 0 even for an address that doesn't exist. So the second close always "succeeds", and neither fallback after it ever runs. It sends the same polite request that was just ignored.
  • hyprctl dispatch killwindow address:… and closewindow address:… are the old syntax. Under the Lua config they fail with a parse error and exit 7. The trailing || true hides that.
  • hl.dsp.window.kill({ window = "address:…" }) is the form that actually kills a window. It removed a test window on the worker.

The zombie test passes either way (test/shell.d/hyprland-window-close-test.sh:126-142). The mock marks the window closed after any second dispatch, and the assertion only counts lines containing the address. Two ignored close requests satisfy it, so it can't tell a forced clear from a repeat.

Scope. Today SUPER+W and SUPER+Q are Hyprland's built-in close. This PR turns every press into a bash script that runs hyprctl and jq, sleeps at least 50 ms before it can exit, and reads the focused window after the key press rather than at it. If focus moves in between, it closes the wrong window. That's a lot of cost on every close for one app's report that hasn't been reproduced. A reproduction should come first. After that, the right size depends on what it shows: an upstream Surge/JUCE or Hyprland fix, or an opt-in force-kill binding for a hung client.

What ran: the PR's hyprland-window-close-test.sh passed 11 of 11 on the worker. ./test/cli passed 88 and failed one (vscode generated theme references current theme file), and that test fails the same way on the base commit 8b4eae6, so it isn't caused by this PR. No competing PR touches this.

Codex Medium reviewed it as a second opinion. It agreed with each point above, but it can read this review's working notes, so it isn't fully independent. It found the focus race and the vacuous zombie test on its own reading. I didn't push anything to the branch, since the bug it fixes isn't established yet. Next step is with the author, or with a reproduction from #13308.

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.

Omarchy window not closing after quitting app

4 participants