From 72219babd9bf0a4ce6fc26af91ee969a8705f053 Mon Sep 17 00:00:00 2001
From: Ariver <shanghai3168@gmail.com>
Date: Thu, 11 Jun 2026 19:50:27 +0800
Subject: [PATCH] Refine Quick Switch Space filter interactions

---
 C1.source/Sources/Aligner/QuickSwitchRootView.swift |   79 +++++++++++++++++++++++++++++++++------
 1 files changed, 67 insertions(+), 12 deletions(-)

diff --git a/C1.source/Sources/Aligner/QuickSwitchRootView.swift b/C1.source/Sources/Aligner/QuickSwitchRootView.swift
index dba70d2..3ed74c0 100644
--- a/C1.source/Sources/Aligner/QuickSwitchRootView.swift
+++ b/C1.source/Sources/Aligner/QuickSwitchRootView.swift
@@ -82,9 +82,12 @@
     private var lastProjectionTransitionFadeInLayerCount = 0
     private var lastProjectionTransitionFadeOutLayerCount = 0
     private var lastProjectionTransitionDurationMilliseconds: Double = 0
+    private var suppressEventInput = false
+    private var suppressEventBackgroundClicks = false
     var onEscape: (() -> Void)?
     var onCommitSelection: ((QuickSwitchSelection, QuickSwitchCommitSource) -> Void)?
-    var onSpaceLaneClick: ((UInt64) -> Void)?
+    var onSpaceLaneClick: ((UInt64, Int) -> Void)?
+    var onBackgroundClick: (() -> Bool)?
     var onRequestClose: ((QuickSwitchCloseRequest) -> Void)?
     var onCloseConfirmationDisabled: (() -> Void)?
 
@@ -379,6 +382,13 @@
     }
 
     override func keyDown(with event: NSEvent) {
+        if suppressEventInput {
+            DevelopmentDiagnostics.log("quickSwitch.view.keyDown.ignoredForDebugSequence", [
+                "keyCode": event.keyCode
+            ])
+            return
+        }
+
         switch event.keyCode {
         case TriggerKeyCode.escape where Self.shouldDismissOnEscape(event):
             onEscape?()
@@ -462,6 +472,15 @@
     }
 
     override func mouseDown(with event: NSEvent) {
+        if suppressEventInput {
+            DevelopmentDiagnostics.log("quickSwitch.view.mouseDown.ignoredForDebugSequence", [
+                "x": event.locationInWindow.x,
+                "y": event.locationInWindow.y,
+                "bounds": NSStringFromRect(bounds)
+            ])
+            return
+        }
+
         if handleCloseConfirmationMouseDown(at: event.locationInWindow) {
             return
         }
@@ -477,7 +496,7 @@
         }
 
         if let segment = spaceLaneSegment(at: event.locationInWindow) {
-            clickSpaceLaneSegment(segment)
+            clickSpaceLaneSegment(segment, clickCount: max(1, event.clickCount))
             return
         }
 
@@ -491,6 +510,9 @@
             "y": event.locationInWindow.y,
             "bounds": NSStringFromRect(bounds)
         ])
+        if !suppressEventBackgroundClicks, onBackgroundClick?() == true {
+            return
+        }
         super.mouseDown(with: event)
     }
 
@@ -532,6 +554,15 @@
                 break
             }
         }
+    }
+
+    func setSuppressEventBackgroundClicks(_ suppressed: Bool) {
+        suppressEventBackgroundClicks = suppressed
+    }
+
+    func setSuppressEventInput(_ suppressed: Bool) {
+        suppressEventInput = suppressed
+        suppressEventBackgroundClicks = suppressed
     }
 
     func beginPerformanceFirstFrameMeasurement() {
@@ -1207,8 +1238,21 @@
             }
             recordMouseCommand("click-space:\(spaceID)")
             if let segment = spaceLaneSegment(spaceID: spaceID) {
-                clickSpaceLaneSegment(segment)
+                clickSpaceLaneSegment(segment, clickCount: 1)
             }
+        case "double-click-space" where parts.count == 2:
+            guard let spaceID = UInt64(parts[1]) else {
+                recordMouseCommand("invalid:\(command)")
+                return
+            }
+            recordMouseCommand("double-click-space:\(spaceID)")
+            if let segment = spaceLaneSegment(spaceID: spaceID) {
+                clickSpaceLaneSegment(segment, clickCount: 1)
+                clickSpaceLaneSegment(segment, clickCount: 2)
+            }
+        case "click-background":
+            recordMouseCommand("click-background")
+            _ = onBackgroundClick?()
         case "hover-card" where parts.count == 3:
             guard let appGroupIndex = Int(parts[1]), let windowIndex = Int(parts[2]) else {
                 recordMouseCommand("invalid:\(command)")
@@ -1324,13 +1368,14 @@
         focusSpace(segment.space.id, persistent: false, source: source)
     }
 
