xwayland: break cyclic loop of parents (#6722)

in X11 some surfaces is a parent of itself and creates a cyclic loop
when trying to find its parent. check for old parent and break if its
beginning to roll over.
This commit is contained in:
Tom Englund 2024-07-01 00:26:08 +02:00 committed by GitHub
parent 4d6f96f74f
commit d7ea1b7785
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -444,9 +444,11 @@ PHLWINDOW CWindow::X11TransientFor() {
if (!m_pXWaylandSurface || !m_pXWaylandSurface->parent)
return nullptr;
auto s = m_pXWaylandSurface->parent;
auto s = m_pXWaylandSurface->parent;
auto oldParent = s;
while (s) {
if (!s->parent)
// break cyclic loop of m_pXWaylandSurface being parent of itself, #TODO reject this from even being created?
if (!s->parent || s->parent == oldParent)
break;
s = s->parent;
}