feat: improve support for crossover windows

This commit is contained in:
Zachary Wander
2023-07-02 20:50:43 +02:00
committed by Louis Pontoise
parent 01b3a428d9
commit f9f1c19b84
2 changed files with 22 additions and 8 deletions
+21 -8
View File
@@ -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)
}
+1
View File
@@ -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]