window: properly break cycles in X11TransientFor

ref #8045
This commit is contained in:
Vaxry 2024-10-16 22:22:36 +01:00
parent 09581d32fd
commit b57086aa43

View file

@ -452,14 +452,20 @@ PHLWINDOW CWindow::X11TransientFor() {
return nullptr;
auto s = m_pXWaylandSurface->parent;
auto oldParent = s;
std::vector<SP<CXWaylandSurface>> visited;
while (s) {
// break cyclic loop of m_pXWaylandSurface being parent of itself, #TODO reject this from even being created?
if (!s->parent || s->parent == oldParent)
// break loops. Some X apps make them, and it seems like it's valid behavior?!?!?!
// TODO: we should reject loops being created in the first place.
if (std::find(visited.begin(), visited.end(), s) != visited.end())
break;
visited.emplace_back(s.lock());
s = s->parent;
}
if (s == m_pXWaylandSurface)
return nullptr; // dead-ass circle
for (auto const& w : g_pCompositor->m_vWindows) {
if (w->m_pXWaylandSurface != s)
continue;