Skip to content

Commit

Permalink
chore: remove use of AXAPIEnabled() (#17)
Browse files Browse the repository at this point in the history
Function AXAPIEnabled() has been deprecated, and apparently removed at or before MacOS 12.3.
The code already checks for the presence of its replacement, AXIsProcessTrustedWithOptions().
With this change, only AXIsProcessTrustedWithOptions() is reference.
  • Loading branch information
jacobmarble committed Sep 13, 2022
1 parent 403827c commit 77377ba
Showing 1 changed file with 3 additions and 12 deletions.
15 changes: 3 additions & 12 deletions AppGrid/SDAccessibility.m
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#import "SDAccessibility.h"

extern Boolean AXIsProcessTrustedWithOptions(CFDictionaryRef options) __attribute__((weak_import));
extern Boolean AXIsProcessTrustedWithOptions(CFDictionaryRef options);
extern CFStringRef kAXTrustedCheckOptionPrompt __attribute__((weak_import));

@implementation SDAccessibility
Expand All @@ -18,20 +18,11 @@ - (void) recache {
}

+ (BOOL) isEnabled {
if (AXIsProcessTrustedWithOptions != NULL)
return AXIsProcessTrustedWithOptions(NULL);
else
return AXAPIEnabled();
return AXIsProcessTrustedWithOptions(NULL);
}

+ (void) openPanel {
if (AXIsProcessTrustedWithOptions != NULL) {
AXIsProcessTrustedWithOptions((__bridge CFDictionaryRef)@{(__bridge id)kAXTrustedCheckOptionPrompt: @YES});
}
else {
static NSString* script = @"tell application \"System Preferences\"\nactivate\nset current pane to pane \"com.apple.preference.universalaccess\"\nend tell";
[[[NSAppleScript alloc] initWithSource:script] executeAndReturnError:nil];
}
AXIsProcessTrustedWithOptions((__bridge CFDictionaryRef)@{(__bridge id)kAXTrustedCheckOptionPrompt: @YES});
}

+ (instancetype) singleton {
Expand Down

0 comments on commit 77377ba

Please sign in to comment.