Skip to content

Commit

Permalink
fix: adobe audition windows were not showing up (closes #581)
Browse files Browse the repository at this point in the history
  • Loading branch information
lwouis committed Sep 8, 2020
1 parent 29eff03 commit 6edced0
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
14 changes: 10 additions & 4 deletions src/api-wrappers/AXUIElement.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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) ||
Expand All @@ -67,19 +68,24 @@ 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"
}

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 {
Expand All @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions src/logic/Applications.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/logic/events/AccessibilityEvents.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 6edced0

Please sign in to comment.