diff --git a/src/api-wrappers/AXUIElement.swift b/src/api-wrappers/AXUIElement.swift index 355185209..3e52d4e2b 100644 --- a/src/api-wrappers/AXUIElement.swift +++ b/src/api-wrappers/AXUIElement.swift @@ -56,7 +56,8 @@ extension AXUIElement { books(runningApp) || ( // CGWindowLevel == .normalWindow helps filter out iStats Pro and other top-level pop-overs, and floating windows isOnNormalLevel && - (["AXStandardWindow", "AXDialog"].contains(subrole) || + ([kAXStandardWindowSubrole, kAXDialogSubrole].contains(subrole) || + adobeAudition(runningApp, subrole) || steam(runningApp, title, role) || worldOfWarcraft(runningApp, role) || battleNetBootstrapper(runningApp, role) || @@ -67,6 +68,11 @@ extension AXUIElement { drBetotte(runningApp))) } + private func adobeAudition(_ runningApp: NSRunningApplication, _ subrole: String?) -> Bool { + // Books.app has animations on window creation. This means windows are originally created with subrole == AXUnknown or isOnNormalLevel == false + return runningApp.bundleIdentifier == "com.adobe.Audition" && subrole == kAXFloatingWindowSubrole + } + private func books(_ runningApp: NSRunningApplication) -> Bool { // Books.app has animations on window creation. This means windows are originally created with subrole == AXUnknown or isOnNormalLevel == false return runningApp.bundleIdentifier == "com.apple.iBooksX" @@ -74,12 +80,12 @@ extension AXUIElement { private func worldOfWarcraft(_ runningApp: NSRunningApplication, _ role: String?) -> Bool { // Battlenet bootstrapper windows have subrole == AXUnknown - return runningApp.bundleIdentifier == "com.blizzard.worldofwarcraft" && role == "AXWindow" + return runningApp.bundleIdentifier == "com.blizzard.worldofwarcraft" && role == kAXWindowRole } private func battleNetBootstrapper(_ runningApp: NSRunningApplication, _ role: String?) -> Bool { // Battlenet bootstrapper windows have subrole == AXUnknown - return runningApp.bundleIdentifier == "net.battle.bootstrapper" && role == "AXWindow" + return runningApp.bundleIdentifier == "net.battle.bootstrapper" && role == kAXWindowRole } private func drBetotte(_ runningApp: NSRunningApplication) -> Bool { @@ -102,7 +108,7 @@ extension AXUIElement { private func firefoxFullscreenVideo(_ runningApp: NSRunningApplication, _ role: String?) -> Bool { // Firefox fullscreen video have subrole == AXUnknown if fullscreen'ed when the base window is not fullscreen - return (runningApp.bundleIdentifier?.hasPrefix("org.mozilla.firefox") ?? false) && role == "AXWindow" + return (runningApp.bundleIdentifier?.hasPrefix("org.mozilla.firefox") ?? false) && role == kAXWindowRole } private func androidEmulator(_ runningApp: NSRunningApplication, _ title: String?) -> Bool { diff --git a/src/logic/Applications.swift b/src/logic/Applications.swift index 733f9cfda..fd5027f54 100644 --- a/src/logic/Applications.swift +++ b/src/logic/Applications.swift @@ -69,8 +69,8 @@ class Applications { if !App.app.appIsBeingUsed || Preferences.hideAppBadges { return } retryAxCallUntilTimeout { if let dockPid = (list.first { $0.runningApplication.bundleIdentifier == "com.apple.dock" }?.pid), - let axList = (try AXUIElementCreateApplication(dockPid).children()?.first { try $0.role() == "AXList" }), - let axAppDockItem = (try axList.children()?.filter { try $0.subrole() == "AXApplicationDockItem" && ($0.appIsRunning() ?? false) }) { + let axList = (try AXUIElementCreateApplication(dockPid).children()?.first { try $0.role() == kAXListRole }), + let axAppDockItem = (try axList.children()?.filter { try $0.subrole() == kAXApplicationDockItemSubrole && ($0.appIsRunning() ?? false) }) { let axAppDockItemUrlAndLabel = try axAppDockItem.map { try ($0.attribute(kAXURLAttribute, URL.self), $0.attribute(kAXStatusLabelAttribute, String.self)) } DispatchQueue.main.async { refreshBadges_(axAppDockItemUrlAndLabel) diff --git a/src/logic/events/AccessibilityEvents.swift b/src/logic/events/AccessibilityEvents.swift index 203f87e6b..d5d4a4aab 100644 --- a/src/logic/events/AccessibilityEvents.swift +++ b/src/logic/events/AccessibilityEvents.swift @@ -31,7 +31,7 @@ func handleEvent(_ type: String, _ element: AXUIElement) throws { debugPrint("Accessibility event", type, type != kAXFocusedUIElementChangedNotification ? (try element.title() ?? "nil") : "nil") // events are handled concurrently, thus we check that the app is still running if let pid = try element.pid(), - try (!(type == kAXWindowCreatedNotification && pid == ProcessInfo.processInfo.processIdentifier && element.subrole() == "AXUnknown")) { + try (!(type == kAXWindowCreatedNotification && pid == ProcessInfo.processInfo.processIdentifier && element.subrole() == kAXUnknownSubrole)) { switch type { case kAXApplicationActivatedNotification: try applicationActivated(element) case kAXApplicationHiddenNotification,