-    private func clickSpaceLaneSegment(_ segment: SpaceLaneSegmentLayers) {
+    private func clickSpaceLaneSegment(_ segment: SpaceLaneSegmentLayers, clickCount: Int = 1) {
         DevelopmentDiagnostics.log("quickSwitch.view.clickSpaceLane", [
             "spaceID": segment.space.id,
-            "label": segment.space.label
+            "label": segment.space.label,
+            "clickCount": clickCount
         ])
         lastSpaceLaneClickSpaceID = segment.space.id
-        onSpaceLaneClick?(segment.space.id)
+        onSpaceLaneClick?(segment.space.id, clickCount)
         lastSpaceLaneClickSpaceID = segment.space.id
     }
 
@@ -2443,9 +2488,11 @@
         let isActive = isHovered || isFocused || isLocked
         let isAssociated = (isAppAssociated || isWindowAssociated) && !isActive
 
-        segment.containerLayer.borderWidth = (hasWindows || isCurrent || isActive || isAssociated) ? 1.5 : 1
+        segment.containerLayer.borderWidth = isLocked
+            ? 2.75
+            : (hasWindows || isCurrent || isActive || isAssociated) ? 1.5 : 1
         segment.containerLayer.borderColor = (isActive
-            ? spaceLaneOccupiedColor.withAlphaComponent(0.62)
+            ? spaceLaneOccupiedColor.withAlphaComponent(isLocked ? 0.92 : 0.62)
             : isAssociated
                 ? spaceLaneOccupiedColor.withAlphaComponent(0.50)
                 : hasWindows
@@ -2472,17 +2519,20 @@
                 colors: spaceLaneIdleOccupiedGradientColors()
             )
         }
+        segment.containerLayer.shadowColor = isLocked
+            ? NSColor.white.withAlphaComponent(0.98).cgColor
+            : NSColor.black.cgColor
         segment.containerLayer.shadowOpacity = (hasWindows || isLocked)
-            ? (isActive ? 0.26 : isAssociated ? 0.18 : isCurrent ? 0.14 : 0)
+            ? (isLocked ? 0.72 : isActive ? 0.26 : isAssociated ? 0.18 : isCurrent ? 0.14 : 0)
             : 0
         segment.containerLayer.shadowRadius = (hasWindows || isLocked)
-            ? (isActive ? 24 : isAssociated ? 18 : isCurrent ? 12 : 0)
+            ? (isLocked ? 30 : isActive ? 24 : isAssociated ? 18 : isCurrent ? 12 : 0)
             : 0
         segment.containerLayer.shadowOffset = CGSize(
             width: 0,
-            height: (hasWindows || isLocked) ? (isActive ? -6 : isAssociated ? -4 : isCurrent ? -2.5 : 0) : 0
+            height: (hasWindows || isLocked) ? (isLocked ? 0 : isActive ? -6 : isAssociated ? -4 : isCurrent ? -2.5 : 0) : 0
         )
-        segment.containerLayer.zPosition = isActive ? 30 : isAssociated ? 18 : isCurrent ? 10 : 0
+        segment.containerLayer.zPosition = isLocked ? 42 : isActive ? 30 : isAssociated ? 18 : isCurrent ? 10 : 0
         segment.containerLayer.transform = (isActive || isAssociated)
             ? CATransform3DMakeScale(isActive ? 1.03 : 1.015, isActive ? 1.03 : 1.015, 1)
             : CATransform3DIdentity
@@ -4426,8 +4476,13 @@
                     "gradientColors": gradientColorDictionaries(from: segment.containerLayer),
                     "borderColor": colorDictionary(from: segment.containerLayer.borderColor),
                     "borderWidth": Double(segment.containerLayer.borderWidth),
+                    "shadowColor": colorDictionary(from: segment.containerLayer.shadowColor),
                     "shadowOpacity": Double(segment.containerLayer.shadowOpacity),
                     "shadowRadius": Double(segment.containerLayer.shadowRadius),
+                    "shadowOffset": [
+                        "width": Double(segment.containerLayer.shadowOffset.width),
+                        "height": Double(segment.containerLayer.shadowOffset.height)
+                    ],
                     "appFrame": dictionary(from: segment.appLayer.frame),
                     "frame": dictionary(from: segment.containerLayer.frame),
                     "visibleFrame": dictionary(from: visibleFrame),

--
Gitblit v1.9.3