Skip to content

Commit

Permalink
fix: open alt-tab during space transitions (closes #92)
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 f8e1b00 commit 141562d
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 3 deletions.
3 changes: 3 additions & 0 deletions alt-tab-macos/logic/Spaces.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ class Spaces {
static func observeSpaceChanges() {
NSWorkspace.shared.notificationCenter.addObserver(forName: NSWorkspace.activeSpaceDidChangeNotification, object: nil, queue: nil, using: { _ in
updateCurrentSpace()
let app = App.shared as! App
guard app.appIsBeingUsed else { return }
app.reopenUi()
})
}

Expand Down
4 changes: 2 additions & 2 deletions alt-tab-macos/logic/SystemPermissions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class SystemPermissions {
"Please authorize and re-launch.",
"See https://help.rescuetime.com/article/59-how-do-i-enable-accessibility-permissions-on-mac-osx",
separator: "\n")
NSApp.terminate(self)
App.shared.terminate(self)
}
}

Expand All @@ -22,7 +22,7 @@ class SystemPermissions {
"Please authorize and re-launch.",
"See https://dropshare.zendesk.com/hc/en-us/articles/360033453434-Enabling-Screen-Recording-Permission-on-macOS-Catalina-10-15-",
separator: "\n")
NSApp.terminate(self)
App.shared.terminate(self)
}
}
}
7 changes: 7 additions & 0 deletions alt-tab-macos/ui/App.swift
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,13 @@ class App: NSApplication, NSApplicationDelegate, NSWindowDelegate {
}
}

func reopenUi() {
thumbnailsPanel!.orderOut(nil)
Windows.refreshAllThumbnails()
refreshOpenUi()
thumbnailsPanel!.show()
}

func refreshOpenUi() {
guard appIsBeingUsed else { return }
let currentScreen = Screen.preferred() // fix screen between steps since it could change (e.g. mouse moved to another screen)
Expand Down
2 changes: 1 addition & 1 deletion alt-tab-macos/ui/PreferencesWindow.swift
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ class PreferencesWindow: NSWindow, NSWindowDelegate {
throw NSError.make(domain: "Preferences", message: "Please enter a valid value for '" + key + "'")
}
try Preferences.updateAndValidateFromString(key, newValue)
(NSApp as! App).initPreferencesDependentComponents()
(App.shared as! App).initPreferencesDependentComponents()
try Preferences.saveRawToDisk()
} catch let error {
debugPrint("PreferencesWindow: save: error", key, newValue, error)
Expand Down

0 comments on commit 141562d

Please sign in to comment.