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

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