diff --git a/src/debug_console.cpp b/src/debug_console.cpp index 1a6e0d77ca..977471e430 100644 --- a/src/debug_console.cpp +++ b/src/debug_console.cpp @@ -1304,8 +1304,7 @@ int SurfaceTreeModel::rowCount(const QModelIndex &parent) const if (parent.isValid()) { using namespace KWaylandServer; if (SurfaceInterface *surface = static_cast(parent.internalPointer())) { - const auto &children = surface->childSubSurfaces(); - return children.count(); + return surface->below().count() + surface->above().count(); } return 0; } @@ -1324,9 +1323,16 @@ QModelIndex SurfaceTreeModel::index(int row, int column, const QModelIndex &pare if (parent.isValid()) { using namespace KWaylandServer; if (SurfaceInterface *surface = static_cast(parent.internalPointer())) { - const auto &children = surface->childSubSurfaces(); - if (row < children.count()) { - return createIndex(row, column, children.at(row)->surface()); + int reference = 0; + const auto &below = surface->below(); + if (row < reference + below.count()) { + return createIndex(row, column, below.at(row - reference)->surface()); + } + reference += below.count(); + + const auto &above = surface->above(); + if (row < reference + above.count()) { + return createIndex(row, column, above.at(row - reference)->surface()); } } return QModelIndex(); @@ -1368,10 +1374,18 @@ QModelIndex SurfaceTreeModel::parent(const QModelIndex &child) const // something is wrong return QModelIndex(); } - const auto &children = grandParent->childSubSurfaces(); - for (int row = 0; row < children.count(); row++) { - if (children.at(row) == parent->subSurface()) { - return createIndex(row, 0, parent); + int row = 0; + const auto &below = grandParent->below(); + for (int i = 0; i < below.count(); i++) { + if (below.at(i) == parent->subSurface()) { + return createIndex(row + i, 0, parent); + } + } + row += below.count(); + const auto &above = grandParent->above(); + for (int i = 0; i < above.count(); i++) { + if (above.at(i) == parent->subSurface()) { + return createIndex(row + i, 0, parent); } } return QModelIndex(); diff --git a/src/subsurfacemonitor.cpp b/src/subsurfacemonitor.cpp index e5ba41e226..acfe84a1af 100644 --- a/src/subsurfacemonitor.cpp +++ b/src/subsurfacemonitor.cpp @@ -67,8 +67,13 @@ void SubSurfaceMonitor::registerSurface(SurfaceInterface *surface) connect(surface, &SurfaceInterface::childSubSurfaceRemoved, this, &SubSurfaceMonitor::unregisterSubSurface); - const QList childSubSurfaces = surface->childSubSurfaces(); - for (SubSurfaceInterface *childSubSurface : childSubSurfaces) { + const QList below = surface->below(); + for (SubSurfaceInterface *childSubSurface : below) { + registerSubSurface(childSubSurface); + } + + const QList above = surface->above(); + for (SubSurfaceInterface *childSubSurface : above) { registerSubSurface(childSubSurface); } } diff --git a/src/surfaceitem_wayland.cpp b/src/surfaceitem_wayland.cpp index 428f7b1581..e2d848bc98 100644 --- a/src/surfaceitem_wayland.cpp +++ b/src/surfaceitem_wayland.cpp @@ -48,8 +48,13 @@ SurfaceItemWayland::SurfaceItemWayland(KWaylandServer::SurfaceInterface *surface setPosition(subsurface->position()); } - const QList children = surface->childSubSurfaces(); - for (KWaylandServer::SubSurfaceInterface *subsurface : children) { + const QList below = surface->below(); + for (KWaylandServer::SubSurfaceInterface *subsurface : below) { + handleChildSubSurfaceAdded(subsurface); + } + + const QList above = surface->above(); + for (KWaylandServer::SubSurfaceInterface *subsurface : above) { handleChildSubSurfaceAdded(subsurface); } @@ -110,11 +115,16 @@ void SurfaceItemWayland::handleChildSubSurfaceRemoved(KWaylandServer::SubSurface void SurfaceItemWayland::handleChildSubSurfacesChanged() { - const QList stackingOrder = m_surface->childSubSurfaces(); - QList items; - items.reserve(stackingOrder.count()); + const QList below = m_surface->below(); + const QList above = m_surface->above(); - for (KWaylandServer::SubSurfaceInterface *subsurface : stackingOrder) { + QList items; + items.reserve(below.count() + above.count()); + + for (KWaylandServer::SubSurfaceInterface *subsurface : below) { + items.append(m_subsurfaces[subsurface]); + } + for (KWaylandServer::SubSurfaceInterface *subsurface : above) { items.append(m_subsurfaces[subsurface]); }