Blame SOURCES/0042-Handle-registry_global-out-of-constructor.patch

9fb289
From bc5a8d24f63181a36759723a4d1b39b59b3b53e6 Mon Sep 17 00:00:00 2001
9fb289
From: Elvis Lee <kwangwoong.lee@lge.com>
9fb289
Date: Thu, 18 Feb 2021 15:45:49 +0900
9fb289
Subject: [PATCH 42/52] Handle registry_global out of constructor
9fb289
9fb289
Factory functions in QWaylandDisplay::registry_global() can be overridden.
9fb289
Later, other classes instantiated in the registry_global can support
9fb289
platform specific implementation with inheritance and some factory function.
9fb289
9fb289
Change-Id: I92ce574e049b8c91587687cc7c30611f3dfdbe56
9fb289
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
9fb289
(cherry picked from commit 3793a82038682db77966ea5daf8e75964e4250fe)
9fb289
---
9fb289
 src/client/qwaylanddisplay.cpp     | 19 ++++++++++++-------
9fb289
 src/client/qwaylanddisplay_p.h     |  2 ++
9fb289
 src/client/qwaylandintegration.cpp |  3 +++
9fb289
 3 files changed, 17 insertions(+), 7 deletions(-)
9fb289
9fb289
diff --git a/src/client/qwaylanddisplay.cpp b/src/client/qwaylanddisplay.cpp
9fb289
index ea344c61..0f75cb7e 100644
9fb289
--- a/src/client/qwaylanddisplay.cpp
9fb289
+++ b/src/client/qwaylanddisplay.cpp
9fb289
@@ -158,13 +158,6 @@ QWaylandDisplay::QWaylandDisplay(QWaylandIntegration *waylandIntegration)
9fb289
     if (!mXkbContext)
9fb289
         qCWarning(lcQpaWayland, "failed to create xkb context");
9fb289
 #endif
9fb289
-
9fb289
-    forceRoundTrip();
9fb289
-
9fb289
-    if (!mWaitingScreens.isEmpty()) {
9fb289
-        // Give wl_output.done and zxdg_output_v1.done events a chance to arrive
9fb289
-        forceRoundTrip();
9fb289
-    }
9fb289
 }
9fb289
 
9fb289
 QWaylandDisplay::~QWaylandDisplay(void)
9fb289
@@ -189,6 +182,18 @@ QWaylandDisplay::~QWaylandDisplay(void)
9fb289
         wl_display_disconnect(mDisplay);
9fb289
 }
9fb289
 
9fb289
+// Steps which is called just after constructor. This separates registry_global() out of the constructor
9fb289
+// so that factory functions in integration can be overridden.
9fb289
+void QWaylandDisplay::initialize()
9fb289
+{
9fb289
+    forceRoundTrip();
9fb289
+
9fb289
+    if (!mWaitingScreens.isEmpty()) {
9fb289
+        // Give wl_output.done and zxdg_output_v1.done events a chance to arrive
9fb289
+        forceRoundTrip();
9fb289
+    }
9fb289
+}
9fb289
+
9fb289
 void QWaylandDisplay::ensureScreen()
9fb289
 {
9fb289
     if (!mScreens.empty() || mPlaceholderScreen)
9fb289
diff --git a/src/client/qwaylanddisplay_p.h b/src/client/qwaylanddisplay_p.h
9fb289
index 09a1736a..d9c8849f 100644
9fb289
--- a/src/client/qwaylanddisplay_p.h
9fb289
+++ b/src/client/qwaylanddisplay_p.h
9fb289
@@ -129,6 +129,8 @@ public:
9fb289
     QWaylandDisplay(QWaylandIntegration *waylandIntegration);
9fb289
     ~QWaylandDisplay(void) override;
9fb289
 
9fb289
+    void initialize();
9fb289
+
9fb289
 #if QT_CONFIG(xkbcommon)
9fb289
     struct xkb_context *xkbContext() const { return mXkbContext.get(); }
9fb289
 #endif
9fb289
diff --git a/src/client/qwaylandintegration.cpp b/src/client/qwaylandintegration.cpp
9fb289
index e5e7dd42..f5632982 100644
9fb289
--- a/src/client/qwaylandintegration.cpp
9fb289
+++ b/src/client/qwaylandintegration.cpp
9fb289
@@ -200,6 +200,9 @@ void QWaylandIntegration::initialize()
9fb289
     QSocketNotifier *sn = new QSocketNotifier(fd, QSocketNotifier::Read, mDisplay.data());
9fb289
     QObject::connect(sn, SIGNAL(activated(QSocketDescriptor)), mDisplay.data(), SLOT(flushRequests()));
9fb289
 
9fb289
+    // Call after eventDispatcher is fully connected, for QWaylandDisplay::forceRoundTrip()
9fb289
+    mDisplay->initialize();
9fb289
+
9fb289
     // Qt does not support running with no screens
9fb289
     mDisplay->ensureScreen();
9fb289
 }
9fb289
-- 
9fb289
2.35.1
9fb289