Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 21 additions & 2 deletions docs/GlobalShortcuts.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,25 @@ regardless of the user they're running under!

## macOS

Mumble needs to be granted accessibility permissions.
Mumble needs permission to monitor keyboard and mouse input for global shortcuts
(e.g. Push-to-Talk) to work. The required permission depends on your macOS version:

![macOS screenshot](../screenshots/macOS_privacy_accessibility.png)
### macOS 10.15 (Catalina) and later

Grant **Input Monitoring** permission:

1. Open **System Settings** > **Privacy & Security** > **Input Monitoring**
2. Enable the checkbox next to **Mumble**

![macOS Input Monitoring screenshot](../screenshots/macOS_privacy_input_monitoring.png)

### macOS 10.9 - 10.14

Grant **Accessibility** permission:

1. Open **System Preferences** > **Security & Privacy** > **Privacy** > **Accessibility**
2. Click the lock to make changes, then enable the checkbox next to **Mumble**

![macOS Accessibility screenshot](../screenshots/macOS_privacy_accessibility.png)

Mumble will automatically detect your macOS version and open the correct settings pane.
Binary file added screenshots/macOS_privacy_input_monitoring.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
57 changes: 20 additions & 37 deletions src/mumble/GlobalShortcut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@
#include <QtWidgets/QToolTip>

#ifdef Q_OS_MAC
# include <ApplicationServices/ApplicationServices.h>
# include <QtCore/QOperatingSystemVersion>
# include "GlobalShortcut_macx.h"
#endif

#include <cassert>
Expand Down Expand Up @@ -639,25 +638,13 @@ GlobalShortcutConfig::GlobalShortcutConfig(Settings &st) : ConfigWidget(st) {
#endif

#ifdef Q_OS_MAC
// Help Mac users enable accessibility access for Mumble...
const QOperatingSystemVersion current = QOperatingSystemVersion::current();
if (current >= QOperatingSystemVersion::OSXMavericks) {
qpbOpenAccessibilityPrefs->setHidden(true);
label->setText(tr("<html><head/><body>"
"<p>"
"Mumble can currently only use mouse buttons and keyboard modifier keys (Alt, Ctrl, Cmd, "
"etc.) for global shortcuts."
"</p>"
"<p>"
"If you want more flexibility, you can add Mumble as a trusted accessibility program in the "
"Security & Privacy section "
"of your Mac's System Preferences."
"</p>"
"<p>"
"In the Security & Privacy preference pane, change to the Privacy tab. Then choose "
"Accessibility (near the bottom) in "
"the list to the left. Finally, add Mumble to the list of trusted accessibility programs."
"</body></html>"));
// Help Mac users enable the appropriate permission for Mumble.
// On macOS 10.15+, this is Input Monitoring; on older versions, it's Accessibility.
qpbOpenInputMonitoringSettings->setHidden(true);
if (!macOS_usesInputMonitoring()) {
// Update the label text for older macOS versions that use Accessibility
label->setText(tr("<html><head/><body><p>Mumble needs <b>Accessibility</b> permission to use global "
"shortcuts such as Push-to-Talk.</p></body></html>"));
}
#endif
}
Expand All @@ -677,24 +664,16 @@ bool GlobalShortcutConfig::eventFilter(QObject * /*object*/, QEvent *e) {

bool GlobalShortcutConfig::showWarning() const {
#ifdef Q_OS_MAC
# if MAC_OS_X_VERSION_MAX_ALLOWED >= 1090
const QOperatingSystemVersion current = QOperatingSystemVersion::current();
if (current >= QOperatingSystemVersion::OSXMavericks) {
return !AXIsProcessTrustedWithOptions(nullptr);
} else
# endif
{
return !QFile::exists(QLatin1String("/private/var/db/.AccessibilityAPIEnabled"));
}
#endif
return !macOS_hasGlobalShortcutPermission();
#else
return false;
#endif
}

void GlobalShortcutConfig::on_qpbOpenAccessibilityPrefs_clicked() {
QStringList args;
args << QLatin1String("/Applications/System Preferences.app");
args << QLatin1String("/System/Library/PreferencePanes/UniversalAccessPref.prefPane");
(void) QProcess::startDetached(QLatin1String("/usr/bin/open"), args);
void GlobalShortcutConfig::on_qpbOpenInputMonitoringSettings_clicked() {
#ifdef Q_OS_MAC
macOS_openPrivacySettings();
#endif
}

void GlobalShortcutConfig::on_qpbSkipWarning_clicked() {
Expand Down Expand Up @@ -885,7 +864,11 @@ void GlobalShortcutConfig::reload() {
}
#ifdef Q_OS_MAC
if (!Global::get().s.bSuppressMacEventTapWarning) {
qwWarningContainer->setVisible(showWarning());
bool warn = showWarning();
qwWarningContainer->setVisible(warn);
if (warn) {
qpbOpenInputMonitoringSettings->setHidden(false);
}
} else {
qwWarningContainer->setVisible(false);
}
Expand Down
2 changes: 1 addition & 1 deletion src/mumble/GlobalShortcut.h
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ public slots:
void on_qpbRemove_clicked(bool);
void on_qtwShortcuts_currentItemChanged(QTreeWidgetItem *, QTreeWidgetItem *);
void on_qtwShortcuts_itemChanged(QTreeWidgetItem *, int);
void on_qpbOpenAccessibilityPrefs_clicked();
void on_qpbOpenInputMonitoringSettings_clicked();
void on_qpbSkipWarning_clicked();
};

Expand Down
6 changes: 3 additions & 3 deletions src/mumble/GlobalShortcut.ui
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Mumble can currently only use mouse buttons and keyboard modifier keys (Alt, Ctrl, Cmd, etc.) for global shortcuts.&lt;/p&gt;&lt;p&gt;If you want more flexibility, you can enable &lt;span style=&quot; font-style:italic;&quot;&gt;Access for assistive devices&lt;/span&gt; in the system's Accessibility preferences. However, please note that this change also potentially allows malicious programs to read what is typed on your keyboard.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Mumble needs &lt;b&gt;Input Monitoring&lt;/b&gt; permission to use global shortcuts such as Push-to-Talk.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="textFormat">
<enum>Qt::RichText</enum>
Expand All @@ -58,9 +58,9 @@
</spacer>
</item>
<item>
<widget class="QPushButton" name="qpbOpenAccessibilityPrefs">
<widget class="QPushButton" name="qpbOpenInputMonitoringSettings">
<property name="text">
<string>Open Accessibility Preferences</string>
<string>Open Privacy Settings</string>
</property>
</widget>
</item>
Expand Down
28 changes: 28 additions & 0 deletions src/mumble/GlobalShortcut_macx.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,34 @@
#include "Global.h"
#include "GlobalShortcut.h"

// Helper functions for runtime macOS version checking.
// These allow C++ code to check and request the appropriate permission
// (Input Monitoring on macOS 10.15+, Accessibility on older versions).
#ifdef __cplusplus
extern "C" {
#endif

/// Check if the app has the necessary permission for global shortcuts.
/// On macOS 10.15+, checks Input Monitoring; on older versions, checks Accessibility.
bool macOS_hasGlobalShortcutPermission();

/// Request the necessary permission for global shortcuts.
/// On macOS 10.15+, requests Input Monitoring; on older versions, this is a no-op
/// (Accessibility permission is requested automatically when the event tap fails).
void macOS_requestGlobalShortcutPermission();

/// Open the appropriate Privacy settings pane in System Preferences.
/// On macOS 10.15+, opens Input Monitoring; on older versions, opens Accessibility.
void macOS_openPrivacySettings();

/// Returns true if the current macOS version uses Input Monitoring (10.15+),
/// false if it uses Accessibility (10.14 and earlier).
bool macOS_usesInputMonitoring();

#ifdef __cplusplus
}
#endif

class GlobalShortcutMac : public GlobalShortcutEngine {
private:
Q_OBJECT
Expand Down
53 changes: 51 additions & 2 deletions src/mumble/GlobalShortcut_macx.mm
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,50 @@
#define MOD_OFFSET 0x10000
#define MOUSE_OFFSET 0x20000

// Helper functions for runtime macOS version checking.
// These allow GlobalShortcut.cpp (C++) to use the appropriate permission API
// based on the running macOS version.

bool macOS_hasGlobalShortcutPermission() {
if (@available(macOS 10.15, *)) {
// macOS 10.15+ (Catalina): Use Input Monitoring API
return CGPreflightListenEventAccess();
} else {
// macOS 10.9 - 10.14: Use Accessibility API
return AXIsProcessTrustedWithOptions(nullptr);
}
}

void macOS_requestGlobalShortcutPermission() {
if (@available(macOS 10.15, *)) {
// macOS 10.15+ (Catalina): Request Input Monitoring permission
CGRequestListenEventAccess();
} else {
// macOS 10.9 - 10.14: Request Accessibility permission with system prompt
NSDictionary *options = @{(__bridge NSString *) kAXTrustedCheckOptionPrompt: @YES };
AXIsProcessTrustedWithOptions((__bridge CFDictionaryRef) options);
}
}

void macOS_openPrivacySettings() {
NSString *urlString;
if (@available(macOS 10.15, *)) {
// macOS 10.15+: Open Input Monitoring settings
urlString = @"x-apple.systempreferences:com.apple.preference.security?Privacy_ListenEvent";
} else {
// macOS 10.9 - 10.14: Open Accessibility settings
urlString = @"x-apple.systempreferences:com.apple.preference.security?Privacy_Accessibility";
}
[[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:urlString]];
}

bool macOS_usesInputMonitoring() {
if (@available(macOS 10.15, *)) {
return true;
}
return false;
}

GlobalShortcutEngine *GlobalShortcutEngine::platformInit() {
return new GlobalShortcutMac();
}
Expand Down Expand Up @@ -135,6 +179,11 @@
return;
#endif

// Request the appropriate permission based on macOS version.
// On macOS 10.15+, this requests Input Monitoring permission.
// On older versions, permission is requested automatically when the event tap fails.
macOS_requestGlobalShortcutPermission();

CGEventMask evmask = CGEventMaskBit(kCGEventLeftMouseDown) |
CGEventMaskBit(kCGEventLeftMouseUp) |
CGEventMaskBit(kCGEventRightMouseDown) |
Expand All @@ -151,7 +200,7 @@
CGEventMaskBit(kCGEventScrollWheel);
port = CGEventTapCreate(kCGSessionEventTap,
kCGTailAppendEventTap,
kCGEventTapOptionDefault, // active filter (not only a listener)
kCGEventTapOptionListenOnly,
evmask,
GlobalShortcutMac::callback,
this);
Expand Down Expand Up @@ -478,7 +527,7 @@
}

bool GlobalShortcutMac::canSuppress() {
return true;
return false;
}

bool GlobalShortcutMac::canDisable() {
Expand Down
2 changes: 1 addition & 1 deletion src/mumble/mumble.plist.in
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,6 @@
<key>NSMicrophoneUsageDescription</key>
<string>Mumble uses your microphone to allow you to talk to other people</string>
<key>NSAccessibilityUsageDescription</key>
<string>Mumble needs accessibility permission for global shortcuts</string>
<string>Mumble needs accessibility permission for global shortcuts such as Push-to-Talk on older macOS versions</string>
</dict>
</plist>
24 changes: 12 additions & 12 deletions src/mumble/mumble_ar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3700,14 +3700,6 @@ Label of the server. This is what the server will be named like in your server l
<source>&amp;Remove</source>
<translation type="unfinished">و حذف</translation>
</message>
<message>
<source>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Mumble can currently only use mouse buttons and keyboard modifier keys (Alt, Ctrl, Cmd, etc.) for global shortcuts.&lt;/p&gt;&lt;p&gt;If you want more flexibility, you can enable &lt;span style=&quot; font-style:italic;&quot;&gt;Access for assistive devices&lt;/span&gt; in the system&apos;s Accessibility preferences. However, please note that this change also potentially allows malicious programs to read what is typed on your keyboard.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Open Accessibility Preferences</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Skip</source>
<translation type="unfinished"></translation>
Expand Down Expand Up @@ -3774,6 +3766,14 @@ Without this option enabled, using Mumble&apos;s global shortcuts in privileged
<source>This removes the selected entry from the &quot;Configured Shortcut&quot; tree above</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Mumble needs &lt;b&gt;Input Monitoring&lt;/b&gt; permission to use global shortcuts such as Push-to-Talk.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Open Privacy Settings</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>GlobalShortcutButtons</name>
Expand Down Expand Up @@ -3816,10 +3816,6 @@ Without this option enabled, using Mumble&apos;s global shortcuts in privileged
</context>
<context>
<name>GlobalShortcutConfig</name>
<message>
<source>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Mumble can currently only use mouse buttons and keyboard modifier keys (Alt, Ctrl, Cmd, etc.) for global shortcuts.&lt;/p&gt;&lt;p&gt;If you want more flexibility, you can add Mumble as a trusted accessibility program in the Security &amp; Privacy section of your Mac&apos;s System Preferences.&lt;/p&gt;&lt;p&gt;In the Security &amp; Privacy preference pane, change to the Privacy tab. Then choose Accessibility (near the bottom) in the list to the left. Finally, add Mumble to the list of trusted accessibility programs.&lt;/body&gt;&lt;/html&gt;</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Shortcuts</source>
<translation type="unfinished"></translation>
Expand Down Expand Up @@ -3849,6 +3845,10 @@ Without this option enabled, using Mumble&apos;s global shortcuts in privileged
<source>Shortcut input combinations</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Mumble needs &lt;b&gt;Accessibility&lt;/b&gt; permission to use global shortcuts such as Push-to-Talk.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Unassigned</source>
<translation type="unfinished"></translation>
Expand Down
24 changes: 12 additions & 12 deletions src/mumble/mumble_bg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3697,14 +3697,6 @@ Label of the server. This is what the server will be named like in your server l
<source>&amp;Remove</source>
<translation>&amp;Премахване</translation>
</message>
<message>
<source>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Mumble can currently only use mouse buttons and keyboard modifier keys (Alt, Ctrl, Cmd, etc.) for global shortcuts.&lt;/p&gt;&lt;p&gt;If you want more flexibility, you can enable &lt;span style=&quot; font-style:italic;&quot;&gt;Access for assistive devices&lt;/span&gt; in the system&apos;s Accessibility preferences. However, please note that this change also potentially allows malicious programs to read what is typed on your keyboard.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Open Accessibility Preferences</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Skip</source>
<translation>Пропускане</translation>
Expand Down Expand Up @@ -3771,6 +3763,14 @@ Without this option enabled, using Mumble&apos;s global shortcuts in privileged
<source>This removes the selected entry from the &quot;Configured Shortcut&quot; tree above</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Mumble needs &lt;b&gt;Input Monitoring&lt;/b&gt; permission to use global shortcuts such as Push-to-Talk.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Open Privacy Settings</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>GlobalShortcutButtons</name>
Expand Down Expand Up @@ -3813,10 +3813,6 @@ Without this option enabled, using Mumble&apos;s global shortcuts in privileged
</context>
<context>
<name>GlobalShortcutConfig</name>
<message>
<source>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Mumble can currently only use mouse buttons and keyboard modifier keys (Alt, Ctrl, Cmd, etc.) for global shortcuts.&lt;/p&gt;&lt;p&gt;If you want more flexibility, you can add Mumble as a trusted accessibility program in the Security &amp; Privacy section of your Mac&apos;s System Preferences.&lt;/p&gt;&lt;p&gt;In the Security &amp; Privacy preference pane, change to the Privacy tab. Then choose Accessibility (near the bottom) in the list to the left. Finally, add Mumble to the list of trusted accessibility programs.&lt;/body&gt;&lt;/html&gt;</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Shortcuts</source>
<translation>Преки пътища</translation>
Expand Down Expand Up @@ -3846,6 +3842,10 @@ Without this option enabled, using Mumble&apos;s global shortcuts in privileged
<source>Shortcut input combinations</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Mumble needs &lt;b&gt;Accessibility&lt;/b&gt; permission to use global shortcuts such as Push-to-Talk.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Unassigned</source>
<translation type="unfinished">Необозначено</translation>
Expand Down
Loading
Loading