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

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