From 3ef24f71a70fc47eba8bf23f6827a60a4f34a07a Mon Sep 17 00:00:00 2001
From: Ariver <shanghai3168@gmail.com>
Date: Thu, 04 Jun 2026 00:32:09 +0800
Subject: [PATCH] Fix Shottr and HBuilderX window candidates

---
 C1.source/Sources/AlignerCore/Windows/WindowEnumerationPolicy.swift |   35 +++++++++++++++++++++++++++++------
 1 files changed, 29 insertions(+), 6 deletions(-)

diff --git a/C1.source/Sources/AlignerCore/Windows/WindowEnumerationPolicy.swift b/C1.source/Sources/AlignerCore/Windows/WindowEnumerationPolicy.swift
index 75bc119..a219abb 100644
--- a/C1.source/Sources/AlignerCore/Windows/WindowEnumerationPolicy.swift
+++ b/C1.source/Sources/AlignerCore/Windows/WindowEnumerationPolicy.swift
@@ -76,7 +76,7 @@
 
     public static func shouldInclude(_ record: WindowEnumerationRecord) -> Bool {
         guard record.id != 0 else { return false }
-        guard record.activationPolicy == .regular else { return false }
+        guard hasSupportedActivationPolicy(record) else { return false }
         guard isSupportedSubrole(record.subrole) else { return false }
         guard !record.app.isHidden || record.isFullscreen else { return false }
         guard !record.isGhost else { return false }
@@ -87,6 +87,11 @@
         guard !isKnownClosedDocumentPlaceholder(record) else { return false }
 
         return record.isMinimized || record.isFullscreen || isLargeEnough(record.size)
+    }
+
+    private static func hasSupportedActivationPolicy(_ record: WindowEnumerationRecord) -> Bool {
+        record.activationPolicy == .regular
+            || (record.activationPolicy == .accessory && isKnownCGOnlyOffscreenMainWindow(record))
     }
 
     public static func window(from record: WindowEnumerationRecord) -> AlignerWindow? {
@@ -118,11 +123,29 @@
     }
 
     private static func isCGOnlyOffscreenGhost(_ record: WindowEnumerationRecord) -> Bool {
-        record.identifierSource == .cgWindow
-            && !record.hasAXBacking
-            && !record.isOnscreen
-            && !record.isMinimized
-            && !record.isFullscreen
+        guard record.identifierSource == .cgWindow,
+              !record.hasAXBacking,
+              !record.isOnscreen,
+              !record.isMinimized,
+              !record.isFullscreen
+        else {
+            return false
+        }
+
+        return !isKnownCGOnlyOffscreenMainWindow(record)
+    }
+
+    private static func isKnownCGOnlyOffscreenMainWindow(_ record: WindowEnumerationRecord) -> Bool {
+        let trimmedTitle = record.title.trimmingCharacters(in: .whitespacesAndNewlines)
+
+        switch record.app.bundleIdentifier {
+        case "cc.ffitch.shottr":
+            return trimmedTitle == "Shottr" && isLargeEnough(record.size)
+        case "io.dcloud.HBuilderX":
+            return !trimmedTitle.isEmpty && isLargeEnough(record.size)
+        default:
+            return false
+        }
     }
 
     private static func isKnownClosedDocumentPlaceholder(_ record: WindowEnumerationRecord) -> Bool {

--
Gitblit v1.9.3