Blame SOURCES/0023-Client-do-not-empty-clipboard-when-a-new-popup-windo.patch

869fe3
From 167a89d23d4db6f62ef8336002fe306829604a77 Mon Sep 17 00:00:00 2001
6f97c1
From: Jan Grulich <jgrulich@redhat.com>
6f97c1
Date: Fri, 16 Jul 2021 13:00:03 +0200
869fe3
Subject: [PATCH 23/40] Client: do not empty clipboard when a new popup/window
147f94
 is opened
6f97c1
6f97c1
If we open a new popup or a window within the same app we have to avoid
6f97c1
invalidating selection offer when losing focus, because it's still the
6f97c1
same client who has the focus and we might not get a new selection offer
6f97c1
by the compositor and therefore we would lose clipboard content.
6f97c1
6f97c1
Fixes: QTBUG-93474
6f97c1
Change-Id: Ia2ef826c2967b1daf1cdeb085e8dae66d090dbcf
147f94
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
147f94
Reviewed-by: David Edmundson <davidedmundson@kde.org>
147f94
147f94
Cherry-pick: 1e57ebd501cfc2255300392cd4565cd034efeed8
6f97c1
---
147f94
 src/client/qwaylanddisplay.cpp     | 13 +++++++++++++
147f94
 src/client/qwaylandinputdevice.cpp |  8 --------
147f94
 2 files changed, 13 insertions(+), 8 deletions(-)
6f97c1
6f97c1
diff --git a/src/client/qwaylanddisplay.cpp b/src/client/qwaylanddisplay.cpp
147f94
index 27303110..9f595af3 100644
6f97c1
--- a/src/client/qwaylanddisplay.cpp
6f97c1
+++ b/src/client/qwaylanddisplay.cpp
6f97c1
@@ -597,6 +597,19 @@ void QWaylandDisplay::handleWaylandSync()
6f97c1
     QWindow *activeWindow = mActiveWindows.empty() ? nullptr : mActiveWindows.last()->window();
6f97c1
     if (activeWindow != QGuiApplication::focusWindow())
6f97c1
         QWindowSystemInterface::handleWindowActivated(activeWindow);
6f97c1
+
6f97c1
+    if (!activeWindow) {
6f97c1
+        if (lastInputDevice()) {
6f97c1
+#if QT_CONFIG(clipboard)
6f97c1
+            if (auto *dataDevice = lastInputDevice()->dataDevice())
6f97c1
+                dataDevice->invalidateSelectionOffer();
6f97c1
+#endif
6f97c1
+#if QT_CONFIG(wayland_client_primary_selection)
6f97c1
+            if (auto *device = lastInputDevice()->primarySelectionDevice())
6f97c1
+                device->invalidateSelectionOffer();
6f97c1
+#endif
6f97c1
+        }
6f97c1
+    }
6f97c1
 }
147f94
 
6f97c1
 const wl_callback_listener QWaylandDisplay::syncCallbackListener = {
6f97c1
diff --git a/src/client/qwaylandinputdevice.cpp b/src/client/qwaylandinputdevice.cpp
147f94
index ae045f4f..514457e9 100644
6f97c1
--- a/src/client/qwaylandinputdevice.cpp
6f97c1
+++ b/src/client/qwaylandinputdevice.cpp
6f97c1
@@ -1300,14 +1300,6 @@ void QWaylandInputDevice::Keyboard::handleFocusDestroyed()
6f97c1
 void QWaylandInputDevice::Keyboard::handleFocusLost()
6f97c1
 {
6f97c1
     mFocus = nullptr;
6f97c1
-#if QT_CONFIG(clipboard)
6f97c1
-    if (auto *dataDevice = mParent->dataDevice())
6f97c1
-        dataDevice->invalidateSelectionOffer();
6f97c1
-#endif
6f97c1
-#if QT_CONFIG(wayland_client_primary_selection)
6f97c1
-    if (auto *device = mParent->primarySelectionDevice())
6f97c1
-        device->invalidateSelectionOffer();
6f97c1
-#endif
6f97c1
     mParent->mQDisplay->handleKeyboardFocusChanged(mParent);
6f97c1
     mRepeatTimer.stop();
6f97c1
 }
147f94
-- 
9fb289
2.35.1
147f94