wayland: Switch to SurfaceInterface::{below,above}
This commit is contained in:
parent
a1847f77f1
commit
2a1f9f1646
3 changed files with 46 additions and 17 deletions
|
@ -1304,8 +1304,7 @@ int SurfaceTreeModel::rowCount(const QModelIndex &parent) const
|
|||
if (parent.isValid()) {
|
||||
using namespace KWaylandServer;
|
||||
if (SurfaceInterface *surface = static_cast<SurfaceInterface*>(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<SurfaceInterface*>(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();
|
||||
|
|
|
@ -67,8 +67,13 @@ void SubSurfaceMonitor::registerSurface(SurfaceInterface *surface)
|
|||
connect(surface, &SurfaceInterface::childSubSurfaceRemoved,
|
||||
this, &SubSurfaceMonitor::unregisterSubSurface);
|
||||
|
||||
const QList<SubSurfaceInterface *> childSubSurfaces = surface->childSubSurfaces();
|
||||
for (SubSurfaceInterface *childSubSurface : childSubSurfaces) {
|
||||
const QList<SubSurfaceInterface *> below = surface->below();
|
||||
for (SubSurfaceInterface *childSubSurface : below) {
|
||||
registerSubSurface(childSubSurface);
|
||||
}
|
||||
|
||||
const QList<SubSurfaceInterface *> above = surface->above();
|
||||
for (SubSurfaceInterface *childSubSurface : above) {
|
||||
registerSubSurface(childSubSurface);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -48,8 +48,13 @@ SurfaceItemWayland::SurfaceItemWayland(KWaylandServer::SurfaceInterface *surface
|
|||
setPosition(subsurface->position());
|
||||
}
|
||||
|
||||
const QList<KWaylandServer::SubSurfaceInterface *> children = surface->childSubSurfaces();
|
||||
for (KWaylandServer::SubSurfaceInterface *subsurface : children) {
|
||||
const QList<KWaylandServer::SubSurfaceInterface *> below = surface->below();
|
||||
for (KWaylandServer::SubSurfaceInterface *subsurface : below) {
|
||||
handleChildSubSurfaceAdded(subsurface);
|
||||
}
|
||||
|
||||
const QList<KWaylandServer::SubSurfaceInterface *> above = surface->above();
|
||||
for (KWaylandServer::SubSurfaceInterface *subsurface : above) {
|
||||
handleChildSubSurfaceAdded(subsurface);
|
||||
}
|
||||
|
||||
|
@ -110,11 +115,16 @@ void SurfaceItemWayland::handleChildSubSurfaceRemoved(KWaylandServer::SubSurface
|
|||
|
||||
void SurfaceItemWayland::handleChildSubSurfacesChanged()
|
||||
{
|
||||
const QList<KWaylandServer::SubSurfaceInterface *> stackingOrder = m_surface->childSubSurfaces();
|
||||
QList<Item *> items;
|
||||
items.reserve(stackingOrder.count());
|
||||
const QList<KWaylandServer::SubSurfaceInterface *> below = m_surface->below();
|
||||
const QList<KWaylandServer::SubSurfaceInterface *> above = m_surface->above();
|
||||
|
||||
for (KWaylandServer::SubSurfaceInterface *subsurface : stackingOrder) {
|
||||
QList<Item *> 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]);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue