|
Line 0
Link Here
|
|
|
1 |
From: David Edmundson <davidedmundson@kde.org> |
| 2 |
Date: Tue, 19 May 2026 19:47:10 +0100 |
| 3 |
Subject: [PATCH] wayland: avoid resetting clipboard on focus out |
| 4 |
|
| 5 |
The wayland specification as written is rather flawed. |
| 6 |
|
| 7 |
> The data_offer is valid until a new data_offer or NULL is received or |
| 8 |
until the client loses keyboard focus. Switching surface with keyboard |
| 9 |
focus within the same client doesn't mean a new selection will be sent. |
| 10 |
|
| 11 |
Switching keyboard surface within the same client is not atomic in |
| 12 |
Wayland. |
| 13 |
|
| 14 |
Right now we try and sync things with a roundtrip but this does not |
| 15 |
suffice. If we close two popups in quick succession, such as a |
| 16 |
popup-tree, the compositor may try and focus the other the now-closed |
| 17 |
window. By the time the compositor has handled that second window |
| 18 |
closure our callback is complete. |
| 19 |
|
| 20 |
The data offer not being valid doesn't mean we explicitly have to reset |
| 21 |
our concept of it. We can treat it as being inert by just not doing |
| 22 |
anything. It's not an error to use a defuct data_offer. It will be reset |
| 23 |
before the next keyboard_enter event. |
| 24 |
|
| 25 |
This matches GTK. |
| 26 |
|
| 27 |
Upstream-Commit: 78a7fc3e253c48f01d86c18209aff12c0dc75d5f |
| 28 |
Upstream-Review: https://codereview.qt-project.org/c/qt/qtbase/+/746667 |
| 29 |
Origin-Commit: 12c844c85a66b96c73998e88fd9ace244db06e6e |
| 30 |
Change-Id: Iaa09b642c2aa64c52ad34fb2169c3c3b6f9fa958 |
| 31 |
Backport-Note: Keep only the runtime change needed by Qt 6.10.3; omit |
| 32 |
the upstream test-suite changes to minimize the backport surface. |
| 33 |
--- |
| 34 |
src/plugins/platforms/wayland/qwaylanddisplay.cpp | 13 ------------- |
| 35 |
1 file changed, 13 deletions(-) |
| 36 |
|
| 37 |
diff --git a/src/plugins/platforms/wayland/qwaylanddisplay.cpp b/src/plugins/platforms/wayland/qwaylanddisplay.cpp |
| 38 |
--- a/src/plugins/platforms/wayland/qwaylanddisplay.cpp |
| 39 |
+++ b/src/plugins/platforms/wayland/qwaylanddisplay.cpp |
| 40 |
@@ -1005,19 +1005,6 @@ void QWaylandDisplay::handleWaylandSync() |
| 41 |
QWindow *activeWindow = mActiveWindows.empty() ? nullptr : mActiveWindows.last()->window(); |
| 42 |
if (activeWindow != QGuiApplication::focusWindow()) |
| 43 |
QWindowSystemInterface::handleFocusWindowChanged(activeWindow); |
| 44 |
- |
| 45 |
- if (!activeWindow) { |
| 46 |
- if (lastInputDevice()) { |
| 47 |
-#if QT_CONFIG(clipboard) |
| 48 |
- if (auto *dataDevice = lastInputDevice()->dataDevice()) |
| 49 |
- dataDevice->invalidateSelectionOffer(); |
| 50 |
-#endif |
| 51 |
-#if QT_CONFIG(wayland_client_primary_selection) |
| 52 |
- if (auto *device = lastInputDevice()->primarySelectionDevice()) |
| 53 |
- device->invalidateSelectionOffer(); |
| 54 |
-#endif |
| 55 |
- } |
| 56 |
- } |
| 57 |
} |
| 58 |
|
| 59 |
const wl_callback_listener QWaylandDisplay::syncCallbackListener = { |