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

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