Skip to content

Commit 3860fd4

Browse files
authored
Disabled automatic showing of mount popup on Wayland (#2288)
* Disabled automatic showing of mount popup on Wayland In other words, the option "Popup menu" is removed under Wayland. If it's selected on X11 or by editing the config file manually, the selection won't change, but it will be treated as "Show info" and displayed as such by the config dialog. The reason is an old problem of Qt+Wayland: Before the first input (mouse) interaction with the app, Wayland displays its popup as a standalone window, e.g., decorated under stacking compositors. Worse than that, if the user lets the popup disappear by itself without clicking anywhere (the code has a timer for it), the first click on the mount button will cause a crash (without backtrace). NOTE: I've encountered similar Wayland issues elsewhere, e.g., in `QClipboard`. Their common denominator has been QtWayland's dumbness before the first input interaction. So, this is the rule of thumb: Under Wayland, don't show a popup of a Qt app and don't rely on `QClipboard` *without a input interaction*. * Reverted a change that wasn't related to the PR
1 parent 3db2541 commit 3860fd4

File tree

2 files changed

+22
-4
lines changed

2 files changed

+22
-4
lines changed

plugin-mount/configuration.cpp

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,12 @@ Configuration::Configuration(PluginSettings *settings, QWidget *parent) :
5757
ui->ejectPressedCombo->setSizePolicy(sp);
5858

5959
// Fill combo boxes
60-
ui->devAddedCombo->addItem(tr("Popup menu"), QLatin1String(ACT_SHOW_MENU));
60+
if (QGuiApplication::platformName() != QStringLiteral("wayland"))
61+
{
62+
// WARNING: The popup menu does not work consistently under Wayland.
63+
// See LXQtMountPlugin::settingsChanged() for an explanation.
64+
ui->devAddedCombo->addItem(tr("Popup menu"), QLatin1String(ACT_SHOW_MENU));
65+
}
6166
ui->devAddedCombo->addItem(tr("Show info"), QLatin1String(ACT_SHOW_INFO));
6267
ui->devAddedCombo->addItem(tr("Do nothing"), QLatin1String(ACT_NOTHING));
6368

@@ -83,11 +88,13 @@ void Configuration::loadSettings()
8388
{
8489
mLockSettingChanges = true;
8590

91+
int defaultIndex = QGuiApplication::platformName() == QStringLiteral("wayland") ? 0 : 1;
92+
8693
QVariant value = settings().value(QLatin1String(CFG_KEY_ACTION), QLatin1String(ACT_SHOW_INFO));
87-
setComboboxIndexByData(ui->devAddedCombo, value, 1);
94+
setComboboxIndexByData(ui->devAddedCombo, value, defaultIndex);
8895

8996
value = settings().value(QLatin1String(CFG_EJECT_ACTION), QLatin1String(ACT_NOTHING));
90-
setComboboxIndexByData(ui->ejectPressedCombo, value, 1);
97+
setComboboxIndexByData(ui->ejectPressedCombo, value, defaultIndex);
9198

9299
mLockSettingChanges = false;
93100
}

plugin-mount/lxqtmountplugin.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
*
2626
* END_COMMON_COPYRIGHT_HEADER */
2727

28+
#include <QGuiApplication>
29+
2830
#include "lxqtmountplugin.h"
2931
#include "configuration.h"
3032

@@ -102,6 +104,15 @@ void LXQtMountPlugin::settingsChanged()
102104
QString s = settings()->value(QLatin1String(CFG_KEY_ACTION)).toString();
103105
DeviceAction::ActionId devActionId = DeviceAction::stringToActionId(s, DeviceAction::ActionMenu);
104106

107+
if (devActionId == DeviceAction::ActionMenu
108+
&& QGuiApplication::platformName() == QStringLiteral("wayland"))
109+
{
110+
// WARNING: Wayland considers the popup as a standalone window until the first input
111+
// interaction happens with the panel. To avoid this inconsistent behavior, the
112+
// automatic showing of the popup is disabled on Wayland.
113+
devActionId = DeviceAction::ActionInfo;
114+
}
115+
105116
if (mDeviceAction == nullptr || mDeviceAction->Type() != devActionId)
106117
{
107118
delete mDeviceAction;
@@ -131,6 +142,6 @@ void LXQtMountPlugin::settingsChanged()
131142
delete mEjectAction;
132143
mEjectAction = EjectAction::create(ejActionId, this, this);
133144

134-
connect(mKeyEject, &GlobalKeyShortcut::Action::activated, mEjectAction, &EjectAction::onEjectPressed);
145+
connect(mKeyEject, &GlobalKeyShortcut::Action::activated, mEjectAction, &EjectAction::onEjectPressed);
135146
}
136147
}

0 commit comments

Comments
 (0)