mirror of
https://github.com/lwouis/alt-tab-macos.git
synced 2026-05-24 11:20:36 +00:00
fix: focusing an app could open another version of it
This commit is contained in:
+11
-8
@@ -175,17 +175,20 @@ class Window {
|
||||
}
|
||||
|
||||
func focus() {
|
||||
if isWindowlessApp || cgWindowId == nil {
|
||||
if let bundleID = application.runningApplication.bundleIdentifier {
|
||||
NSWorkspace.shared.launchApplication(withBundleIdentifier: bundleID, additionalEventParamDescriptor: nil, launchIdentifier: nil)
|
||||
} else {
|
||||
application.runningApplication.activate(options: .activateIgnoringOtherApps)
|
||||
}
|
||||
Windows.previewFocusedWindowIfNeeded()
|
||||
} else if let bundleID = application.runningApplication.bundleIdentifier, bundleID == App.id {
|
||||
let bundleUrl = application.runningApplication.bundleURL
|
||||
if bundleUrl == NSRunningApplication.current.bundleURL {
|
||||
App.shared.activate(ignoringOtherApps: true)
|
||||
App.app.window(withWindowNumber: Int(cgWindowId!))?.makeKeyAndOrderFront(nil)
|
||||
Windows.previewFocusedWindowIfNeeded()
|
||||
} else if isWindowlessApp || cgWindowId == nil {
|
||||
if let bundleUrl = bundleUrl {
|
||||
if (try? NSWorkspace.shared.launchApplication(at: bundleUrl, configuration: [:])) == nil {
|
||||
application.runningApplication.activate(options: .activateAllWindows)
|
||||
}
|
||||
} else {
|
||||
application.runningApplication.activate(options: .activateAllWindows)
|
||||
}
|
||||
Windows.previewFocusedWindowIfNeeded()
|
||||
} else {
|
||||
// macOS bug: when switching to a System Preferences window in another space, it switches to that space,
|
||||
// but quickly switches back to another window in that space
|
||||
|
||||
Reference in New Issue
Block a user