Fix dock icon persistence when launching externally
This commit is contained in:
parent
b1b049eb8a
commit
f03b0f3a18
@ -7,12 +7,18 @@ class AppDelegate: NSObject, NSApplicationDelegate {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func applicationShouldHandleReopen(_ sender: NSApplication, hasVisibleWindows flag: Bool) -> Bool {
|
func applicationShouldHandleReopen(_ sender: NSApplication, hasVisibleWindows flag: Bool) -> Bool {
|
||||||
|
updateActivationPolicy()
|
||||||
|
|
||||||
if !flag {
|
if !flag {
|
||||||
createMainWindowIfNeeded()
|
createMainWindowIfNeeded()
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func applicationDidBecomeActive(_ notification: Notification) {
|
||||||
|
updateActivationPolicy()
|
||||||
|
}
|
||||||
|
|
||||||
func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool {
|
func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|||||||
@ -64,6 +64,12 @@ class MenuBarManager: ObservableObject {
|
|||||||
DispatchQueue.main.async { [weak self] in
|
DispatchQueue.main.async { [weak self] in
|
||||||
guard let self = self else { return }
|
guard let self = self else { return }
|
||||||
|
|
||||||
|
if self.isMenuBarOnly {
|
||||||
|
NSApp.setActivationPolicy(.accessory)
|
||||||
|
} else {
|
||||||
|
NSApp.setActivationPolicy(.regular)
|
||||||
|
}
|
||||||
|
|
||||||
// Activate the app
|
// Activate the app
|
||||||
NSApp.activate(ignoringOtherApps: true)
|
NSApp.activate(ignoringOtherApps: true)
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user