From 2182f72105033db025bb29e08319586112e53c5f Mon Sep 17 00:00:00 2001
From: Ariver <shanghai3168@gmail.com>
Date: Wed, 10 Jun 2026 19:37:25 +0800
Subject: [PATCH] Fix empty Space lane fill

---
 C1.source/Sources/Aligner/AlignerApplicationDelegate.swift |   35 ++++++++++++++++++++++++++++++++++-
 1 files changed, 34 insertions(+), 1 deletions(-)

diff --git a/C1.source/Sources/Aligner/AlignerApplicationDelegate.swift b/C1.source/Sources/Aligner/AlignerApplicationDelegate.swift
index 4218d77..3b968f2 100644
--- a/C1.source/Sources/Aligner/AlignerApplicationDelegate.swift
+++ b/C1.source/Sources/Aligner/AlignerApplicationDelegate.swift
@@ -4,6 +4,8 @@
 
 @MainActor
 final class AlignerApplicationDelegate: NSObject, NSApplicationDelegate {
+    private static let quickSwitchConfirmBeforeCloseDefaultsKey = "QuickSwitchConfirmBeforeClose"
+
     private let permissionChecker = SystemPermissionChecker()
     private let launchOptions = Round0DebugLaunchOptions.parse(arguments: ProcessInfo.processInfo.arguments)
     private let round1PoCOptions = Round1PerformancePoCOptions.parse(arguments: ProcessInfo.processInfo.arguments)
@@ -352,7 +354,12 @@
             let controller = QuickSwitchSessionController(
                 snapshotLoader: quickSwitchSnapshotLoader(),
                 windowActivationService: quickSwitchWindowActivationService(),
+                windowCloseService: quickSwitchWindowCloseService(),
                 disableScreenshotRefresh: round1QuickSwitchOptions.disableScreenshotRefresh,
+                closeConfirmationRequired: quickSwitchConfirmBeforeClose,
+                onCloseConfirmationDisabled: { [weak self] in
+                    self?.setQuickSwitchConfirmBeforeClose(false)
+                },
                 debugHoveredAppGroupIndex: round1QuickSwitchOptions.debugHoveredAppGroupIndex,
                 debugOverlayWidth: round1QuickSwitchOptions.debugOverlayWidth,
                 debugKeySequence: round1QuickSwitchOptions.debugKeySequence,
@@ -421,7 +428,12 @@
             let controller = QuickSwitchSessionController(
                 snapshotLoader: quickSwitchSnapshotLoader(),
                 windowActivationService: quickSwitchWindowActivationService(),
+                windowCloseService: quickSwitchWindowCloseService(),
                 disableScreenshotRefresh: round1QuickSwitchOptions.disableScreenshotRefresh,
+                closeConfirmationRequired: quickSwitchConfirmBeforeClose,
+                onCloseConfirmationDisabled: { [weak self] in
+                    self?.setQuickSwitchConfirmBeforeClose(false)
+                },
                 debugHoveredAppGroupIndex: round1QuickSwitchOptions.debugHoveredAppGroupIndex,
                 debugOverlayWidth: round1QuickSwitchOptions.debugOverlayWidth,
                 debugKeySequence: round1QuickSwitchOptions.debugKeySequence,
@@ -509,7 +521,8 @@
             return FixtureQuickSwitchSnapshotLoader(
                 appCount: fixtureAppCount,
                 windowsPerApp: round1QuickSwitchOptions.fixtureWindowsPerApp ?? 1,
-                mode: .layout
+                mode: .layout,
+                usesMultipleDisplays: round1QuickSwitchOptions.fixtureMultiDisplay
             )
         }
 
@@ -529,6 +542,26 @@
         return CGWindowAXWindowService(spaceIDsByWindowIDProvider: { _ in [:] })
     }
 
+    private func quickSwitchWindowCloseService() -> any WindowCloseServiceProtocol {
+        if round1QuickSwitchOptions.debugWindowClose {
+            return DebugWindowCloseService()
+        }
+
+        return CGWindowAXWindowService(spaceIDsByWindowIDProvider: { _ in [:] })
+    }
+
+    private var quickSwitchConfirmBeforeClose: Bool {
+        let value = UserDefaults.standard.object(forKey: Self.quickSwitchConfirmBeforeCloseDefaultsKey)
+        return (value as? Bool) ?? true
+    }
+
+    private func setQuickSwitchConfirmBeforeClose(_ enabled: Bool) {
+        UserDefaults.standard.set(enabled, forKey: Self.quickSwitchConfirmBeforeCloseDefaultsKey)
+        DevelopmentDiagnostics.log("app.quickSwitch.closeConfirmationPreferenceChanged", [
+            "confirmBeforeClose": enabled
+        ])
+    }
+
     @objc private func showPermissions() {
         DevelopmentDiagnostics.log("app.permissions.show", [
             "accessibility": permissionStatusString(accessibilityStatus()),

--
Gitblit v1.9.3