summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorVlad Zahorodnii <vlad.zahorodnii@kde.org>2022-09-27 22:05:07 +0300
committerVlad Zahorodnii <vlad.zahorodnii@kde.org>2022-12-13 12:47:24 +0200
commit45163234a4e4baad0012d3ee07501093d98ba91c (patch)
treea206a25815e9e4af35708fe8d306bcfafe74d1ee /src
parentc76f9bcd6704736998871d9c0cbd64e69f59757a (diff)
downloadqtwayland-45163234a4e4baad0012d3ee07501093d98ba91c.tar.gz
Client: Handle zwp_primary_selection_device_manager_v1 global removal
The zwp_primary_selection_device_manager_v1 global can be withdrawn if the compositor disables the primary selection, i.e. middle click to paste selected text. QtWayland needs to handle that; otherwise the app can crash. Pick-to: 6.5 Change-Id: Idbb4db18b605f85a5951fa12c1bdf61898b0d123 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/client/qwaylanddisplay.cpp9
-rw-r--r--src/client/qwaylandprimaryselectionv1.cpp5
2 files changed, 9 insertions, 5 deletions
diff --git a/src/client/qwaylanddisplay.cpp b/src/client/qwaylanddisplay.cpp
index 52ea6492..2bf09331 100644
--- a/src/client/qwaylanddisplay.cpp
+++ b/src/client/qwaylanddisplay.cpp
@@ -522,6 +522,8 @@ void QWaylandDisplay::registry_global(uint32_t id, const QString &interface, uin
#if QT_CONFIG(wayland_client_primary_selection)
} else if (interface == QLatin1String(QWaylandPrimarySelectionDeviceManagerV1::interface()->name)) {
mPrimarySelectionManager.reset(new QWaylandPrimarySelectionDeviceManagerV1(this, id, 1));
+ for (QWaylandInputDevice *inputDevice : std::as_const(mInputDevices))
+ inputDevice->setPrimarySelectionDevice(mPrimarySelectionManager->createDevice(inputDevice));
#endif
} else if (interface == QLatin1String(QtWayland::qt_text_input_method_manager_v1::interface()->name)
&& (mTextInputManagerList.contains(interface) && mTextInputManagerList.indexOf(interface) < mTextInputManagerIndex)) {
@@ -674,6 +676,13 @@ void QWaylandDisplay::registry_global_remove(uint32_t id)
inputDevice->setTextInputMethod(nullptr);
mWaylandIntegration->reconfigureInputContext();
}
+#if QT_CONFIG(wayland_client_primary_selection)
+ if (global.interface == QLatin1String(QtWayland::zwp_primary_selection_device_manager_v1::interface()->name)) {
+ mPrimarySelectionManager.reset();
+ for (QWaylandInputDevice *inputDevice : std::as_const(mInputDevices))
+ inputDevice->setPrimarySelectionDevice(nullptr);
+ }
+#endif
emit globalRemoved(mGlobals.takeAt(i));
break;
}
diff --git a/src/client/qwaylandprimaryselectionv1.cpp b/src/client/qwaylandprimaryselectionv1.cpp
index 1eb1fcff..999aba97 100644
--- a/src/client/qwaylandprimaryselectionv1.cpp
+++ b/src/client/qwaylandprimaryselectionv1.cpp
@@ -18,11 +18,6 @@ QWaylandPrimarySelectionDeviceManagerV1::QWaylandPrimarySelectionDeviceManagerV1
: zwp_primary_selection_device_manager_v1(display->wl_registry(), id, qMin(version, uint(1)))
, m_display(display)
{
- // Create devices for all seats.
- // This only works if we get the global before all devices
- const auto seats = m_display->inputDevices();
- for (auto *seat : seats)
- seat->setPrimarySelectionDevice(createDevice(seat));
}
QWaylandPrimarySelectionDeviceV1 *QWaylandPrimarySelectionDeviceManagerV1::createDevice(QWaylandInputDevice *seat)