Fix dock icon persistence when launching externally

This commit is contained in:
Beingpax 2025-05-12 22:36:21 +05:45
parent b1b049eb8a
commit f03b0f3a18
2 changed files with 12 additions and 0 deletions

View File

@ -7,12 +7,18 @@ class AppDelegate: NSObject, NSApplicationDelegate {
}
func applicationShouldHandleReopen(_ sender: NSApplication, hasVisibleWindows flag: Bool) -> Bool {
updateActivationPolicy()
if !flag {
createMainWindowIfNeeded()
}
return true
}
func applicationDidBecomeActive(_ notification: Notification) {
updateActivationPolicy()
}
func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool {
return false
}

View File

@ -64,6 +64,12 @@ class MenuBarManager: ObservableObject {
DispatchQueue.main.async { [weak self] in
guard let self = self else { return }
if self.isMenuBarOnly {
NSApp.setActivationPolicy(.accessory)
} else {
NSApp.setActivationPolicy(.regular)
}
// Activate the app
NSApp.activate(ignoringOtherApps: true)