Fix transient_for endless loop

Other approaches would be:
- Slow/fast pointer technique.
- Using a set/associative map to save 'seen' nodes. i3 does not have
  such data structure.

Counting the total amount of windows is the simpler to implement.

I've also extracted the logic in a function and re-used it in render.c.

Fixes #4404
This commit is contained in:
Orestis Floros
2021-11-11 20:14:22 +01:00
parent 43e805a00d
commit e1d3e6b2f6
6 changed files with 92 additions and 45 deletions

View File

@ -226,34 +226,12 @@ static void render_root(Con *con, Con *fullscreen) {
}
Con *floating_child = con_descend_focused(child);
Con *transient_con = floating_child;
bool is_transient_for = false;
while (transient_con != NULL &&
transient_con->window != NULL &&
transient_con->window->transient_for != XCB_NONE) {
DLOG("transient_con = 0x%08x, transient_con->window->transient_for = 0x%08x, fullscreen_id = 0x%08x\n",
transient_con->window->id, transient_con->window->transient_for, fullscreen->window->id);
if (transient_con->window->transient_for == fullscreen->window->id) {
is_transient_for = true;
break;
}
Con *next_transient = con_by_window_id(transient_con->window->transient_for);
if (next_transient == NULL)
break;
/* Some clients (e.g. x11-ssh-askpass) actually set
* WM_TRANSIENT_FOR to their own window id, so break instead of
* looping endlessly. */
if (transient_con == next_transient)
break;
transient_con = next_transient;
}
if (!is_transient_for)
continue;
else {
if (con_find_transient_for_window(floating_child, fullscreen->window->id)) {
DLOG("Rendering floating child even though in fullscreen mode: "
"floating->transient_for (0x%08x) --> fullscreen->id (0x%08x)\n",
floating_child->window->transient_for, fullscreen->window->id);
} else {
continue;
}
}
DLOG("floating child at (%d,%d) with %d x %d\n",