From 7059aa83bcaecb0b1029f331f4d38229f84ed752 Mon Sep 17 00:00:00 2001 From: Brenden Matthews Date: Sat, 24 Feb 2024 16:31:07 -0500 Subject: [PATCH] Stop walking window tree if we get zero It looks like some of the child windows are zero, which causes the next call to XQueryTree to blow up. --- src/x11.cc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/x11.cc b/src/x11.cc index b1040fb21..6168c0e11 100644 --- a/src/x11.cc +++ b/src/x11.cc @@ -1384,8 +1384,13 @@ inline Window last_descendant(Display *display, Window parent) { while ( XQueryTree(display, current, &_ignored, &_ignored, &children, &count) && count != 0) { - current = children[count - 1]; + auto next = children[count - 1]; XFree(children); + if (next != 0) { + current = next; + } else { + break; + } } return current;