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

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