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()) {
|
if (parent.isValid()) {
|
||||||
using namespace KWaylandServer;
|
using namespace KWaylandServer;
|
||||||
if (SurfaceInterface *surface = static_cast<SurfaceInterface*>(parent.internalPointer())) {
|
if (SurfaceInterface *surface = static_cast<SurfaceInterface*>(parent.internalPointer())) {
|
||||||
const auto &children = surface->childSubSurfaces();
|
return surface->below().count() + surface->above().count();
|
||||||
return children.count();
|
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -1324,9 +1323,16 @@ QModelIndex SurfaceTreeModel::index(int row, int column, const QModelIndex &pare
|
||||||
if (parent.isValid()) {
|
if (parent.isValid()) {
|
||||||
using namespace KWaylandServer;
|
using namespace KWaylandServer;
|
||||||
if (SurfaceInterface *surface = static_cast<SurfaceInterface*>(parent.internalPointer())) {
|
if (SurfaceInterface *surface = static_cast<SurfaceInterface*>(parent.internalPointer())) {
|
||||||
const auto &children = surface->childSubSurfaces();
|
int reference = 0;
|
||||||
if (row < children.count()) {
|
const auto &below = surface->below();
|
||||||
return createIndex(row, column, children.at(row)->surface());
|
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();
|
return QModelIndex();
|
||||||
|
@ -1368,10 +1374,18 @@ QModelIndex SurfaceTreeModel::parent(const QModelIndex &child) const
|
||||||
// something is wrong
|
// something is wrong
|
||||||
return QModelIndex();
|
return QModelIndex();
|
||||||
}
|
}
|
||||||
const auto &children = grandParent->childSubSurfaces();
|
int row = 0;
|
||||||
for (int row = 0; row < children.count(); row++) {
|
const auto &below = grandParent->below();
|
||||||
if (children.at(row) == parent->subSurface()) {
|
for (int i = 0; i < below.count(); i++) {
|
||||||
return createIndex(row, 0, parent);
|
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();
|
return QModelIndex();
|
||||||
|
|
|
@ -67,8 +67,13 @@ void SubSurfaceMonitor::registerSurface(SurfaceInterface *surface)
|
||||||
connect(surface, &SurfaceInterface::childSubSurfaceRemoved,
|
connect(surface, &SurfaceInterface::childSubSurfaceRemoved,
|
||||||
this, &SubSurfaceMonitor::unregisterSubSurface);
|
this, &SubSurfaceMonitor::unregisterSubSurface);
|
||||||
|
|
||||||
const QList<SubSurfaceInterface *> childSubSurfaces = surface->childSubSurfaces();
|
const QList<SubSurfaceInterface *> below = surface->below();
|
||||||
for (SubSurfaceInterface *childSubSurface : childSubSurfaces) {
|
for (SubSurfaceInterface *childSubSurface : below) {
|
||||||
|
registerSubSurface(childSubSurface);
|
||||||
|
}
|
||||||
|
|
||||||
|
const QList<SubSurfaceInterface *> above = surface->above();
|
||||||
|
for (SubSurfaceInterface *childSubSurface : above) {
|
||||||
registerSubSurface(childSubSurface);
|
registerSubSurface(childSubSurface);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,8 +48,13 @@ SurfaceItemWayland::SurfaceItemWayland(KWaylandServer::SurfaceInterface *surface
|
||||||
setPosition(subsurface->position());
|
setPosition(subsurface->position());
|
||||||
}
|
}
|
||||||
|
|
||||||
const QList<KWaylandServer::SubSurfaceInterface *> children = surface->childSubSurfaces();
|
const QList<KWaylandServer::SubSurfaceInterface *> below = surface->below();
|
||||||
for (KWaylandServer::SubSurfaceInterface *subsurface : children) {
|
for (KWaylandServer::SubSurfaceInterface *subsurface : below) {
|
||||||
|
handleChildSubSurfaceAdded(subsurface);
|
||||||
|
}
|
||||||
|
|
||||||
|
const QList<KWaylandServer::SubSurfaceInterface *> above = surface->above();
|
||||||
|
for (KWaylandServer::SubSurfaceInterface *subsurface : above) {
|
||||||
handleChildSubSurfaceAdded(subsurface);
|
handleChildSubSurfaceAdded(subsurface);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -110,11 +115,16 @@ void SurfaceItemWayland::handleChildSubSurfaceRemoved(KWaylandServer::SubSurface
|
||||||
|
|
||||||
void SurfaceItemWayland::handleChildSubSurfacesChanged()
|
void SurfaceItemWayland::handleChildSubSurfacesChanged()
|
||||||
{
|
{
|
||||||
const QList<KWaylandServer::SubSurfaceInterface *> stackingOrder = m_surface->childSubSurfaces();
|
const QList<KWaylandServer::SubSurfaceInterface *> below = m_surface->below();
|
||||||
QList<Item *> items;
|
const QList<KWaylandServer::SubSurfaceInterface *> above = m_surface->above();
|
||||||
items.reserve(stackingOrder.count());
|
|
||||||
|
|
||||||
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]);
|
items.append(m_subsurfaces[subsurface]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue