From e50261a99c0ed6911aa16331dde730223fe4a2e1 Mon Sep 17 00:00:00 2001 From: Jonathan White Date: Sun, 13 Oct 2019 21:59:10 -0400 Subject: [PATCH] macOS 10.15: Request screen reader permission for AutoType * Fix #3609 - Request screen reader permission by faking a 1px screenshot. Thanks to MacPass for this idea. * Fix #3578 - Remove duplicate sandbox entitlement * Fix #3270 - Use executable path reference for libquazip --- share/macosx/keepassxc.entitlements | 2 -- src/cli/CMakeLists.txt | 2 ++ src/gui/macutils/AppKitImpl.mm | 11 +++++++++++ 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/share/macosx/keepassxc.entitlements b/share/macosx/keepassxc.entitlements index a63705585..be766090c 100644 --- a/share/macosx/keepassxc.entitlements +++ b/share/macosx/keepassxc.entitlements @@ -8,8 +8,6 @@ production com.apple.security.network.client - com.apple.security.app-sandbox - com.apple.security.print com.apple.security.app-sandbox diff --git a/src/cli/CMakeLists.txt b/src/cli/CMakeLists.txt index 1fdd85aa7..9ae438db2 100644 --- a/src/cli/CMakeLists.txt +++ b/src/cli/CMakeLists.txt @@ -105,6 +105,8 @@ if(APPLE AND WITH_APP_BUNDLE) "@executable_path/../Frameworks/libyubikey.0.dylib" -change /usr/local/opt/ykpers/lib/libykpers-1.1.dylib "@executable_path/../Frameworks/libykpers-1.1.dylib" + -change /usr/local/opt/quazip/lib/libquazip.1.dylib + "@executable_path/../Frameworks/libquazip.1.dylib" keepassxc-cli COMMENT "Changing linking of keepassxc-cli") diff --git a/src/gui/macutils/AppKitImpl.mm b/src/gui/macutils/AppKitImpl.mm index 9bfbc8de7..fa0128569 100644 --- a/src/gui/macutils/AppKitImpl.mm +++ b/src/gui/macutils/AppKitImpl.mm @@ -144,6 +144,17 @@ static const NSEventMask NSEventMaskKeyDown = NSKeyDownMask; // - (bool) enableAccessibility { + // Request a 1 pixel screenshot to trigger the permissions + // required for screen reader access. These are necessary + // for Auto-Type to find the window titles in macOS 10.15+ + CGImageRef screenshot = CGWindowListCreateImage( + CGRectMake(0, 0, 1, 1), + kCGWindowListOptionOnScreenOnly, + kCGNullWindowID, + kCGWindowImageDefault); + CFRelease(screenshot); + + // Request accessibility permissions for Auto-Type type on behalf of the user NSDictionary* opts = @{static_cast(kAXTrustedCheckOptionPrompt): @YES}; return AXIsProcessTrustedWithOptions(static_cast(opts)); }