diff --git a/src/api-wrappers/AXUIElement.swift b/src/api-wrappers/AXUIElement.swift index 18195fcb..ccd5ee19 100644 --- a/src/api-wrappers/AXUIElement.swift +++ b/src/api-wrappers/AXUIElement.swift @@ -1,4 +1,10 @@ import Cocoa +import ApplicationServices.HIServices.AXUIElement +import ApplicationServices.HIServices.AXValue +import ApplicationServices.HIServices.AXError +import ApplicationServices.HIServices.AXRoleConstants +import ApplicationServices.HIServices.AXAttributeConstants +import ApplicationServices.HIServices.AXActionConstants // if the window server is busy, it may not reply to AX calls. We retry right before the call times-out and returns a bogus value func retryAxCallUntilTimeout(_ group: DispatchGroup? = nil, _ fn: @escaping () throws -> Void, _ startTime: DispatchTime = DispatchTime.now()) { diff --git a/src/logic/Application.swift b/src/logic/Application.swift index 74ded6f4..152dd201 100644 --- a/src/logic/Application.swift +++ b/src/logic/Application.swift @@ -1,4 +1,5 @@ import Cocoa +import ApplicationServices.HIServices.AXNotificationConstants class Application: NSObject { // kvObservers should be listed first, so it gets deinit'ed first; otherwise it can crash @@ -22,10 +23,10 @@ class Application: NSObject { kAXApplicationShownNotification, kAXFocusedUIElementChangedNotification, ] - // workaround: Protégé exhibits bugs when we subscribe to its kAXFocusedUIElementChangedNotification - // we don't know what's happening; we hardcode this exception to make the app usable - if app.bundleIdentifier == "edu.stanford.protege" { - n.remove(at: 5) + // workaround: some apps exhibit bugs when we subscribe to its kAXFocusedUIElementChangedNotification + // we don't know what's happening; we avoid this subscription to make these app usable + if app.bundleIdentifier == "edu.stanford.protege" || app.bundleIdentifier?.range(of: "^com\\.jetbrains\\..+?EAP$", options: .regularExpression) != nil { + return n.filter { $0 != kAXFocusedUIElementChangedNotification } } return n } diff --git a/src/logic/events/AccessibilityEvents.swift b/src/logic/events/AccessibilityEvents.swift index f40b81c0..3b9ac6ff 100644 --- a/src/logic/events/AccessibilityEvents.swift +++ b/src/logic/events/AccessibilityEvents.swift @@ -1,4 +1,6 @@ import Cocoa +import ApplicationServices.HIServices.AXUIElement +import ApplicationServices.HIServices.AXNotificationConstants func axObserverCallback(observer: AXObserver, element: AXUIElement, notificationName: CFString, _: UnsafeMutableRawPointer?) -> Void { let type = notificationName as String