| | |
| | | isGhost: isGhost( |
| | | rawWindow: rawWindow, |
| | | axWindow: axWindow, |
| | | app: app, |
| | | spaceIDs: spaceIDs, |
| | | hasAXBackedTitleDuplicate: hasAXBackedTitleDuplicate |
| | | ), |
| | |
| | | private func isGhost( |
| | | rawWindow: [String: Any], |
| | | axWindow: AXWindowMetadata?, |
| | | app: AlignerApp, |
| | | spaceIDs: [UInt64], |
| | | hasAXBackedTitleDuplicate: Bool = false |
| | | ) -> Bool { |
| | |
| | | return false |
| | | } |
| | | if axWindow != nil { |
| | | return layer != 0 || alpha <= 0 |
| | | if alpha <= 0 { |
| | | return true |
| | | } |
| | | if layer == 0 { |
| | | return false |
| | | } |
| | | |
| | | return !isOnscreen |
| | | } |
| | | if hasAXBackedTitleDuplicate { |
| | | return true |
| | | } |
| | | if isKnownCGOnlyMainWindow(rawWindow: rawWindow, app: app) { |
| | | return false |
| | | } |
| | | if !spaceIDs.isEmpty, isLikelyFullscreenAuxiliaryCGWindow(bounds: rawBounds) { |
| | | return true |
| | |
| | | bounds.width < 500 || bounds.height < 160 |
| | | } |
| | | |
| | | private func isKnownCGOnlyMainWindow(rawWindow: [String: Any], app: AlignerApp) -> Bool { |
| | | let layer = intValue(rawWindow[kCGWindowLayer as String]) ?? 0 |
| | | let alpha = doubleValue(rawWindow[kCGWindowAlpha as String]) ?? 1 |
| | | let isOnscreen = boolValue(rawWindow[kCGWindowIsOnscreen as String]) |
| | | let title = stringValue(rawWindow[kCGWindowName as String]) ?? "" |
| | | let rawBounds = bounds(rawWindow[kCGWindowBounds as String]) |
| | | let trimmedTitle = title.trimmingCharacters(in: .whitespacesAndNewlines) |
| | | |
| | | if app.bundleIdentifier == "cc.ffitch.shottr" { |
| | | return alpha > 0 |
| | | && trimmedTitle == "Shottr" |
| | | && rawBounds.width > WindowEnumerationPolicy.minimumVisibleWidth |
| | | && rawBounds.height > WindowEnumerationPolicy.minimumVisibleHeight |
| | | } |
| | | |
| | | guard app.bundleIdentifier == "io.dcloud.HBuilderX" else { return false } |
| | | |
| | | return layer == 0 |
| | | && alpha > 0 |
| | | && !isOnscreen |
| | | && !trimmedTitle.isEmpty |
| | | && rawBounds.width > WindowEnumerationPolicy.minimumVisibleWidth |
| | | && rawBounds.height > WindowEnumerationPolicy.minimumVisibleHeight |
| | | } |
| | | |
| | | private func isDesktopElement(rawWindow: [String: Any], app: AlignerApp) -> Bool { |
| | | guard app.bundleIdentifier == "com.apple.finder" else { return false } |
| | | let title = stringValue(rawWindow[kCGWindowName as String]) ?? "" |