FEAT(client): Use Input Monitoring instead of Accessibility for macOS…#7065
FEAT(client): Use Input Monitoring instead of Accessibility for macOS…#7065nicholas-lonsinger wants to merge 1 commit intomumble-voip:masterfrom
Conversation
WalkthroughUpdates macOS global-shortcut handling and docs to distinguish Input Monitoring (macOS 10.15+) from Accessibility (macOS 10.9–10.14). Adds runtime helpers to detect and request the appropriate permission, opens the correct privacy/settings pane, and updates UI text and buttons. Objective-C++ changes call the new permission flow at startup, switch the CGEventTap to listen-only, and disable event suppression. Info.plist usage text for accessibility was adjusted. Possibly related issues
Possibly related PRs
Suggested labels
Suggested reviewers
🚥 Pre-merge checks | ✅ 2✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Tip Issue Planner is now in beta. Read the docs and try it out! Share your feedback on Discord. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Fix all issues with AI agents
In `@src/mumble/GlobalShortcut_macx.mm`:
- Around line 138-140: Wrap the call to CGRequestListenEventAccess() in a
compile-time SDK guard so the symbol is only referenced when building against
macOS 10.15+ SDKs: add an `#if` check around the CGRequestListenEventAccess()
invocation that tests MAC_OS_X_VERSION_MAX_ALLOWED (or
MAC_OS_X_VERSION_MIN_REQUIRED) for MAC_OS_X_VERSION_10_15 (or uses an equivalent
macro check pattern used elsewhere in the codebase), keeping the existing
runtime __builtin_available(macOS 10.15, *) check intact; leave the
kCGEventTapOptionListenOnly usage as-is since it is available on older SDKs.
In `@src/mumble/GlobalShortcut.cpp`:
- Around line 642-653: The Input Monitoring UI text and prefs link are gated for
10.9+ (OSXMavericks) but must be limited to macOS 10.15+ to match
CMAKE_OSX_DEPLOYMENT_TARGET and showWarning() behavior; update the checks in
reload() and commit() to use a 10.15 version guard (e.g. current >=
QOperatingSystemVersion(10,15)) instead of OSXMavericks, and likewise guard
on_qpbOpenAccessibilityPrefs_clicked() so the Privacy_ListenEvent link is only
used when macOS 10.15+ is available (or wrap it with __builtin_available(macOS
10.15, *)). Repeat these changes for the other similar blocks (the sections
noted around the other ranges) and ensure label/qpbOpenAccessibilityPrefs text
and visibility are only set for 10.15+.
- Around line 672-684: The call to CGPreflightListenEventAccess() inside the
macOS runtime check must be wrapped with a compile-time SDK guard to avoid build
errors on older SDKs; modify the block containing __builtin_available(macOS
10.15, *) in GlobalShortcut.cpp so that the line calling
CGPreflightListenEventAccess() is only compiled when
MAC_OS_X_VERSION_MAX_ALLOWED >= 101500 (keep the existing __builtin_available
runtime check intact), and preserve the existing `#if`
MAC_OS_X_VERSION_MAX_ALLOWED >= 1090 else fallback
(AXIsProcessTrustedWithOptions / QFile check) so older SDKs and runtimes still
use the fallback paths.
cc056d5 to
9d7eb90
Compare
|
The changes requested by code rabbit were to add more checks for architectures prior to the macOS build target of macOS 10.15. I would recommend not doing these changes (In fact I removed the checks in a subsequent squash/force push) for the following reasons:
|
901a034 to
291af77
Compare
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/mumble/GlobalShortcut.cpp (1)
652-663:⚠️ Potential issue | 🟡 Minor
eventFilterpath may show the warning container with the button still hidden.The
eventFilteronWindowActivate(line 656) sets the warning container visible viashowWarning(), but does not unhideqpbOpenInputMonitoringSettings. If the button was hidden in the constructor (line 643) andreload()never unhid it (e.g., permission was previously granted), a subsequentWindowActivatewhereshowWarning()now returnstruewould display the warning text without the "Open Privacy Settings" button.This is an unlikely edge case (would require revoking Input Monitoring while the settings dialog is open), but it would leave users with a warning and no actionable button.
Suggested fix: also manage button visibility in eventFilter
if (e->type() == QEvent::WindowActivate) { if (!Global::get().s.bSuppressMacEventTapWarning) { - qwWarningContainer->setVisible(showWarning()); + bool warn = showWarning(); + qwWarningContainer->setVisible(warn); + if (warn) { + qpbOpenInputMonitoringSettings->setHidden(false); + } } }Also applies to: 865-874
🧹 Nitpick comments (1)
src/mumble/GlobalShortcut_macx.mm (1)
65-170: Dead suppression logic in the callback — consider a clarifying comment.With
kCGEventTapOptionListenOnly, the return value of the callback is ignored by the system. Thesuppressvariable computation (lines 69, 85, 120, 133) and thereturn suppress ? nullptr : eventon line 170 are now effectively dead code. The PR description states this is intentionally preserved for future re-use.A brief comment near line 69 or line 170 noting that suppression is dormant under listen-only mode would help future readers understand this is deliberate rather than an oversight.
Suggested clarifying comment
+ // Note: With kCGEventTapOptionListenOnly, the return value of this callback + // is ignored by the system. Suppression logic is retained for potential future + // reactivation with kCGEventTapOptionDefault. return suppress ? nullptr : event;
…hortcuts Use Input Monitoring permission instead of Accessibility for macOS global shortcuts, with runtime fallback to Accessibility API for older systems. This change: - Uses @available runtime checks to select the appropriate permission API based on the running macOS version - macOS 10.15+ (Catalina): Uses Input Monitoring API (CGPreflightListenEventAccess/CGRequestListenEventAccess) - macOS 10.9 - 10.14: Falls back to Accessibility API - Updates UI to reference the correct permission type - Opens the correct System Settings pane for the detected API - Helper functions in GlobalShortcut_macx.mm encapsulate version checks and are callable from C++ code via extern "C" linkage - Adds proactive permission prompt for older macOS using AXIsProcessTrustedWithOptions with kAXTrustedCheckOptionPrompt, ensuring users see a system dialog on all supported versions - Updates GlobalShortcuts.md documentation with version-specific instructions for both Input Monitoring and Accessibility permissions - Adds Input Monitoring screenshot for documentation This allows a single binary to support older deployment targets while using the correct permission system at runtime. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
291af77 to
4b29cd6
Compare
|
I have two versions of this update, the current version includes support for the 1.5 branch and will use Input Monitoring by default but will switch to Accessibility on older < 10.15 version of Mac OS (probably very few people). This can help improve the security of the app on the older OS while preserving support. If this is good then I would submit a second version of this just for the master branch that would be for the newer macOS version (currently oldest support is macOS 14), so it wouldn't need any reference to Accessibility. If you just want to apply it to just the master though I can change it so it's only Input Monitoring based so it wouldn't need the dead code in there anymore. |
… global shortcuts
Replace the Accessibility permission requirement with the lesser Input Monitoring permission for macOS global shortcuts (Push-to-Talk). The event tap is now created in listen-only mode (kCGEventTapOptionListenOnly) which only requires Input Monitoring permission on macOS 10.15+.
Key changes:
All existing suppression code is left intact but dormant, as it may be re-added or removed at a later point.
Checks