| | |
| | | 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 |
| | |
| | | title: String, |
| | | identifierSource: AlignerWindow.IdentifierSource = .cgWindow, |
| | | size: CGSize, |
| | | frame: CGRect? = nil, |
| | | subrole: AlignerWindowSubrole, |
| | | isMinimized: Bool = false, |
| | | isFullscreen: Bool = false, |
| | |
| | | self.activationPolicy = activationPolicy |
| | | self.title = title |
| | | self.size = size |
| | | self.frame = frame |
| | | self.subrole = subrole |
| | | self.isMinimized = isMinimized |
| | | self.isFullscreen = isFullscreen |
| | |
| | | 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 } |
| | | |
| | | return record.isMinimized || record.isFullscreen || isLargeEnough(record.size) |
| | | } |
| | | |
| | | public static func shouldIncludeAXOnlyRecord( |
| | | identifierSource: AlignerWindow.IdentifierSource, |
| | | isMinimized: Bool, |
| | | isFullscreen: Bool, |
| | | spaceIDs: [UInt64] |
| | | ) -> Bool { |
| | | if identifierSource == .syntheticAX { |
| | | return isMinimized |
| | | } |
| | | if isMinimized { |
| | | return true |
| | | } |
| | | if isFullscreen { |
| | | return !spaceIDs.isEmpty |
| | | } |
| | | return false |
| | | } |
| | | |
| | | 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? { |
| | |
| | | isMinimized: record.isMinimized, |
| | | isFullscreen: record.isFullscreen, |
| | | isGhost: record.isGhost, |
| | | frame: record.frame, |
| | | spaceIDs: record.spaceIDs |
| | | ) |
| | | } |
| | |
| | | return false |
| | | } |
| | | |
| | | if !record.spaceIDs.isEmpty { |
| | | return false |
| | | } |
| | | |
| | | return !isKnownCGOnlyOffscreenMainWindow(record) |
| | | } |
| | | |
| | |
| | | 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: |
| | |
| | | } |
| | | } |
| | | |
| | | 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 |