Add window-closed subscribe event - #2181
Closed
kim-raaschou wants to merge 1 commit into
Closed
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What: New subscribe event
window-closedthat fires when a window is removed from AeroSpace’s model (closed, quit, or otherwise destroyed). It is the symmetric counterpart to the existingwindow-detectedevent.Why: External tools (overlays, status bars, scripts) that subscribe to AeroSpace events currently have no way to detect a window closing.
window-detectedfires 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.
yabaiexposes an equivalentwindow_destroyedsignal.How:
ServerEventType.windowClosed(wire name:window-closed).MacWindow.garbageCollect()— the single point where a window leavesallWindowsMap, so it covers every removal path (close command,kAXUIElementDestroyedNotification, refresh reconciliation) and fires exactly once per window.{"_event":"window-closed","windowId":123,"workspace":"4"}.sendInitialskips this transition-only event.aerospace-subscribe.adoc) and grammar updated; generated cmd-help unchanged (synopsis untouched).Testing:
./build-debug.shand fullswift testpass (382 tests, 0 failures), incl.SubscribeCmdArgsTest.Related: #1514