wayland: Wire in surface mapped state

If a sub-surface should be considered unmapped, make the corresponding
item invisible.

Note that this must apply only to sub-surfaces. Whether the main surface
should be visible is up to kwin. It may want to play an animation when
the toplevel surface is unmapped, etc.
This commit is contained in:
Vlad Zahorodnii 2021-07-28 20:08:48 +03:00
parent aa386896f1
commit fdb1914a83
2 changed files with 11 additions and 0 deletions

View file

@ -39,8 +39,13 @@ SurfaceItemWayland::SurfaceItemWayland(KWaylandServer::SurfaceInterface *surface
KWaylandServer::SubSurfaceInterface *subsurface = surface->subSurface();
if (subsurface) {
connect(surface, &KWaylandServer::SurfaceInterface::mapped,
this, &SurfaceItemWayland::handleSubSurfaceMappedChanged);
connect(surface, &KWaylandServer::SurfaceInterface::unmapped,
this, &SurfaceItemWayland::handleSubSurfaceMappedChanged);
connect(subsurface, &KWaylandServer::SubSurfaceInterface::positionChanged,
this, &SurfaceItemWayland::handleSubSurfacePositionChanged);
setVisible(surface->isMapped());
setPosition(subsurface->position());
}
@ -123,6 +128,11 @@ void SurfaceItemWayland::handleSubSurfacePositionChanged()
setPosition(m_surface->subSurface()->position());
}
void SurfaceItemWayland::handleSubSurfaceMappedChanged()
{
setVisible(m_surface->isMapped());
}
SurfacePixmap *SurfaceItemWayland::createPixmap()
{
return new SurfacePixmapWayland(this);

View file

@ -42,6 +42,7 @@ private Q_SLOTS:
void handleChildSubSurfaceRemoved(KWaylandServer::SubSurfaceInterface *child);
void handleChildSubSurfacesChanged();
void handleSubSurfacePositionChanged();
void handleSubSurfaceMappedChanged();
protected:
SurfacePixmap *createPixmap() override;