Skip to content

Commit

Permalink
fix: quitting multiple apps would refresh the ui multiple times
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 9ca28eb commit bfc2700
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions alt-tab-macos/logic/Applications.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,17 @@ class Applications {
// some apps never finish launching; the observer leaks for them without this
app.removeObserver()
Applications.map.removeValue(forKey: runningApp.processIdentifier)
guard Windows.listRecentlyUsedFirst.count > 0 else { (App.shared as! App).hideUi(); return }
// TODO: implement of more sophisticated way to decide which thumbnail gets focused on app quit
Windows.focusedWindowIndex = 1
(App.shared as! App).refreshOpenUi()
}
// sometimes removed `runningApps` are already terminated by the time they reach this method so we can't match their pid in `Applications.map` above
// we need to remove them based on their lack of `bundleIdentifier`
if someAppsAreAlreadyTerminated {
Windows.listRecentlyUsedFirst.removeAll(where: { $0.application.runningApplication.bundleIdentifier == nil })
Applications.map = Applications.map.filter { $0.value.runningApplication.bundleIdentifier != nil }
}
guard Windows.listRecentlyUsedFirst.count > 0 else { (App.shared as! App).hideUi(); return }
// TODO: implement of more sophisticated way to decide which thumbnail gets focused on app quit
Windows.focusedWindowIndex = 1
(App.shared as! App).refreshOpenUi()
}

private static func filterApplications(_ apps: [NSRunningApplication]) -> [NSRunningApplication] {
Expand Down

0 comments on commit bfc2700

Please sign in to comment.