From 0d5a72344a1d3feb7e802de4cd56aa161230714e Mon Sep 17 00:00:00 2001 From: Art Ginzburg Date: Wed, 29 Mar 2023 23:41:44 +0400 Subject: [PATCH] Prevent unresponsive trackpad after revoking Accessibility permission - Use `AXIsProcessTrustedWithOptions` instead of `AXIsProcessTrusted` - Use event tap option `.listenOnly` instead of `.default` closes #63 Co-Authored-By: Ilya Rodionov --- MiddleClick/Controller.m | 2 +- MiddleClick/TrayMenu.m | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/MiddleClick/Controller.m b/MiddleClick/Controller.m index 2311761..9edb7a0 100644 --- a/MiddleClick/Controller.m +++ b/MiddleClick/Controller.m @@ -164,7 +164,7 @@ - (void)registerMouseCallback:(NSAutoreleasePool*)pool // create eventTap which listens for core grpahic events with the filter // sepcified above (so left mouse down and up again) CFMachPortRef eventTap = CGEventTapCreate( - kCGHIDEventTap, kCGHeadInsertEventTap, kCGEventTapOptionDefault, + kCGHIDEventTap, kCGHeadInsertEventTap, kCGEventTapOptionListenOnly, eventMask, mouseCallback, NULL); currentEventTap = eventTap; diff --git a/MiddleClick/TrayMenu.m b/MiddleClick/TrayMenu.m index 301e6ca..9537f34 100644 --- a/MiddleClick/TrayMenu.m +++ b/MiddleClick/TrayMenu.m @@ -14,7 +14,8 @@ - (id)initWithController:(Controller*)ctrl - (void)initAccessibilityPermissionStatus:(NSMenu*)menu { - BOOL hasAccessibilityPermission = AXIsProcessTrusted(); + NSDictionary *options = @{(id)kAXTrustedCheckOptionPrompt: @YES}; + BOOL hasAccessibilityPermission = AXIsProcessTrustedWithOptions((CFDictionaryRef)options); [self updateAccessibilityPermissionStatus:menu hasAccessibilityPermission:hasAccessibilityPermission];