tests: fix DefaultCompositor::surface() when index > 0

This amends c98bbc549557b1e0e7c972687ac2760204dff2a5.

Pick-to: 6.3
Change-Id: Id0759ebab699d762c134246d0ec9f72b03923bac
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
This commit is contained in:
Liang Qi 2022-03-10 12:44:59 +01:00
parent b41a7e47ee
commit b72632e01e

View File

@ -81,23 +81,25 @@ DefaultCompositor::DefaultCompositor(CompositorType t)
Surface *DefaultCompositor::surface(int i) Surface *DefaultCompositor::surface(int i)
{ {
Surface *result = nullptr; QList<Surface *> surfaces;
switch (m_type) { switch (m_type) {
case CompositorType::Default: case CompositorType::Default:
result = get<WlCompositor>()->m_surfaces.value(i, nullptr); return get<WlCompositor>()->m_surfaces.value(i, nullptr);
break;
case CompositorType::Legacy: { case CompositorType::Legacy: {
QList<Surface *> surfaces = get<WlCompositor>()->m_surfaces; QList<Surface *> msurfaces = get<WlCompositor>()->m_surfaces;
for (Surface *surface : surfaces) { for (Surface *surface : msurfaces) {
if (surface->isMapped()) { if (surface->isMapped()) {
result = surface; surfaces << surface;
break;
} }
} }
} }
break; break;
} }
return result;
if (i >= 0 && i < surfaces.size())
return surfaces[i];
return nullptr;
} }
uint DefaultCompositor::sendXdgShellPing() uint DefaultCompositor::sendXdgShellPing()