fix: shortcuts temporarily stuck in intellij eap (closes #652)

This commit is contained in:
Louis Pontoise authored and lwouis committed 2020-10-15 23:39:13 +09:00
1 parent 16c7a9319a
commit 7c171c26cb
3 files changed
+13 -4

No files matched your search

+6
View File
@@ -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()) {
+5 -4
View File
@@ -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
}
@@ -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