From 0045898e8cd7b2d8972bb24c8ac27e514bdd8c70 Mon Sep 17 00:00:00 2001
From: Ariver <shanghai3168@gmail.com>
Date: Thu, 11 Jun 2026 16:46:31 +0800
Subject: [PATCH] Implement Quick Switch Space filtering

---
 C1.source/Sources/AlignerCore/Windows/WindowEnumerationPolicy.swift |   30 +++++++++++++++++++++++++++---
 1 files changed, 27 insertions(+), 3 deletions(-)

diff --git a/C1.source/Sources/AlignerCore/Windows/WindowEnumerationPolicy.swift b/C1.source/Sources/AlignerCore/Windows/WindowEnumerationPolicy.swift
index 6357849..586fc83 100644
--- a/C1.source/Sources/AlignerCore/Windows/WindowEnumerationPolicy.swift
+++ b/C1.source/Sources/AlignerCore/Windows/WindowEnumerationPolicy.swift
@@ -83,6 +83,7 @@
         guard !record.isDesktopElement else { return false }
         guard !record.isSystemCritical else { return false }
         guard record.isInteractable else { return false }
+        guard !isKnownClosedShottrCGPlaceholder(record) else { return false }
         guard !isCGOnlyOffscreenGhost(record) else { return false }
         guard !isKnownClosedDocumentPlaceholder(record) else { return false }
 
@@ -91,7 +92,7 @@
 
     private static func hasSupportedActivationPolicy(_ record: WindowEnumerationRecord) -> Bool {
         record.activationPolicy == .regular
-            || (record.activationPolicy == .accessory && isKnownCGOnlyOffscreenMainWindow(record))
+            || (record.activationPolicy == .accessory && isKnownAccessoryMainWindow(record))
     }
 
     public static func window(from record: WindowEnumerationRecord) -> AlignerWindow? {
@@ -132,6 +133,10 @@
             return false
         }
 
+        if !record.spaceIDs.isEmpty {
+            return false
+        }
+
         return !isKnownCGOnlyOffscreenMainWindow(record)
     }
 
@@ -141,8 +146,6 @@
         switch record.app.bundleIdentifier {
         case "com.apple.finder":
             return !trimmedTitle.isEmpty && isLargeEnough(record.size)
-        case "cc.ffitch.shottr":
-            return trimmedTitle == "Shottr" && isLargeEnough(record.size)
         case "io.dcloud.HBuilderX":
             return !trimmedTitle.isEmpty && isLargeEnough(record.size)
         default:
@@ -150,6 +153,27 @@
         }
     }
 
+    private static func isKnownAccessoryMainWindow(_ record: WindowEnumerationRecord) -> Bool {
+        let trimmedTitle = record.title.trimmingCharacters(in: .whitespacesAndNewlines)
+
+        return record.app.bundleIdentifier == "cc.ffitch.shottr"
+            && trimmedTitle == "Shottr"
+            && record.isOnscreen
+            && isLargeEnough(record.size)
+    }
+
+    private static func isKnownClosedShottrCGPlaceholder(_ record: WindowEnumerationRecord) -> Bool {
+        let trimmedTitle = record.title.trimmingCharacters(in: .whitespacesAndNewlines)
+
+        return record.app.bundleIdentifier == "cc.ffitch.shottr"
+            && trimmedTitle == "Shottr"
+            && record.identifierSource == .cgWindow
+            && !record.hasAXBacking
+            && !record.isOnscreen
+            && !record.isMinimized
+            && !record.isFullscreen
+    }
+
     private static func isKnownClosedDocumentPlaceholder(_ record: WindowEnumerationRecord) -> Bool {
         let trimmedTitle = record.title.trimmingCharacters(in: .whitespacesAndNewlines)
         return record.identifierSource == .cgWindow

--
Gitblit v1.9.3