Skip to content

Commit

Permalink
fix: discover windows when switching spaces (#1324)
Browse files Browse the repository at this point in the history
  • Loading branch information
lwouis committed Oct 14, 2022
1 parent b72c4db commit 9c26d54
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/logic/Applications.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,16 @@ class Applications {

static func manuallyUpdateWindowsFor2s() {
let group = DispatchGroup()
manuallyUpdateWindows(group)
_ = group.wait(wallTimeout: .now() + .seconds(2))
}

static func manuallyUpdateWindows(_ group: DispatchGroup? = nil) {
for app in list {
if app.runningApplication.isFinishedLaunching && app.runningApplication.activationPolicy != .prohibited {
app.manuallyUpdateWindows(group)
}
}
_ = group.wait(wallTimeout: .now() + .seconds(2))
}

static func initialDiscovery() {
Expand Down
2 changes: 2 additions & 0 deletions src/logic/Spaces.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ class Spaces {
updateCurrentSpace()
// if UI was kept open during Space transition, the Spaces may be obsolete; we refresh them
Windows.list.forEachAsync { $0.updatesWindowSpace() }
// from macos 12.2 beta onwards, we can't get other-space windows; grabbing windows when switching spaces mitigates the issue
Applications.manuallyUpdateWindows()
})
NSWorkspace.shared.notificationCenter.addObserver(forName: NSApplication.didChangeScreenParametersNotification, object: nil, queue: nil, using: { _ in
debugPrint("OS event", "didChangeScreenParametersNotification")
Expand Down

0 comments on commit 9c26d54

Please sign in to comment.