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

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