|
@@ -93,12 +93,7 @@ class AppDelegate: NSObject, NSApplicationDelegate {
|
|
|
|
|
|
|
|
@objc
|
|
@objc
|
|
|
private func openMainWindowFromStatusBar() {
|
|
private func openMainWindowFromStatusBar() {
|
|
|
- configureMainWindowIfNeeded()
|
|
|
|
|
- NSApp.setActivationPolicy(.regular)
|
|
|
|
|
- NSApp.activate(ignoringOtherApps: true)
|
|
|
|
|
- if let window = NSApp.windows.first {
|
|
|
|
|
- window.makeKeyAndOrderFront(nil)
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ showMainWindow()
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@objc
|
|
@objc
|
|
@@ -106,13 +101,27 @@ class AppDelegate: NSObject, NSApplicationDelegate {
|
|
|
configureMainWindowIfNeeded()
|
|
configureMainWindowIfNeeded()
|
|
|
guard let window = NSApp.windows.first else { return }
|
|
guard let window = NSApp.windows.first else { return }
|
|
|
|
|
|
|
|
- if window.isVisible && !window.isMiniaturized {
|
|
|
|
|
- window.miniaturize(nil)
|
|
|
|
|
|
|
+ if window.isVisible {
|
|
|
|
|
+ hideMainWindow()
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ showMainWindow()
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private func hideMainWindow() {
|
|
|
|
|
+ guard let window = NSApp.windows.first else { return }
|
|
|
|
|
+ if window.isMiniaturized {
|
|
|
|
|
+ window.deminiaturize(nil)
|
|
|
|
|
+ }
|
|
|
|
|
+ window.orderOut(nil)
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private func showMainWindow() {
|
|
|
|
|
+ configureMainWindowIfNeeded()
|
|
|
NSApp.setActivationPolicy(.regular)
|
|
NSApp.setActivationPolicy(.regular)
|
|
|
NSApp.activate(ignoringOtherApps: true)
|
|
NSApp.activate(ignoringOtherApps: true)
|
|
|
|
|
+ guard let window = NSApp.windows.first else { return }
|
|
|
if window.isMiniaturized {
|
|
if window.isMiniaturized {
|
|
|
window.deminiaturize(nil)
|
|
window.deminiaturize(nil)
|
|
|
}
|
|
}
|
|
@@ -158,6 +167,15 @@ class AppDelegate: NSObject, NSApplicationDelegate {
|
|
|
// Insert code here to tear down your application
|
|
// Insert code here to tear down your application
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ func applicationDidResignActive(_ notification: Notification) {
|
|
|
|
|
+ hideMainWindow()
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ func applicationShouldHandleReopen(_ sender: NSApplication, hasVisibleWindows flag: Bool) -> Bool {
|
|
|
|
|
+ showMainWindow()
|
|
|
|
|
+ return true
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
func applicationSupportsSecureRestorableState(_ app: NSApplication) -> Bool {
|
|
func applicationSupportsSecureRestorableState(_ app: NSApplication) -> Bool {
|
|
|
return true
|
|
return true
|
|
|
}
|
|
}
|