diff --git a/src/api-wrappers/AXUIElement.swift b/src/api-wrappers/AXUIElement.swift index fe34018f..91a688ed 100644 --- a/src/api-wrappers/AXUIElement.swift +++ b/src/api-wrappers/AXUIElement.swift @@ -83,11 +83,17 @@ extension AXUIElement { // debugPrint(runningApp.bundleIdentifier, title, level, CGWindow.normalLevel, subrole, role, size) // Some non-windows have cgWindowId == 0 (e.g. windows of apps starting at login with the checkbox "Hidden" checked) - return wid != 0 && size != nil && - (books(runningApp) || keynote(runningApp) || iina(runningApp) || openFlStudio(runningApp, title) || ( + return wid != 0 && size != nil && ( + ( + books(runningApp) || + keynote(runningApp) || + iina(runningApp) || + openFlStudio(runningApp, title) || + crossoverWindow(runningApp, role, subrole, level) + ) || ( // CGWindowLevel == .normalWindow helps filter out iStats Pro and other top-level pop-overs, and floating windows - level == CGWindow.normalLevel && - ([kAXStandardWindowSubrole, kAXDialogSubrole].contains(subrole) || + level == CGWindow.normalLevel && ( + [kAXStandardWindowSubrole, kAXDialogSubrole].contains(subrole) || openBoard(runningApp) || adobeAudition(runningApp, subrole) || adobeAfterEffects(runningApp, subrole) || @@ -100,11 +106,13 @@ extension AXUIElement { dvdFab(runningApp) || drBetotte(runningApp) || androidEmulator(runningApp, title) - ) && + ) && ( mustHaveIfJetbrainApp(runningApp, title, subrole, size!) && - mustHaveIfSteam(runningApp, title, role) && - mustHaveIfColorSlurp(runningApp, title, subrole) - )) + mustHaveIfSteam(runningApp, title, role) && + mustHaveIfColorSlurp(runningApp, title, subrole) + ) + ) + ) } private static func mustHaveIfJetbrainApp(_ runningApp: NSRunningApplication, _ title: String?, _ subrole: String?, _ size: NSSize) -> Bool { @@ -205,6 +213,11 @@ extension AXUIElement { return title != "" && Applications.isAndroidEmulator(runningApp) } + private static func crossoverWindow(_ runningApp: NSRunningApplication, _ role: String?, _ subrole: String?, _ level: CGWindowLevel) -> Bool { + return runningApp.bundleIdentifier == nil && role == kAXWindowRole && subrole == kAXUnknownSubrole && level == CGWindow.baseLevel + && (runningApp.localizedName == "wine64-preloader" || runningApp.executableURL?.absoluteString.contains("/winetemp-") ?? false) + } + func position() throws -> CGPoint? { return try value(kAXPositionAttribute, CGPoint.zero, .cgPoint) } diff --git a/src/api-wrappers/CGWindow.swift b/src/api-wrappers/CGWindow.swift index e0639d9f..1f1f997f 100644 --- a/src/api-wrappers/CGWindow.swift +++ b/src/api-wrappers/CGWindow.swift @@ -4,6 +4,7 @@ typealias CGWindow = [CFString: Any] extension CGWindow { static let normalLevel = CGWindowLevelForKey(.normalWindow) + static let baseLevel = CGWindowLevelForKey(.baseWindow) static func windows(_ option: CGWindowListOption) -> [CGWindow] { return CGWindowListCopyWindowInfo([.excludeDesktopElements, option], kCGNullWindowID) as! [CGWindow]