|
|
@@ -51,13 +51,13 @@ class AppDelegate: NSObject, NSApplicationDelegate {
|
|
|
@objc
|
|
|
private func statusBarButtonClicked(_ sender: Any?) {
|
|
|
guard let event = NSApp.currentEvent else {
|
|
|
- openMainWindowFromStatusBar()
|
|
|
+ toggleMainWindowFromStatusBar()
|
|
|
return
|
|
|
}
|
|
|
if event.type == .rightMouseUp {
|
|
|
presentStatusBarShortcutsMenu()
|
|
|
} else {
|
|
|
- openMainWindowFromStatusBar()
|
|
|
+ toggleMainWindowFromStatusBar()
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -101,6 +101,24 @@ class AppDelegate: NSObject, NSApplicationDelegate {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ @objc
|
|
|
+ private func toggleMainWindowFromStatusBar() {
|
|
|
+ configureMainWindowIfNeeded()
|
|
|
+ guard let window = NSApp.windows.first else { return }
|
|
|
+
|
|
|
+ if window.isVisible && !window.isMiniaturized {
|
|
|
+ window.miniaturize(nil)
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ NSApp.setActivationPolicy(.regular)
|
|
|
+ NSApp.activate(ignoringOtherApps: true)
|
|
|
+ if window.isMiniaturized {
|
|
|
+ window.deminiaturize(nil)
|
|
|
+ }
|
|
|
+ window.makeKeyAndOrderFront(nil)
|
|
|
+ }
|
|
|
+
|
|
|
private func configureMainWindowIfNeeded() {
|
|
|
guard let window = NSApp.windows.first else { return }
|
|
|
window.title = "My Apps"
|