diff --git a/src/api-wrappers/CGWindowID.swift b/src/api-wrappers/CGWindowID.swift index 58e75da8..6aa7f3c0 100644 --- a/src/api-wrappers/CGWindowID.swift +++ b/src/api-wrappers/CGWindowID.swift @@ -40,7 +40,3 @@ extension CGWindowID { return value as? T } } - -//class Testt { -// static var sampleCgImage: CGImage? = nil -//} diff --git a/src/logic/Applications.swift b/src/logic/Applications.swift index 205890af..484adb7f 100644 --- a/src/logic/Applications.swift +++ b/src/logic/Applications.swift @@ -30,7 +30,9 @@ class Applications { static func addInitialRunningApplicationsWindows() { let otherSpaces = Spaces.otherSpaces() - if otherSpaces.count > 0 { + // the CGSAddWindowsToSpaces trick stopped working starting with macOS 12.2 + // see https://github.com/lwouis/alt-tab-macos/issues/1324 + if otherSpaces.count > 0, #unavailable(macOS 12.2) { let windowsOnCurrentSpace = Spaces.windowsInSpaces([Spaces.currentSpaceId]) let windowsOnOtherSpaces = Spaces.windowsInSpaces(otherSpaces) let windowsOnlyOnOtherSpaces = Array(Set(windowsOnOtherSpaces).subtracting(windowsOnCurrentSpace)) @@ -41,7 +43,7 @@ class Applications { CGSRemoveWindowsFromSpaces(cgsMainConnectionId, windowsOnlyOnOtherSpaces as NSArray, [Spaces.currentSpaceId]) } } else { - Applications.manuallyUpdateWindowsFor2s() + Applications.manuallyUpdateWindows() } } diff --git a/src/ui/App.swift b/src/ui/App.swift index 8ffee2f2..79095d2a 100644 --- a/src/ui/App.swift +++ b/src/ui/App.swift @@ -24,6 +24,7 @@ class App: AppCenterApplication, NSApplicationDelegate { var feedbackWindow: FeedbackWindow! var permissionsWindow: PermissionsWindow! var isFirstSummon = true + var isVeryFirstSummon = true var appIsBeingUsed = false var globalShortcutsAreDisabled = false var shortcutIndex = 0 @@ -75,8 +76,6 @@ class App: AppCenterApplication, NSApplicationDelegate { KeyboardEvents.addEventHandlers() MouseEvents.observe() TrackpadEvents.observe() - // TODO: undeterministic; events in the queue may still be processing; good enough for now - DispatchQueue.main.async { () -> () in Windows.sortByLevel() } self.preloadWindows() #if DEBUG // self.showPreferencesWindow() @@ -281,6 +280,10 @@ class App: AppCenterApplication, NSApplicationDelegate { Logger.debug(shortcutIndex, self.shortcutIndex, isFirstSummon) App.app.appIsBeingUsed = true if isFirstSummon || shortcutIndex != self.shortcutIndex { + if isVeryFirstSummon { + DispatchQueue.main.async { () -> () in Windows.sortByLevel() } + isVeryFirstSummon = false + } isFirstSummon = false self.shortcutIndex = shortcutIndex let screen = NSScreen.preferred()