From b29f7228d5bacf7086b7155f24d92fffd65bda11 Mon Sep 17 00:00:00 2001
From: Ariver <shanghai3168@gmail.com>
Date: Sun, 31 May 2026 01:52:17 +0800
Subject: [PATCH] Prepare 7.8.6 explicit app grid launch release

---
 Apptag/ApptagApp.swift |   45 +++++++++++++++++++++++++--------------------
 1 files changed, 25 insertions(+), 20 deletions(-)

diff --git a/Apptag/ApptagApp.swift b/Apptag/ApptagApp.swift
index 6f4c0b3..449efca 100644
--- a/Apptag/ApptagApp.swift
+++ b/Apptag/ApptagApp.swift
@@ -208,10 +208,10 @@
         configureApplicationMenuWhenAvailable(retries: 12)
     }
 
-    /// Dock icon click → show overlay (same as menubar "Show TagLauncher")
+    /// Reopening the already-running app must not implicitly show App Grid.
+    /// App Grid is only opened by explicit launcher commands: main hotkey or status item/menu.
     func applicationShouldHandleReopen(_ sender: NSApplication, hasVisibleWindows flag: Bool) -> Bool {
         guard Date() >= suppressReopenUntil else { return false }
-        showOrFocusOverlay()
         return false  // Suppress default "unhide all windows" behavior
     }
 
@@ -900,18 +900,7 @@
 
     private func handleOverlayEscapeKey() -> Bool {
         if isQuickSearchOpen || quickSearchOnlyOverlaySession {
-            let shouldHideOverlayAfterDismiss = quickSearchShouldHideOverlayOnClose || quickSearchOnlyOverlaySession
-            isQuickSearchOpen = false
-            removeQuickSearchExternalMouseMonitor()
-            updateOverlayLevelForTextInput()
-            NotificationCenter.default.post(name: .tagLauncherQuickSearchDismissRequested, object: nil)
-            if shouldHideOverlayAfterDismiss {
-                quickSearchShouldHideOverlayOnClose = false
-                quickSearchOnlyOverlaySession = false
-                DispatchQueue.main.async { [weak self] in
-                    self?.hideOverlay(force: true)
-                }
-            }
+            dismissQuickSearchFromKeyboard()
             return true
         }
         guard !isSettingsVisible,
@@ -920,6 +909,21 @@
         else { return false }
         hideOverlay(force: true)
         return true
+    }
+
+    private func dismissQuickSearchFromKeyboard() {
+        let shouldHideOverlayAfterDismiss = quickSearchShouldHideOverlayOnClose || quickSearchOnlyOverlaySession
+        isQuickSearchOpen = false
+        removeQuickSearchExternalMouseMonitor()
+        updateOverlayLevelForTextInput()
+        NotificationCenter.default.post(name: .tagLauncherQuickSearchDismissRequested, object: nil)
+        if shouldHideOverlayAfterDismiss {
+            quickSearchShouldHideOverlayOnClose = false
+            quickSearchOnlyOverlaySession = false
+            DispatchQueue.main.async { [weak self] in
+                self?.hideOverlay(force: true)
+            }
+        }
     }
 
     private func requestQuickSearch(source: String) {
@@ -1072,6 +1076,12 @@
 
     private func showQuickSearchFromGlobalHotkey() {
         let now = Date()
+        if overlayWindow?.isVisible == true, isQuickSearchOpen || quickSearchOnlyOverlaySession {
+            lastQuickSearchHotkeyAt = now
+            dismissQuickSearchFromKeyboard()
+            return
+        }
+
         if now.timeIntervalSince(lastQuickSearchHotkeyAt) < 0.28 {
             promoteOverlayToForegroundInput()
             updateOverlayLevelForTextInput()
@@ -1079,11 +1089,6 @@
         }
         lastQuickSearchHotkeyAt = now
 
-        if overlayWindow?.isVisible == true, isQuickSearchOpen || quickSearchOnlyOverlaySession {
-            promoteOverlayToForegroundInput()
-            updateOverlayLevelForTextInput()
-            return
-        }
         if overlayWindow?.isVisible == true {
             refreshLauncherChromeState(
                 activate: !overlayAvoidsSpaceSwitch,
@@ -1472,7 +1477,7 @@
     }
 
     @objc private func handleExternalActivationRequest(_ notification: Notification) {
-        let shouldShowOverlay = notification.userInfo?["showOverlay"] as? Bool ?? true
+        let shouldShowOverlay = notification.userInfo?["showOverlay"] as? Bool ?? false
         guard shouldShowOverlay else { return }
         showOrFocusOverlay()
     }

--
Gitblit v1.9.3