Skip to content

Add window-closed subscribe event - #2181

Closed
kim-raaschou wants to merge 1 commit into
nikitabobko:mainfrom
kim-raaschou:feature/window-closed-event
Closed

Add window-closed subscribe event#2181
kim-raaschou wants to merge 1 commit into
nikitabobko:mainfrom
kim-raaschou:feature/window-closed-event

Conversation

@kim-raaschou

Copy link
Copy Markdown

What: New subscribe event window-closed that fires when a window is removed from AeroSpace’s model (closed, quit, or otherwise destroyed). It is the symmetric counterpart to the existing window-detected event.

Why: External tools (overlays, status bars, scripts) that subscribe to AeroSpace events currently have no way to detect a window closing. window-detected fires on creation, but nothing fires on removal, so subscribers keep showing windows that no longer exist until an unrelated event (e.g. the next focus change) happens to trigger a refresh. macOS provides no reliable higher-level close signal, and AeroSpace already owns the authoritative removal point, so the event is cheapest and most correct to emit here.

Use case: a companion overview/HUD that mirrors the current window set. Without this event, closing a background window (no focus change) leaves a stale tile until something else happens. yabai exposes an equivalent window_destroyed signal.

How:

  • New ServerEventType.windowClosed (wire name: window-closed).
  • Broadcast from MacWindow.garbageCollect() — the single point where a window leaves allWindowsMap, so it covers every removal path (close command, kAXUIElementDestroyedNotification, refresh reconciliation) and fires exactly once per window.
  • Payload: {"_event":"window-closed","windowId":123,"workspace":"4"}.
  • sendInitial skips this transition-only event.
  • Docs (aerospace-subscribe.adoc) and grammar updated; generated cmd-help unchanged (synopsis untouched).

Testing: ./build-debug.sh and full swift test pass (382 tests, 0 failures), incl. SubscribeCmdArgsTest.

Related: #1514

What: New subscribe event 'window-closed' that fires when a window is
removed from AeroSpace's model (closed, quit, or otherwise destroyed).

Why: External tools (overlays, status bars) subscribing to AeroSpace
events have no way to detect a window closing. AeroSpace emits
'window-detected' on creation but nothing on removal, so subscribers keep
showing windows that no longer exist until an unrelated event happens to
trigger a refresh. macOS provides no higher-level close signal, and
AeroSpace already owns the authoritative removal point, so the event
belongs here.

How:
- New ServerEventType.windowClosed (wire: 'window-closed')
- Broadcast from MacWindow.garbageCollect() — the single point where a
  window leaves allWindowsMap, so it covers every removal path (close
  command, kAXUIElementDestroyedNotification, refresh reconciliation) and
  fires exactly once per window
- Payload: {"_event":"window-closed","windowId":123,"workspace":"4"}
- sendInitial skips this transition-only event

Symmetric with the existing 'window-detected' event.

nikitabobko#1514

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
kim-raaschou added a commit to kim-raaschou/AeroControl that referenced this pull request Jul 16, 2026
Remove the implemented "App version in menu" and "Verification gates"
sections and the YAGNI / Retired-plans appendices. Add section 3
documenting the dead-tile-on-close push fix: the upstream window-closed
event (PR nikitabobko/AeroSpace#2181) plus the local permission-free
mouse-up doorbell + app-quit retry. No polling.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant