Skip to content

Commit

Permalink
FIX(client): Disable broken shortcuts on Wayland
Browse files Browse the repository at this point in the history
Our global shortcut system currently doesn't work when using Wayland
(mumble-voip#5257). Therefore, this
commit makes sure that the global shortcut system is not even started
on such systems. Furthermore, it informs the user about the shortcuts
being disabled.

Fixes mumble-voip#5303
  • Loading branch information
Krzmbrzl committed Nov 10, 2021
1 parent 5cb3e60 commit 1b03098
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/mumble/GlobalShortcut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "Channel.h"
#include "ClientUser.h"
#include "Database.h"
#include "EnvUtils.h"
#include "MainWindow.h"
#include "Global.h"
#include "GlobalShortcutButtons.h"
Expand Down Expand Up @@ -525,6 +526,16 @@ GlobalShortcutConfig::GlobalShortcutConfig(Settings &st) : ConfigWidget(st) {

qcbEnableGlobalShortcuts->setVisible(canDisable);

qlWaylandNote->setVisible(false);
#ifdef Q_OS_LINUX
if (EnvUtils::waylandIsUsed()) {
// Our global shortcut system doesn't work with Wayland
qlWaylandNote->setVisible(true);

qgbShortcuts->setEnabled(false);
}
#endif

#ifdef Q_OS_MAC
// Help Mac users enable accessibility access for Mumble...
# if QT_VERSION >= QT_VERSION_CHECK(5, 9, 0)
Expand Down Expand Up @@ -750,6 +761,7 @@ QTreeWidgetItem *GlobalShortcutConfig::itemForShortcut(const Shortcut &sc) const
void GlobalShortcutConfig::reload() {
std::stable_sort(qlShortcuts.begin(), qlShortcuts.end());
qtwShortcuts->clear();

foreach (const Shortcut &sc, qlShortcuts) {
QTreeWidgetItem *item = itemForShortcut(sc);
qtwShortcuts->addTopLevelItem(item);
Expand Down
13 changes: 13 additions & 0 deletions src/mumble/GlobalShortcut.ui
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,19 @@
</layout>
</widget>
</item>
<item>
<widget class="QLabel" name="qlWaylandNote">
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Mumble's Global Shortcuts system does currently not work in combination with the Wayland protocol. For more information, visit &lt;a href=&quot;https://github.com/mumble-voip/mumble/issues/5257&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#0057ae;&quot;&gt;https://github.com/mumble-voip/mumble/issues/5257&lt;/span&gt;&lt;/a&gt;.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QGroupBox" name="qgbShortcuts">
<property name="title">
Expand Down
7 changes: 7 additions & 0 deletions src/mumble/GlobalShortcut_unix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

#include "GlobalShortcut_unix.h"

#include "EnvUtils.h"
#include "Settings.h"
#include "Global.h"

Expand Down Expand Up @@ -62,6 +63,12 @@ GlobalShortcutX::GlobalShortcutX() {
}

#ifdef Q_OS_LINUX
if (EnvUtils::waylandIsUsed()) {
qWarning("GlobalShortcutX: Global shortcuts don't work on Wayland (see "
"https://github.com/mumble-voip/mumble/issues/5257)");
return;
}

if (Global::get().s.bEnableEvdev) {
QString dir = QLatin1String("/dev/input");
QFileSystemWatcher *fsw = new QFileSystemWatcher(QStringList(dir), this);
Expand Down
14 changes: 14 additions & 0 deletions src/mumble/Settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

#include "AudioInput.h"
#include "Cert.h"
#include "EnvUtils.h"
#include "Log.h"
#include "SSL.h"
#include "Global.h"
Expand Down Expand Up @@ -532,6 +533,12 @@ Settings::Settings() {
bEnableXboxInput = true;
bEnableUIAccess = true;

#ifdef Q_OS_LINUX
if (EnvUtils::waylandIsUsed()) {
bShortcutEnable = false;
}
#endif

for (int i = Log::firstMsgType; i <= Log::lastMsgType; ++i) {
qmMessages.insert(i,
Settings::LogConsole | Settings::LogBalloon | Settings::LogTTS | Settings::LogMessageLimit);
Expand Down Expand Up @@ -1007,6 +1014,13 @@ void Settings::load(QSettings *settings_ptr) {
LOAD(bEnableXboxInput, "shortcut/windows/xbox/enable");
LOAD(bEnableUIAccess, "shortcut/windows/uiaccess/enable");

#ifdef Q_OS_LINUX
if (EnvUtils::waylandIsUsed()) {
// Global shortcuts don't work on Wayland
bShortcutEnable = false;
}
#endif

// Search options
LOAD(searchForUsers, "search/search_for_users");
LOAD(searchForChannels, "search/search_for_channels");
Expand Down

0 comments on commit 1b03098

Please sign in to comment.