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

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