mirror of
https://github.com/MacPass/MacPass.git
synced 2025-12-14 00:02:28 +00:00
Added Accessibilty verification for macOS 10.14 to allow for better user experince
This commit is contained in:
@@ -34,10 +34,13 @@
|
|||||||
@property (strong) IBOutlet NSWindow *matchSelectionWindow;
|
@property (strong) IBOutlet NSWindow *matchSelectionWindow;
|
||||||
@property (weak) IBOutlet NSPopUpButton *matchSelectionButton;
|
@property (weak) IBOutlet NSPopUpButton *matchSelectionButton;
|
||||||
@property (readonly, strong) DDHotKey *registredHotKey;
|
@property (readonly, strong) DDHotKey *registredHotKey;
|
||||||
|
@property (readonly, strong, class) MPAutotypeDaemon *defaultDaemon;
|
||||||
|
@property (nonatomic, readonly) BOOL autotypeSupported; // YES if the system allows for Autotype. NO if the user has denied this.
|
||||||
|
|
||||||
+ (instancetype)defaultDaemon;
|
|
||||||
- (instancetype)init NS_UNAVAILABLE;
|
- (instancetype)init NS_UNAVAILABLE;
|
||||||
|
|
||||||
|
- (void)checkForAccessibiltyPermissions;
|
||||||
|
|
||||||
- (void)performAutotypeForEntry:(KPKEntry *)entry;
|
- (void)performAutotypeForEntry:(KPKEntry *)entry;
|
||||||
- (void)performAutotypeForEntry:(KPKEntry *)entry overrideSequence:(NSString *)sequence;
|
- (void)performAutotypeForEntry:(KPKEntry *)entry overrideSequence:(NSString *)sequence;
|
||||||
- (void)selectAutotypeCandiate:(MPAutotypeContext *)context;
|
- (void)selectAutotypeCandiate:(MPAutotypeContext *)context;
|
||||||
|
|||||||
@@ -55,6 +55,8 @@ NSString *const kMPProcessIdentifierKey = @"kMPProcessIdentifierKey";
|
|||||||
|
|
||||||
@implementation MPAutotypeDaemon
|
@implementation MPAutotypeDaemon
|
||||||
|
|
||||||
|
@dynamic autotypeSupported;
|
||||||
|
|
||||||
#pragma mark -
|
#pragma mark -
|
||||||
#pragma mark Lifecylce
|
#pragma mark Lifecylce
|
||||||
|
|
||||||
@@ -93,6 +95,7 @@ static MPAutotypeDaemon *_sharedInstance;
|
|||||||
name:NSWorkspaceDidDeactivateApplicationNotification
|
name:NSWorkspaceDidDeactivateApplicationNotification
|
||||||
object:nil];
|
object:nil];
|
||||||
}
|
}
|
||||||
|
[self checkForAccessibiltyPermissions];
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -105,6 +108,14 @@ static MPAutotypeDaemon *_sharedInstance;
|
|||||||
|
|
||||||
#pragma mark -
|
#pragma mark -
|
||||||
#pragma mark Properties
|
#pragma mark Properties
|
||||||
|
- (BOOL)autotypeSupported {
|
||||||
|
if(@available(macOS 10.14, *)) {
|
||||||
|
return AXIsProcessTrusted();
|
||||||
|
}
|
||||||
|
/* macOS 10.13 and lower allows us to send key events regardless of accessibilty trust */
|
||||||
|
return YES;
|
||||||
|
}
|
||||||
|
|
||||||
- (void)setEnabled:(BOOL)enabled {
|
- (void)setEnabled:(BOOL)enabled {
|
||||||
if(_enabled != enabled) {
|
if(_enabled != enabled) {
|
||||||
_enabled = enabled;
|
_enabled = enabled;
|
||||||
@@ -122,6 +133,16 @@ static MPAutotypeDaemon *_sharedInstance;
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)checkForAccessibiltyPermissions {
|
||||||
|
if(@available(macOS 10.14, *)) {
|
||||||
|
CFStringRef keys[] = { kAXTrustedCheckOptionPrompt };
|
||||||
|
CFBooleanRef values[] = { kCFBooleanTrue };
|
||||||
|
CFDictionaryRef dictRef = CFDictionaryCreate(kCFAllocatorDefault, (const void **)keys, (const void **)values, 1, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
|
||||||
|
AXIsProcessTrustedWithOptions(dictRef);
|
||||||
|
CFRelease(dictRef);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#pragma mark -
|
#pragma mark -
|
||||||
#pragma mark Autotype Invocation
|
#pragma mark Autotype Invocation
|
||||||
- (void)performAutotypeForEntry:(KPKEntry *)entry {
|
- (void)performAutotypeForEntry:(KPKEntry *)entry {
|
||||||
|
|||||||
Reference in New Issue
Block a user