diff options
-rw-r--r-- | src/compositor/compositor_api/qwaylandview.cpp | 57 | ||||
-rw-r--r-- | src/compositor/compositor_api/qwaylandview_p.h | 2 |
2 files changed, 35 insertions, 24 deletions
diff --git a/src/compositor/compositor_api/qwaylandview.cpp b/src/compositor/compositor_api/qwaylandview.cpp index 477b45897..127593770 100644 --- a/src/compositor/compositor_api/qwaylandview.cpp +++ b/src/compositor/compositor_api/qwaylandview.cpp @@ -55,8 +55,9 @@ void QWaylandViewPrivate::markSurfaceAsDestroyed(QWaylandSurface *surface) Q_Q(QWaylandView); Q_ASSERT(surface == this->surface); - q->setSurface(nullptr); + setSurface(nullptr); emit q->surfaceDestroyed(); + clearFrontBuffer(); } /*! @@ -132,38 +133,46 @@ QWaylandSurface *QWaylandView::surface() const return d->surface; } -void QWaylandView::setSurface(QWaylandSurface *newSurface) -{ - Q_D(QWaylandView); - if (d->surface == newSurface) - return; - - if (d->surface) { - QWaylandSurfacePrivate::get(d->surface)->derefView(this); - if (d->output) - QWaylandOutputPrivate::get(d->output)->removeView(this, d->surface); +void QWaylandViewPrivate::setSurface(QWaylandSurface *newSurface) +{ + Q_Q(QWaylandView); + if (surface) { + QWaylandSurfacePrivate::get(surface)->derefView(q); + if (output) + QWaylandOutputPrivate::get(output)->removeView(q, surface); } - d->surface = newSurface; + surface = newSurface; - if (!d->bufferLocked) { - d->currentBuffer = QWaylandBufferRef(); - d->currentDamage = QRegion(); - } + nextBuffer = QWaylandBufferRef(); + nextBufferCommitted = false; + nextDamage = QRegion(); - d->nextBuffer = QWaylandBufferRef(); - d->nextBufferCommitted = false; - d->nextDamage = QRegion(); + if (surface) { + QWaylandSurfacePrivate::get(surface)->refView(q); + if (output) + QWaylandOutputPrivate::get(output)->addView(q, surface); + } +} - if (d->surface) { - QWaylandSurfacePrivate::get(d->surface)->refView(this); - if (d->output) - QWaylandOutputPrivate::get(d->output)->addView(this, d->surface); +void QWaylandViewPrivate::clearFrontBuffer() +{ + if (!bufferLocked) { + currentBuffer = QWaylandBufferRef(); + currentDamage = QRegion(); } +} - emit surfaceChanged(); +void QWaylandView::setSurface(QWaylandSurface *newSurface) +{ + Q_D(QWaylandView); + if (d->surface == newSurface) + return; + d->setSurface(newSurface); + d->clearFrontBuffer(); + emit surfaceChanged(); } /*! diff --git a/src/compositor/compositor_api/qwaylandview_p.h b/src/compositor/compositor_api/qwaylandview_p.h index b9cb0d07b..e7f521afe 100644 --- a/src/compositor/compositor_api/qwaylandview_p.h +++ b/src/compositor/compositor_api/qwaylandview_p.h @@ -74,6 +74,8 @@ public: { } void markSurfaceAsDestroyed(QWaylandSurface *surface); + void setSurface(QWaylandSurface *newSurface); + void clearFrontBuffer(); QObject *renderObject = nullptr; QWaylandSurface *surface = nullptr; |