Blame SOURCES/0038-client-Simplify-round-trip-behavior.patch

e1c9ed
From 971dbf2d5be743ddeb998f7461ff3e06ccb892c4 Mon Sep 17 00:00:00 2001
e1c9ed
From: David Edmundson <davidedmundson@kde.org>
e1c9ed
Date: Wed, 9 Feb 2022 17:20:48 +0000
e1c9ed
Subject: [PATCH 38/40] client: Simplify round trip behavior
e1c9ed
e1c9ed
The custom event queue was removed in
e1c9ed
302d4ffb8549214eb4028dc3e47ec4ee4e12ffbd (2015) so the comment about not
e1c9ed
being able to use the inbuilt round trip method no longer applies.
e1c9ed
e1c9ed
This fixes a real world problem. Use of a blocking round trip should not
e1c9ed
process non wayland events. Doing so can lead to misbehaviour client
e1c9ed
side as things happen out of order. The move to the event thread created
e1c9ed
several regressions as we now get events before the QGuiApplication is
e1c9ed
fully constructed.
e1c9ed
e1c9ed
Change-Id: I650481f49a47ed1a9778c7e1bc3c48db6e8f0031
e1c9ed
Reviewed-by: Vlad Zahorodnii <vlad.zahorodnii@kde.org>
e1c9ed
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
e1c9ed
(cherry picked from commit 62646d9122845d7bd9104b610478cebde3e769c7)
e1c9ed
---
e1c9ed
 src/client/qwaylanddisplay.cpp | 43 +---------------------------------
e1c9ed
 1 file changed, 1 insertion(+), 42 deletions(-)
e1c9ed
e1c9ed
diff --git a/src/client/qwaylanddisplay.cpp b/src/client/qwaylanddisplay.cpp
e1c9ed
index 6f1bada5..86045a35 100644
e1c9ed
--- a/src/client/qwaylanddisplay.cpp
e1c9ed
+++ b/src/client/qwaylanddisplay.cpp
e1c9ed
@@ -611,50 +611,9 @@ uint32_t QWaylandDisplay::currentTimeMillisec()
e1c9ed
     return 0;
e1c9ed
 }
e1c9ed
 
e1c9ed
-static void
e1c9ed
-sync_callback(void *data, struct wl_callback *callback, uint32_t serial)
e1c9ed
-{
e1c9ed
-    Q_UNUSED(serial)
e1c9ed
-    bool *done = static_cast<bool *>(data);
e1c9ed
-
e1c9ed
-    *done = true;
e1c9ed
-
e1c9ed
-    // If the wl_callback done event is received after the condition check in the while loop in
e1c9ed
-    // forceRoundTrip(), but before the call to processEvents, the call to processEvents may block
e1c9ed
-    // forever if no more events are posted (eventhough the callback is handled in response to the
e1c9ed
-    // aboutToBlock signal). Hence, we wake up the event dispatcher so forceRoundTrip may return.
e1c9ed
-    // (QTBUG-64696)
e1c9ed
-    if (auto *dispatcher = QThread::currentThread()->eventDispatcher())
e1c9ed
-        dispatcher->wakeUp();
e1c9ed
-
e1c9ed
-    wl_callback_destroy(callback);
e1c9ed
-}
e1c9ed
-
e1c9ed
-static const struct wl_callback_listener sync_listener = {
e1c9ed
-    sync_callback
e1c9ed
-};
e1c9ed
-
e1c9ed
 void QWaylandDisplay::forceRoundTrip()
e1c9ed
 {
e1c9ed
-    // wl_display_roundtrip() works on the main queue only,
e1c9ed
-    // but we use a separate one, so basically reimplement it here
e1c9ed
-    int ret = 0;
e1c9ed
-    bool done = false;
e1c9ed
-    wl_callback *callback = wl_display_sync(mDisplay);
e1c9ed
-    wl_callback_add_listener(callback, &sync_listener, &done);
e1c9ed
-    flushRequests();
e1c9ed
-    if (QThread::currentThread()->eventDispatcher()) {
e1c9ed
-        while (!done && ret >= 0) {
e1c9ed
-            QThread::currentThread()->eventDispatcher()->processEvents(QEventLoop::WaitForMoreEvents);
e1c9ed
-            ret = wl_display_dispatch_pending(mDisplay);
e1c9ed
-        }
e1c9ed
-    } else {
e1c9ed
-        while (!done && ret >= 0)
e1c9ed
-            ret = wl_display_dispatch(mDisplay);
e1c9ed
-    }
e1c9ed
-
e1c9ed
-    if (ret == -1 && !done)
e1c9ed
-        wl_callback_destroy(callback);
e1c9ed
+     wl_display_roundtrip(mDisplay);
e1c9ed
 }
e1c9ed
 
e1c9ed
 bool QWaylandDisplay::supportsWindowDecoration() const
e1c9ed
-- 
e1c9ed
2.35.1
e1c9ed