diff options
author | Giulio Camuffo <giulio.camuffo@jollamobile.com> | 2014-07-14 15:15:16 +0300 |
---|---|---|
committer | Giulio Camuffo <giulio.camuffo@jollamobile.com> | 2014-08-04 09:37:23 +0200 |
commit | ef15bfc5cf516b5ec3656361883e05869026b330 (patch) | |
tree | 4f4a5036da9eac8569568e82e45f9ac6d60056d3 /src/client/qwaylanddisplay.cpp | |
parent | 52d2f25d3bf04088ad1da6759a49c7408f114b37 (diff) |
Make sure to have a hardware integration when creating windows
We need to do a full roundtrip and wait for the qt_hardware_integration
global before returning from QWaylandDisplay constructor. Waiting
for the screen is not enough, since there is no guarantee it will come
after the hardware integration global.
Change-Id: I34cb50b830632db7e5d5c7a502eeef778599b267
Reviewed-by: Gunnar Sletta <gunnar.sletta@jollamobile.com>
Diffstat (limited to 'src/client/qwaylanddisplay.cpp')
-rw-r--r-- | src/client/qwaylanddisplay.cpp | 35 |
1 files changed, 31 insertions, 4 deletions
diff --git a/src/client/qwaylanddisplay.cpp b/src/client/qwaylanddisplay.cpp index 4fc452948..17ac467c5 100644 --- a/src/client/qwaylanddisplay.cpp +++ b/src/client/qwaylanddisplay.cpp @@ -137,9 +137,7 @@ QWaylandDisplay::QWaylandDisplay(QWaylandIntegration *waylandIntegration) mWindowManagerIntegration.reset(new QWaylandWindowManagerIntegration(this)); - blockingReadEvents(); - - waitForScreens(); + forceRoundTrip(); } QWaylandDisplay::~QWaylandDisplay(void) @@ -235,6 +233,9 @@ void QWaylandDisplay::registry_global(uint32_t id, const QString &interface, uin mTextInputManager.reset(new QtWayland::wl_text_input_manager(registry, id)); } else if (interface == QStringLiteral("qt_hardware_integration")) { mHardwareIntegration.reset(new QWaylandHardwareIntegration(registry, id)); + // make a roundtrip here since we need to receive the events sent by + // qt_hardware_integration before creating windows + forceRoundTrip(); } mGlobals.append(RegistryGlobal(id, interface, version, registry)); @@ -271,9 +272,35 @@ uint32_t QWaylandDisplay::currentTimeMillisec() return 0; } +static void +sync_callback(void *data, struct wl_callback *callback, uint32_t serial) +{ + Q_UNUSED(serial) + bool *done = static_cast<bool *>(data); + + *done = true; + wl_callback_destroy(callback); +} + +static const struct wl_callback_listener sync_listener = { + sync_callback +}; + void QWaylandDisplay::forceRoundTrip() { - wl_display_roundtrip(mDisplay); + // wl_display_roundtrip() works on the main queue only, + // but we use a separate one, so basically reimplement it here + int ret = 0; + bool done = false; + wl_callback *callback = wl_display_sync(mDisplay); + wl_proxy_set_queue((struct wl_proxy *)callback, mEventQueue); + wl_callback_add_listener(callback, &sync_listener, &done); + flushRequests(); + while (!done && ret >= 0) + ret = wl_display_dispatch_queue(mDisplay, mEventQueue); + + if (ret == -1 && !done) + wl_callback_destroy(callback); } QtWayland::xdg_shell *QWaylandDisplay::shellXdg() |