Skip to content

Commit

Permalink
fix: initial discovery when single space was glitching the os
Browse files Browse the repository at this point in the history
  • Loading branch information
louis.pontoise authored and lwouis committed Mar 10, 2020
1 parent a3c0fe8 commit 3cd4b6d
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions alt-tab-macos/logic/Applications.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,25 @@ class Applications {

static func addInitialRunningApplicationsWindows() {
// on initial launch, we use private APIs to bring windows from other spaces into the current space, observe them, then remove them from the current space
let windows = Spaces.windowsInSpaces(Spaces.otherSpaces()).filter { window in
let spaces = Spaces.otherSpaces()
if spaces.count == 0 {
Windows.sortByLevel()
return
}
let windows = Spaces.windowsInSpaces(spaces).filter { window in
return Windows.list.first(where: { $0.cgWindowId == window }) == nil
}
CGSAddWindowsToSpaces(cgsMainConnectionId, windows as NSArray, [Spaces.currentSpaceId])
for app in list {
guard app.runningApplication.isFinishedLaunching else { continue }
app.observeNewWindows()
if windows.count > 0 {
CGSAddWindowsToSpaces(cgsMainConnectionId, windows as NSArray, [Spaces.currentSpaceId])
for app in list {
guard app.runningApplication.isFinishedLaunching else { continue }
app.observeNewWindows()
}
Windows.sortByLevel()
CGSRemoveWindowsFromSpaces(cgsMainConnectionId, windows as NSArray, [Spaces.currentSpaceId])
return
}
Windows.sortByLevel()
CGSRemoveWindowsFromSpaces(cgsMainConnectionId, windows as NSArray, [Spaces.currentSpaceId])
}

static func addRunningApplications(_ runningApps: [NSRunningApplication]) {
Expand Down

0 comments on commit 3cd4b6d

Please sign in to comment.