Blame SOURCES/qtwayland-client-do-not-empty-clipboard-when-new-popup-or-window-is-opened.patch

6f97c1
From 5ac39d2d76735c5d1d28a16f7fbc8b28e39886dd Mon Sep 17 00:00:00 2001
6f97c1
From: Jan Grulich <jgrulich@redhat.com>
6f97c1
Date: Fri, 16 Jul 2021 13:00:03 +0200
6f97c1
Subject: [PATCH] Client: do not empty clipboard when a new popup/window 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
Pick-to: 6.2 5.15
6f97c1
Change-Id: Ia2ef826c2967b1daf1cdeb085e8dae66d090dbcf
6f97c1
---
6f97c1
6f97c1
diff --git a/src/client/qwaylanddisplay.cpp b/src/client/qwaylanddisplay.cpp
6f97c1
index 2730311..9f595af 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
 }
6f97c1
6f97c1
 const wl_callback_listener QWaylandDisplay::syncCallbackListener = {
6f97c1
diff --git a/src/client/qwaylandinputdevice.cpp b/src/client/qwaylandinputdevice.cpp
6f97c1
index ae045f4..514457e 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
 }