From 5a8600bb59862db9becada37452483e1a1d2e397 Mon Sep 17 00:00:00 2001
From: Ariver <ar@MacBook-Air.local>
Date: Thu, 14 May 2026 23:37:36 +0800
Subject: [PATCH] Release TagLauncher 5.7.5

---
 Apptag/ContentView.swift |   43 +++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 43 insertions(+), 0 deletions(-)

diff --git a/Apptag/ContentView.swift b/Apptag/ContentView.swift
index 3430c2e..111e5cc 100644
--- a/Apptag/ContentView.swift
+++ b/Apptag/ContentView.swift
@@ -237,6 +237,7 @@
     @State private var tagReorderFrames: [String: CGRect] = [:]
     @State private var tagNavDragModeActive = false
     @State private var tagNavDragItem: String? = nil
+    @State private var tagNavDismissMonitor: Any? = nil
     @State private var tagNavReorderFrames: [String: CGRect] = [:]
     @State private var hoveredContainer: String? = nil  // colored container lift
     // Fixed interaction for "Colorless Container": hover fills persistently; click clears.
@@ -347,6 +348,12 @@
                 userInfo: ["active": active]
             )
         }
+        .onChange(of: tagNavDragModeActive) { _, active in
+            updateTagNavDismissMonitor(active: active)
+        }
+        .onDisappear {
+            removeTagNavDismissMonitor()
+        }
     }
 
     /// Set edit phase with synchronous notification BEFORE state change.
@@ -377,6 +384,16 @@
                 topLayout
             }
 
+            if tagNavDragModeActive && tagNavDragItem == nil {
+                Color.clear
+                    .contentShape(Rectangle())
+                    .ignoresSafeArea()
+                    .onTapGesture {
+                        endTagNavReorder()
+                    }
+                    .zIndex(1)
+            }
+
             Button {
                 setEditPhase(.editingApps)
             } label: {
@@ -390,6 +407,7 @@
             .padding(.top, notchHeight > 0 ? notchHeight + 10 : 20)
             .padding(.trailing, 20)
             .keyboardShortcut("e", modifiers: .control)
+            .zIndex(2)
         }
     }
 
@@ -1287,6 +1305,27 @@
         }
         tagNavDragModeActive = false
         tagNavDragItem = nil
+        removeTagNavDismissMonitor()
+    }
+
+    private func updateTagNavDismissMonitor(active: Bool) {
+        if active {
+            guard tagNavDismissMonitor == nil else { return }
+            tagNavDismissMonitor = NSEvent.addLocalMonitorForEvents(matching: [.leftMouseDown, .rightMouseDown]) { event in
+                guard tagNavDragModeActive, editPhase == .none else { return event }
+                endTagNavReorder()
+                return nil
+            }
+        } else {
+            removeTagNavDismissMonitor()
+        }
+    }
+
+    private func removeTagNavDismissMonitor() {
+        if let monitor = tagNavDismissMonitor {
+            NSEvent.removeMonitor(monitor)
+            tagNavDismissMonitor = nil
+        }
     }
 
     private func reorderTagNavItem(at location: CGPoint) {
@@ -1391,6 +1430,9 @@
     }
 
     private func setAppDragMode(_ active: Bool) {
+        if active {
+            endTagNavReorder()
+        }
         appDragModeActive = active
         if active {
             DispatchQueue.main.asyncAfter(deadline: .now() + 8) {
@@ -1424,6 +1466,7 @@
 
     func openApp(_ app: AppInfo) {
         appDragModeActive = false
+        endTagNavReorder()
         hideOverlay()
         let configuration = NSWorkspace.OpenConfiguration()
         NSWorkspace.shared.openApplication(at: app.path, configuration: configuration)

--
Gitblit v1.9.3