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/Tests/AlignerCoreTests/AlignerCoreTests.swift |   70 +++++++++++++++++++++++++++++++++++
 1 files changed, 70 insertions(+), 0 deletions(-)

diff --git a/C1.source/Tests/AlignerCoreTests/AlignerCoreTests.swift b/C1.source/Tests/AlignerCoreTests/AlignerCoreTests.swift
index 9eca644..66709a1 100644
--- a/C1.source/Tests/AlignerCoreTests/AlignerCoreTests.swift
+++ b/C1.source/Tests/AlignerCoreTests/AlignerCoreTests.swift
@@ -244,6 +244,76 @@
         XCTAssertEqual(window?.title, "Visible Document.md")
     }
 
+    func testWindowEnumerationPolicyKeepsKnownCGOnlyOffscreenMainWindows() {
+        let hbuilderApp = AlignerApp(
+            bundleIdentifier: "io.dcloud.HBuilderX",
+            name: "HBuilderX",
+            category: .editorIDE
+        )
+        let record = WindowEnumerationRecord(
+            id: 55_388,
+            app: hbuilderApp,
+            title: "lm-app - HBuilder X 5.07",
+            size: CGSize(width: 1048, height: 796),
+            subrole: .standard,
+            hasAXBacking: false,
+            isOnscreen: false
+        )
+        let emptyTitleRecord = WindowEnumerationRecord(
+            id: 55_389,
+            app: hbuilderApp,
+            title: "",
+            size: CGSize(width: 1048, height: 796),
+            subrole: .standard,
+            hasAXBacking: false,
+            isOnscreen: false
+        )
+        let tinyRecord = WindowEnumerationRecord(
+            id: 55_390,
+            app: hbuilderApp,
+            title: "HBuilderX Utility",
+            size: CGSize(width: 80, height: 40),
+            subrole: .standard,
+            hasAXBacking: false,
+            isOnscreen: false
+        )
+
+        XCTAssertEqual(WindowEnumerationPolicy.window(from: record)?.title, "lm-app - HBuilder X 5.07")
+        XCTAssertNil(WindowEnumerationPolicy.window(from: emptyTitleRecord))
+        XCTAssertNil(WindowEnumerationPolicy.window(from: tinyRecord))
+    }
+
+    func testWindowEnumerationPolicyKeepsShottrCGOnlyAnnotationWindow() {
+        let shottrApp = AlignerApp(
+            bundleIdentifier: "cc.ffitch.shottr",
+            name: "Shottr",
+            category: .generic
+        )
+        let annotationRecord = WindowEnumerationRecord(
+            id: 78,
+            app: shottrApp,
+            activationPolicy: .accessory,
+            title: "Shottr",
+            size: CGSize(width: 1710, height: 997),
+            subrole: .standard,
+            hasAXBacking: false,
+            isOnscreen: false
+        )
+        let utilityRecord = WindowEnumerationRecord(
+            id: 102,
+            app: shottrApp,
+            activationPolicy: .accessory,
+            title: "Colors",
+            size: CGSize(width: 250, height: 397),
+            subrole: .standard,
+            hasAXBacking: false,
+            isOnscreen: false
+        )
+
+        XCTAssertEqual(WindowEnumerationPolicy.window(from: annotationRecord)?.title, "Shottr")
+        XCTAssertNil(WindowEnumerationPolicy.window(from: utilityRecord))
+    }
+
     func testWindowEnumerationPolicyKeepsMinimizedAndFullscreenCGOnlyOffscreenWindows() {
         let minimized = makeWindowRecord(
             title: "Minimized Document.md",

--
Gitblit v1.9.3