diff --git a/src/plugins/platforms/wayland/qwaylanddisplay.cpp b/src/plugins/platforms/wayland/qwaylanddisplay.cpp index 9011f5799a..7d7ffce775 100644 --- a/src/plugins/platforms/wayland/qwaylanddisplay.cpp +++ b/src/plugins/platforms/wayland/qwaylanddisplay.cpp @@ -81,17 +81,17 @@ struct wl_buffer *QWaylandDisplay::createShmBuffer(int fd, struct wl_visual *QWaylandDisplay::rgbVisual() { - return wl_display_get_rgb_visual(mDisplay); + return rgb_visual; } struct wl_visual *QWaylandDisplay::argbVisual() { - return wl_display_get_argb_visual(mDisplay); + return argb_visual; } struct wl_visual *QWaylandDisplay::argbPremultipliedVisual() { - return wl_display_get_premultiplied_argb_visual(mDisplay); + return premultiplied_argb_visual; } #ifdef QT_WAYLAND_GL_SUPPORT @@ -127,6 +127,7 @@ const struct wl_shell_listener QWaylandDisplay::shellListener = { }; QWaylandDisplay::QWaylandDisplay(void) + : argb_visual(0), premultiplied_argb_visual(0), rgb_visual(0) { mDisplay = wl_display_connect(NULL); if (mDisplay == NULL) { @@ -243,6 +244,11 @@ const struct wl_output_listener QWaylandDisplay::outputListener = { QWaylandDisplay::outputHandleGeometry }; +const struct wl_compositor_listener QWaylandDisplay::compositorListener = { + QWaylandDisplay::handleVisual, +}; + + void QWaylandDisplay::waitForScreens() { flushRequests(); @@ -271,6 +277,8 @@ void QWaylandDisplay::displayHandleGlobal(uint32_t id, wl_output_add_listener(output, &outputListener, this); } else if (interface == "wl_compositor") { mCompositor = wl_compositor_create(mDisplay, id, 1); + wl_compositor_add_listener(mCompositor, + &compositorListener, this); } else if (interface == "wl_shm") { mShm = wl_shm_create(mDisplay, id, 1); } else if (interface == "wl_shell"){ @@ -286,3 +294,23 @@ void QWaylandDisplay::displayHandleGlobal(uint32_t id, clipboard->createSelectionOffer(id); } } + +void QWaylandDisplay::handleVisual(void *data, + struct wl_compositor *compositor, + uint32_t id, uint32_t token) +{ + QWaylandDisplay *self = static_cast(data); + + switch (token) { + case WL_COMPOSITOR_VISUAL_ARGB32: + self->argb_visual = wl_visual_create(self->mDisplay, id, 1); + break; + case WL_COMPOSITOR_VISUAL_PREMULTIPLIED_ARGB32: + self->premultiplied_argb_visual = + wl_visual_create(self->mDisplay, id, 1); + break; + case WL_COMPOSITOR_VISUAL_XRGB32: + self->rgb_visual = wl_visual_create(self->mDisplay, id, 1); + break; + } +} diff --git a/src/plugins/platforms/wayland/qwaylanddisplay.h b/src/plugins/platforms/wayland/qwaylanddisplay.h index 626636038d..16ab3f70f8 100644 --- a/src/plugins/platforms/wayland/qwaylanddisplay.h +++ b/src/plugins/platforms/wayland/qwaylanddisplay.h @@ -116,7 +116,10 @@ private: uint32_t mSocketMask; + struct wl_visual *argb_visual, *premultiplied_argb_visual, *rgb_visual; + static const struct wl_output_listener outputListener; + static const struct wl_compositor_listener compositorListener; static int sourceUpdate(uint32_t mask, void *data); static void displayHandleGlobal(struct wl_display *display, uint32_t id, @@ -127,6 +130,9 @@ private: int32_t x, int32_t y, int32_t width, int32_t height); + static void handleVisual(void *data, + struct wl_compositor *compositor, + uint32_t id, uint32_t token); #ifdef QT_WAYLAND_GL_SUPPORT QWaylandGLIntegration *mEglIntegration; #endif diff --git a/src/plugins/platforms/wayland/wayland_sha1.txt b/src/plugins/platforms/wayland/wayland_sha1.txt new file mode 100644 index 0000000000..d2624378e0 --- /dev/null +++ b/src/plugins/platforms/wayland/wayland_sha1.txt @@ -0,0 +1,3 @@ +This version of the Qt Wayland plugin is checked against the following sha1 +from the Wayland repository: +eff7fc0d99be2e51eaa351785030c8d374ac71de