diff --git a/src/plugins/platforms/wayland/qwaylandshmbackingstore.cpp b/src/plugins/platforms/wayland/qwaylandshmbackingstore.cpp index 1abd6808bbc..a0265bdc338 100644 --- a/src/plugins/platforms/wayland/qwaylandshmbackingstore.cpp +++ b/src/plugins/platforms/wayland/qwaylandshmbackingstore.cpp @@ -283,7 +283,9 @@ QWaylandShmBuffer *QWaylandShmBackingStore::getBuffer(const QSize &size, bool &b return buffer; if (mBuffers.size() < MAX_BUFFERS) { - QImage::Format format = QPlatformScreen::platformScreenForWindow(window())->format(); + QImage::Format format = QImage::Format_ARGB32_Premultiplied; + if (!waylandWindow()->format().hasAlpha()) + format = QImage::Format_RGB32; QWaylandShmBuffer *b = new QWaylandShmBuffer(mDisplay, size, format, waylandWindow()->scale()); bufferWasRecreated = true; mBuffers.push_front(b); diff --git a/src/plugins/platforms/wayland/qwaylandshmwindow.cpp b/src/plugins/platforms/wayland/qwaylandshmwindow.cpp index 8fecad178bd..10c90d1c157 100644 --- a/src/plugins/platforms/wayland/qwaylandshmwindow.cpp +++ b/src/plugins/platforms/wayland/qwaylandshmwindow.cpp @@ -14,6 +14,12 @@ namespace QtWaylandClient { QWaylandShmWindow::QWaylandShmWindow(QWindow *window, QWaylandDisplay *display) : QWaylandWindow(window, display) { + mSurfaceFormat.setRedBufferSize(8); + mSurfaceFormat.setGreenBufferSize(8); + mSurfaceFormat.setBlueBufferSize(8); + + const QSurfaceFormat format = window->requestedFormat(); + mSurfaceFormat.setAlphaBufferSize(format.hasAlpha() ? 8 : 0); } QWaylandShmWindow::~QWaylandShmWindow() @@ -25,6 +31,15 @@ QWaylandWindow::WindowType QWaylandShmWindow::windowType() const return QWaylandWindow::Shm; } +void QWaylandShmWindow::setWindowFlags(Qt::WindowFlags flags) +{ + QWaylandWindow::setWindowFlags(flags); + + const QSurfaceFormat format = window()->requestedFormat(); + if (!format.hasAlpha()) + mSurfaceFormat.setAlphaBufferSize(mWindowDecorationEnabled ? 8 : 0); +} + } QT_END_NAMESPACE diff --git a/src/plugins/platforms/wayland/qwaylandshmwindow_p.h b/src/plugins/platforms/wayland/qwaylandshmwindow_p.h index f11df5e4767..dab9e1e5350 100644 --- a/src/plugins/platforms/wayland/qwaylandshmwindow_p.h +++ b/src/plugins/platforms/wayland/qwaylandshmwindow_p.h @@ -29,7 +29,8 @@ public: ~QWaylandShmWindow() override; WindowType windowType() const override; - QSurfaceFormat format() const override { return QSurfaceFormat(); } + + void setWindowFlags(Qt::WindowFlags flags) override; }; }