Handle registry_global out of constructor
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>
This commit is contained in:
parent
a02c408afc
commit
8e336efb2d
@ -162,13 +162,6 @@ QWaylandDisplay::QWaylandDisplay(QWaylandIntegration *waylandIntegration)
|
|||||||
if (!mXkbContext)
|
if (!mXkbContext)
|
||||||
qCWarning(lcQpaWayland, "failed to create xkb context");
|
qCWarning(lcQpaWayland, "failed to create xkb context");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
forceRoundTrip();
|
|
||||||
|
|
||||||
if (!mWaitingScreens.isEmpty()) {
|
|
||||||
// Give wl_output.done and zxdg_output_v1.done events a chance to arrive
|
|
||||||
forceRoundTrip();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QWaylandDisplay::~QWaylandDisplay(void)
|
QWaylandDisplay::~QWaylandDisplay(void)
|
||||||
@ -193,6 +186,18 @@ QWaylandDisplay::~QWaylandDisplay(void)
|
|||||||
wl_display_disconnect(mDisplay);
|
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()
|
void QWaylandDisplay::ensureScreen()
|
||||||
{
|
{
|
||||||
if (!mScreens.empty() || mPlaceholderScreen)
|
if (!mScreens.empty() || mPlaceholderScreen)
|
||||||
|
@ -130,6 +130,8 @@ public:
|
|||||||
QWaylandDisplay(QWaylandIntegration *waylandIntegration);
|
QWaylandDisplay(QWaylandIntegration *waylandIntegration);
|
||||||
~QWaylandDisplay(void) override;
|
~QWaylandDisplay(void) override;
|
||||||
|
|
||||||
|
void initialize();
|
||||||
|
|
||||||
#if QT_CONFIG(xkbcommon)
|
#if QT_CONFIG(xkbcommon)
|
||||||
struct xkb_context *xkbContext() const { return mXkbContext.get(); }
|
struct xkb_context *xkbContext() const { return mXkbContext.get(); }
|
||||||
#endif
|
#endif
|
||||||
|
@ -189,8 +189,11 @@ QPlatformNativeInterface *QWaylandIntegration::createPlatformNativeInterface()
|
|||||||
return new QWaylandNativeInterface(this);
|
return new QWaylandNativeInterface(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Support platform specific initialization
|
||||||
void QWaylandIntegration::initializePlatform()
|
void QWaylandIntegration::initializePlatform()
|
||||||
{
|
{
|
||||||
|
mDisplay->initialize();
|
||||||
|
|
||||||
mNativeInterface.reset(createPlatformNativeInterface());
|
mNativeInterface.reset(createPlatformNativeInterface());
|
||||||
initializeInputDeviceIntegration();
|
initializeInputDeviceIntegration();
|
||||||
#if QT_CONFIG(clipboard)
|
#if QT_CONFIG(clipboard)
|
||||||
@ -205,9 +208,6 @@ void QWaylandIntegration::initializePlatform()
|
|||||||
|
|
||||||
void QWaylandIntegration::initialize()
|
void QWaylandIntegration::initialize()
|
||||||
{
|
{
|
||||||
// Support platform specicif initialization
|
|
||||||
initializePlatform();
|
|
||||||
|
|
||||||
QAbstractEventDispatcher *dispatcher = QGuiApplicationPrivate::eventDispatcher;
|
QAbstractEventDispatcher *dispatcher = QGuiApplicationPrivate::eventDispatcher;
|
||||||
QObject::connect(dispatcher, SIGNAL(aboutToBlock()), mDisplay.data(), SLOT(flushRequests()));
|
QObject::connect(dispatcher, SIGNAL(aboutToBlock()), mDisplay.data(), SLOT(flushRequests()));
|
||||||
QObject::connect(dispatcher, SIGNAL(awake()), mDisplay.data(), SLOT(flushRequests()));
|
QObject::connect(dispatcher, SIGNAL(awake()), mDisplay.data(), SLOT(flushRequests()));
|
||||||
@ -216,6 +216,9 @@ void QWaylandIntegration::initialize()
|
|||||||
QSocketNotifier *sn = new QSocketNotifier(fd, QSocketNotifier::Read, mDisplay.data());
|
QSocketNotifier *sn = new QSocketNotifier(fd, QSocketNotifier::Read, mDisplay.data());
|
||||||
QObject::connect(sn, SIGNAL(activated(QSocketDescriptor)), mDisplay.data(), SLOT(flushRequests()));
|
QObject::connect(sn, SIGNAL(activated(QSocketDescriptor)), mDisplay.data(), SLOT(flushRequests()));
|
||||||
|
|
||||||
|
// Call after eventDispatcher is fully connected, for QWaylandDisplay::forceRoundTrip()
|
||||||
|
initializePlatform();
|
||||||
|
|
||||||
// Qt does not support running with no screens
|
// Qt does not support running with no screens
|
||||||
mDisplay->ensureScreen();
|
mDisplay->ensureScreen();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user