qt5-qtwayland/0017-Handle-registry_global-out-of-constructor.patch

86 lines
3.1 KiB
Diff
Raw Normal View History

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