Ariver
2026-06-20 a3d82000231b8a8e3709e1a6708dbbdaf81412dc
C1.source/Sources/AlignerCore/Windows/WindowEnumerationPolicy.swift
@@ -22,6 +22,7 @@
    public let activationPolicy: AlignerActivationPolicy
    public let title: String
    public let size: CGSize
    public let frame: CGRect?
    public let subrole: AlignerWindowSubrole
    public let isMinimized: Bool
    public let isFullscreen: Bool
@@ -40,6 +41,7 @@
        title: String,
        identifierSource: AlignerWindow.IdentifierSource = .cgWindow,
        size: CGSize,
        frame: CGRect? = nil,
        subrole: AlignerWindowSubrole,
        isMinimized: Bool = false,
        isFullscreen: Bool = false,
@@ -57,6 +59,7 @@
        self.activationPolicy = activationPolicy
        self.title = title
        self.size = size
        self.frame = frame
        self.subrole = subrole
        self.isMinimized = isMinimized
        self.isFullscreen = isFullscreen
@@ -83,6 +86,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 +95,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? {
@@ -105,6 +109,7 @@
            isMinimized: record.isMinimized,
            isFullscreen: record.isFullscreen,
            isGhost: record.isGhost,
            frame: record.frame,
            spaceIDs: record.spaceIDs
        )
    }
@@ -132,6 +137,10 @@
            return false
        }
        if !record.spaceIDs.isEmpty {
            return false
        }
        return !isKnownCGOnlyOffscreenMainWindow(record)
    }
@@ -141,8 +150,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 +157,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