diff --git a/src/item.cpp b/src/item.cpp index ec0ad630d2..471dff1eae 100644 --- a/src/item.cpp +++ b/src/item.cpp @@ -245,24 +245,6 @@ void Item::stackAfter(Item *sibling) sibling->scheduleRepaint(sibling->boundingRect()); } -void Item::stackChildren(const QList &children) -{ - if (m_childItems.count() != children.count()) { - qCWarning(KWIN_CORE) << Q_FUNC_INFO << "invalid child list"; - return; - } - -#if !defined(QT_NO_DEBUG) - for (const Item *item : children) { - Q_ASSERT_X(item->parentItem() == this, Q_FUNC_INFO, "invalid parent"); - } -#endif - - m_childItems = children; - discardQuads(); - markSortedChildItemsDirty(); -} - void Item::scheduleRepaint(const QRegion ®ion) { if (isVisible()) { diff --git a/src/item.h b/src/item.h index e066f40836..e9a5bbc251 100644 --- a/src/item.h +++ b/src/item.h @@ -73,11 +73,6 @@ public: * Moves this item right after the specified @a sibling in the parent's children list. */ void stackAfter(Item *sibling); - /** - * Restacks the child items in the specified order. Note that the specified stacking order - * must be a permutation of childItems(). - */ - void stackChildren(const QList &children); bool isVisible() const; void setVisible(bool visible); diff --git a/src/surfaceitem_wayland.cpp b/src/surfaceitem_wayland.cpp index e2d848bc98..fe6a29cd28 100644 --- a/src/surfaceitem_wayland.cpp +++ b/src/surfaceitem_wayland.cpp @@ -36,8 +36,6 @@ SurfaceItemWayland::SurfaceItemWayland(KWaylandServer::SurfaceInterface *surface this, &SurfaceItemWayland::handleSurfaceCommitted); connect(surface, &KWaylandServer::SurfaceInterface::damaged, this, &SurfaceItemWayland::addDamage); - connect(surface, &KWaylandServer::SurfaceInterface::childSubSurfaceAdded, - this, &SurfaceItemWayland::handleChildSubSurfaceAdded); connect(surface, &KWaylandServer::SurfaceInterface::childSubSurfaceRemoved, this, &SurfaceItemWayland::handleChildSubSurfaceRemoved); @@ -48,16 +46,7 @@ SurfaceItemWayland::SurfaceItemWayland(KWaylandServer::SurfaceInterface *surface setPosition(subsurface->position()); } - const QList below = surface->below(); - for (KWaylandServer::SubSurfaceInterface *subsurface : below) { - handleChildSubSurfaceAdded(subsurface); - } - - const QList above = surface->above(); - for (KWaylandServer::SubSurfaceInterface *subsurface : above) { - handleChildSubSurfaceAdded(subsurface); - } - + handleChildSubSurfacesChanged(); setSize(surface->size()); } @@ -99,13 +88,15 @@ void SurfaceItemWayland::handleSurfaceCommitted() } } -void SurfaceItemWayland::handleChildSubSurfaceAdded(KWaylandServer::SubSurfaceInterface *child) +SurfaceItemWayland *SurfaceItemWayland::getOrCreateSubSurfaceItem(KWaylandServer::SubSurfaceInterface *child) { - SurfaceItemWayland *subsurfaceItem = new SurfaceItemWayland(child->surface(), window()); - subsurfaceItem->setParent(this); - subsurfaceItem->setParentItem(this); - - m_subsurfaces.insert(child, subsurfaceItem); + SurfaceItemWayland *&item = m_subsurfaces[child]; + if (!item) { + item = new SurfaceItemWayland(child->surface(), window()); + item->setParent(this); + item->setParentItem(this); + } + return item; } void SurfaceItemWayland::handleChildSubSurfaceRemoved(KWaylandServer::SubSurfaceInterface *child) @@ -118,17 +109,15 @@ void SurfaceItemWayland::handleChildSubSurfacesChanged() const QList below = m_surface->below(); const QList above = m_surface->above(); - QList items; - items.reserve(below.count() + above.count()); - - for (KWaylandServer::SubSurfaceInterface *subsurface : below) { - items.append(m_subsurfaces[subsurface]); + for (int i = 0; i < below.count(); ++i) { + SurfaceItemWayland *subsurfaceItem = getOrCreateSubSurfaceItem(below[i]); + subsurfaceItem->setZ(i - below.count()); } - for (KWaylandServer::SubSurfaceInterface *subsurface : above) { - items.append(m_subsurfaces[subsurface]); + + for (int i = 0; i < above.count(); ++i) { + SurfaceItemWayland *subsurfaceItem = getOrCreateSubSurfaceItem(above[i]); + subsurfaceItem->setZ(i); } - - stackChildren(items); } void SurfaceItemWayland::handleSubSurfacePositionChanged() diff --git a/src/surfaceitem_wayland.h b/src/surfaceitem_wayland.h index 762c3a0156..de18775901 100644 --- a/src/surfaceitem_wayland.h +++ b/src/surfaceitem_wayland.h @@ -39,7 +39,6 @@ private Q_SLOTS: void handleSurfaceCommitted(); void handleSurfaceSizeChanged(); - void handleChildSubSurfaceAdded(KWaylandServer::SubSurfaceInterface *child); void handleChildSubSurfaceRemoved(KWaylandServer::SubSurfaceInterface *child); void handleChildSubSurfacesChanged(); void handleSubSurfacePositionChanged(); @@ -48,6 +47,8 @@ protected: SurfacePixmap *createPixmap() override; private: + SurfaceItemWayland *getOrCreateSubSurfaceItem(KWaylandServer::SubSurfaceInterface *s); + QPointer m_surface; QHash m_subsurfaces; };