You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
kwin/kwin-do-not-refresh-x11-cli...

75 lines
2.1 KiB

From d335070b80c2f3bc5674355e3edba61bc010bc36 Mon Sep 17 00:00:00 2001
From: Aleix Pol <aleixpol@kde.org>
Date: Tue, 20 Oct 2020 02:29:01 +0200
Subject: [PATCH] xwl: Do not refresh the x11 Clipboard while fetching
At the moment there was a race condition when putting something into the
keyboard from XWayland apps. The clipboard manager would announce a new
thing before we'd submitted it all resulting in a broken state.
This change detects when it's fetching and will only refresh the source
after everything has been sent.
BUG: 424754
CCBUG: 412350
---
xwl/clipboard.cpp | 10 ++++++++++
xwl/clipboard.h | 1 +
2 files changed, 11 insertions(+)
diff --git a/xwl/clipboard.cpp b/xwl/clipboard.cpp
index 37a5c3b..87ee5cd 100644
--- a/xwl/clipboard.cpp
+++ b/xwl/clipboard.cpp
@@ -66,6 +66,10 @@ Clipboard::Clipboard(xcb_atom_t atom, QObject *parent)
void Clipboard::wlSelectionChanged(KWaylandServer::AbstractDataSource *dsi)
{
+ if (m_waitingForTargets) {
+ return;
+ }
+
if (dsi && !ownsSelection(dsi)) {
// Wayland native client provides new selection
if (!m_checkConnection) {
@@ -88,6 +92,10 @@ bool Clipboard::ownsSelection(KWaylandServer::AbstractDataSource *dsi) const
void Clipboard::checkWlSource()
{
+ if (m_waitingForTargets) {
+ return;
+ }
+
auto dsi = waylandServer()->seat()->selection();
auto removeSource = [this] {
if (wlSource()) {
@@ -145,11 +153,13 @@ void Clipboard::doHandleXfixesNotify(xcb_xfixes_selection_notify_event_t *event)
if (X11Source *source = x11Source()) {
source->getTargets();
+ m_waitingForTargets = true;
}
}
void Clipboard::x11OffersChanged(const QStringList &added, const QStringList &removed)
{
+ m_waitingForTargets = false;
X11Source *source = x11Source();
if (!source) {
return;
diff --git a/xwl/clipboard.h b/xwl/clipboard.h
index c229684..f534d1f 100644
--- a/xwl/clipboard.h
+++ b/xwl/clipboard.h
@@ -53,6 +53,7 @@ private:
QMetaObject::Connection m_checkConnection;
Q_DISABLE_COPY(Clipboard)
+ bool m_waitingForTargets = false;
};
} // namespace Xwl
--
GitLab