diff --git a/src/wayland/surface_interface.cpp b/src/wayland/surface_interface.cpp index 71e0fa45cf..f369fe4080 100644 --- a/src/wayland/surface_interface.cpp +++ b/src/wayland/surface_interface.cpp @@ -581,17 +581,27 @@ void SurfaceInterfacePrivate::applyState(SurfaceState *next) } else { surfaceSize = implicitSurfaceSize; } + + const QRect surfaceRect(QPoint(0, 0), surfaceSize); + inputRegion = current.input & surfaceRect; + + if (!current.buffer->hasAlphaChannel()) { + opaqueRegion = surfaceRect; + } else { + opaqueRegion = current.opaque & surfaceRect; + } } else { surfaceSize = QSize(); implicitSurfaceSize = QSize(); bufferSize = QSize(); + inputRegion = QRegion(); + opaqueRegion = QRegion(); } surfaceToBufferMatrix = buildSurfaceToBufferMatrix(); bufferToSurfaceMatrix = surfaceToBufferMatrix.inverted(); - inputRegion = current.input & QRect(QPoint(0, 0), surfaceSize); if (opaqueRegionChanged) { - Q_EMIT q->opaqueChanged(current.opaque); + Q_EMIT q->opaqueChanged(opaqueRegion); } if (oldInputRegion != inputRegion) { Q_EMIT q->inputChanged(inputRegion); @@ -715,7 +725,7 @@ QRegion SurfaceInterface::damage() const QRegion SurfaceInterface::opaque() const { - return d->current.opaque; + return d->opaqueRegion; } QRegion SurfaceInterface::input() const diff --git a/src/wayland/surface_interface_p.h b/src/wayland/surface_interface_p.h index 15274a14a9..9b412baae8 100644 --- a/src/wayland/surface_interface_p.h +++ b/src/wayland/surface_interface_p.h @@ -107,6 +107,7 @@ public: QSize implicitSurfaceSize; QSize surfaceSize; QRegion inputRegion; + QRegion opaqueRegion; ClientBuffer *bufferRef = nullptr; bool mapped = false; bool hasCacheState = false;