Skip to content
Closed
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
4 changes: 4 additions & 0 deletions Sources/AppBundle/model/ServerEvent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,8 @@ public struct ServerEvent: Codable, Sendable {
public static func bindingTriggered(mode: String, binding: String) -> ServerEvent {
ServerEvent(_event: .bindingTriggered, mode: mode, binding: binding)
}

public static func windowClosed(windowId: UInt32, workspace: String?) -> ServerEvent {
ServerEvent(_event: .windowClosed, windowId: windowId, workspace: workspace)
}
}
2 changes: 1 addition & 1 deletion Sources/AppBundle/subscriptions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func handleSubscribeAndWaitTillError(_ connection: NWConnection, _ args: Subscri
workspace: f.workspace.name,
monitorId_oneBased: f.workspace.workspaceMonitor.monitorId_oneBased ?? 0,
)
case .windowDetected, .bindingTriggered: continue
case .windowDetected, .bindingTriggered, .windowClosed: continue
}
if await connection.writeAtomic(event, jsonEncoder).error != nil {
return
Expand Down
1 change: 1 addition & 0 deletions Sources/AppBundle/tree/MacWindow.swift
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ final class MacWindow: Window {
if !skipClosedWindowsCache { cacheClosedWindowIfNeeded() }
let parent = unbindFromParent().parent
let deadWindowWorkspace = parent.nodeWorkspace
broadcastEvent(.windowClosed(windowId: windowId, workspace: deadWindowWorkspace?.name))
let focus = focus
if let deadWindowWorkspace, deadWindowWorkspace == focus.workspace ||
deadWindowWorkspace == prevFocusedWorkspace && prevFocusedWorkspaceDate.distance(to: .now) < 1
Expand Down
2 changes: 1 addition & 1 deletion Sources/AppBundleTests/command/SubscribeCmdArgsTest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ final class SubscribeCmdArgsTest: XCTestCase {
case .failure(let err):
let expectedMsg = """
ERROR: Can't parse 'unknown-event'.
Possible values: (focus-changed|focused-monitor-changed|focused-workspace-changed|mode-changed|window-detected|binding-triggered)
Possible values: (focus-changed|focused-monitor-changed|focused-workspace-changed|mode-changed|window-detected|binding-triggered|window-closed)
"""
assertEquals(err, .init(expectedMsg, 2))
}
Expand Down
1 change: 1 addition & 0 deletions Sources/Common/cmdArgs/impl/SubscribeCmdArgs.swift
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,5 @@ public enum ServerEventType: String, Codable, CaseIterable, Sendable {
case modeChanged = "mode-changed"
case windowDetected = "window-detected"
case bindingTriggered = "binding-triggered"
case windowClosed = "window-closed"
}
2 changes: 2 additions & 0 deletions docs/aerospace-subscribe.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ window-detected:: Fired when a new window is detected. Includes `windowId`, `wor

binding-triggered:: Fired when a keyboard binding is triggered. Includes `binding`, `mode`.

window-closed:: Fired when a window is closed. Includes `windowId`, `workspace`.

// =========================================================== Output Format
include::util/conditional-output-format-header.adoc[]

Expand Down
2 changes: 1 addition & 1 deletion grammar/commands-bnf-grammar.txt
Original file line number Diff line number Diff line change
Expand Up @@ -152,4 +152,4 @@ aerospace -h;
<pid> ::= {{{ aerospace list-apps --format '%{app-pid}%{tab}%{app-name}' }}};
<monitor_id> ::= all | mouse | focused | {{{ aerospace list-monitors --format '%{monitor-id}%{tab}%{monitor-name}' }}};

<event> ::= focus-changed | focused-monitor-changed | focused-workspace-changed | mode-changed | window-detected | binding-triggered;
<event> ::= focus-changed | focused-monitor-changed | focused-workspace-changed | mode-changed | window-detected | binding-triggered | window-closed;
Loading