From a92a519e799939e9d76d5b32b7f77eb8e9c8d578 Mon Sep 17 00:00:00 2001 From: Tasuku Suzuki Date: Sat, 17 Jun 2017 15:28:49 +0900 Subject: [PATCH] Translucent background support Change-Id: I6e7b5869097f579020c7a4439441a63a0771e955 Task-number: QTBUG-55956 Reviewed-by: Laszlo Agocs --- .../platforms/wayland/qwaylandshmbackingstore.cpp | 10 +++++++++- .../platforms/wayland/qwaylandshmbackingstore_p.h | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/plugins/platforms/wayland/qwaylandshmbackingstore.cpp b/src/plugins/platforms/wayland/qwaylandshmbackingstore.cpp index 0afdda4c0c3..045748a16c2 100644 --- a/src/plugins/platforms/wayland/qwaylandshmbackingstore.cpp +++ b/src/plugins/platforms/wayland/qwaylandshmbackingstore.cpp @@ -171,12 +171,20 @@ QPaintDevice *QWaylandShmBackingStore::paintDevice() return contentSurface(); } -void QWaylandShmBackingStore::beginPaint(const QRegion &) +void QWaylandShmBackingStore::beginPaint(const QRegion ®ion) { mPainting = true; ensureSize(); waylandWindow()->setCanResize(false); + + if (mBackBuffer->image()->hasAlphaChannel()) { + QPainter p(paintDevice()); + p.setCompositionMode(QPainter::CompositionMode_Source); + const QColor blank = Qt::transparent; + for (const QRect &rect : region) + p.fillRect(rect, blank); + } } void QWaylandShmBackingStore::endPaint() diff --git a/src/plugins/platforms/wayland/qwaylandshmbackingstore_p.h b/src/plugins/platforms/wayland/qwaylandshmbackingstore_p.h index 8564cc9d223..251368efd47 100644 --- a/src/plugins/platforms/wayland/qwaylandshmbackingstore_p.h +++ b/src/plugins/platforms/wayland/qwaylandshmbackingstore_p.h @@ -94,7 +94,7 @@ public: void flush(QWindow *window, const QRegion ®ion, const QPoint &offset) override; void resize(const QSize &size, const QRegion &staticContents) override; void resize(const QSize &size); - void beginPaint(const QRegion &) override; + void beginPaint(const QRegion ®ion) override; void endPaint() override; QWaylandAbstractDecoration *windowDecoration() const;