diff --git a/src/wayland/autotests/client/test_wayland_surface.cpp b/src/wayland/autotests/client/test_wayland_surface.cpp index 48d751ae7f..f781909387 100644 --- a/src/wayland/autotests/client/test_wayland_surface.cpp +++ b/src/wayland/autotests/client/test_wayland_surface.cpp @@ -400,9 +400,12 @@ void TestWaylandSurface::testAttachBuffer() s->commit(KWayland::Client::Surface::CommitFlag::None); QSignalSpy damageSpy(serverSurface, SIGNAL(damaged(QRegion))); QVERIFY(damageSpy.isValid()); + QSignalSpy mappedSpy(serverSurface, SIGNAL(mapped())); + QVERIFY(mappedSpy.isValid()); QSignalSpy unmappedSpy(serverSurface, SIGNAL(unmapped())); QVERIFY(unmappedSpy.isValid()); QVERIFY(damageSpy.wait()); + QCOMPARE(mappedSpy.count(), 1); QVERIFY(unmappedSpy.isEmpty()); // now the ServerSurface should have the black image attached as a buffer @@ -418,6 +421,7 @@ void TestWaylandSurface::testAttachBuffer() s->commit(KWayland::Client::Surface::CommitFlag::None); damageSpy.clear(); QVERIFY(damageSpy.wait()); + QCOMPARE(mappedSpy.count(), 1); QVERIFY(unmappedSpy.isEmpty()); KWaylandServer::BufferInterface *buffer2 = serverSurface->buffer(); buffer2->ref(); @@ -445,6 +449,7 @@ void TestWaylandSurface::testAttachBuffer() s->commit(); damageSpy.clear(); QVERIFY(damageSpy.wait()); + QCOMPARE(mappedSpy.count(), 1); QVERIFY(unmappedSpy.isEmpty()); QVERIFY(!buffer2->isReferenced()); delete buffer2; @@ -485,6 +490,7 @@ void TestWaylandSurface::testAttachBuffer() QCOMPARE(serverSurface->input(), QRegion(0, 0, 24, 24)); QCOMPARE(serverSurface->buffer(), buffer3); QVERIFY(damageSpy.isEmpty()); + QCOMPARE(mappedSpy.count(), 1); QVERIFY(unmappedSpy.isEmpty()); QVERIFY(serverSurface->isMapped()); @@ -496,7 +502,7 @@ void TestWaylandSurface::testAttachBuffer() s->damage(QRect(0, 0, 10, 10)); s->commit(KWayland::Client::Surface::CommitFlag::None); QVERIFY(unmappedSpy.wait()); - QVERIFY(!unmappedSpy.isEmpty()); + QCOMPARE(mappedSpy.count(), 1); QCOMPARE(unmappedSpy.count(), 1); QVERIFY(damageSpy.isEmpty()); QVERIFY(!serverSurface->isMapped()); diff --git a/src/wayland/surface_interface.cpp b/src/wayland/surface_interface.cpp index 8494392f6b..fec350f0d3 100644 --- a/src/wayland/surface_interface.cpp +++ b/src/wayland/surface_interface.cpp @@ -328,6 +328,7 @@ void SurfaceInterface::Private::swapStates(State *source, State *target, bool em const bool contrastChanged = source->contrastIsSet; const bool slideChanged = source->slideIsSet; const bool childrenChanged = source->childrenChanged; + const bool visibilityChanged = bufferChanged && (bool(source->buffer) != bool(target->buffer)); bool sizeChanged = false; auto buffer = target->buffer; if (bufferChanged) { @@ -457,6 +458,9 @@ void SurfaceInterface::Private::swapStates(State *source, State *target, bool em target->damage = windowRegion.intersected(target->damage.united(bufferDamage)); if (emitChanged) { subSurfaceIsMapped = true; + if (visibilityChanged) { + emit q->mapped(); + } trackedDamage = trackedDamage.united(target->damage); emit q->damaged(target->damage); // workaround for https://bugreports.qt.io/browse/QTBUG-52092 diff --git a/src/wayland/surface_interface.h b/src/wayland/surface_interface.h index fda6365151..240277965c 100644 --- a/src/wayland/surface_interface.h +++ b/src/wayland/surface_interface.h @@ -299,6 +299,10 @@ Q_SIGNALS: void inputChanged(const QRegion&); void scaleChanged(qint32); void transformChanged(KWaylandServer::OutputInterface::Transform); + /** + * Emitted when the Surface becomes visible, i.e. a non-null buffer has been attached. + **/ + void mapped(); /** * Emitted when the Surface removes its content **/