Raise floating windows on focus [direction]

Raise a window when cycling focus between floating windows with `focus
[direction]` command so that newly focused windows are rendered on top
of other windows.

This is done by placing the window last in the floating nodes of the
parent and reordering the stack so the relative order is preserved.

fixes #1322
This commit is contained in:
Tony Crisci
2014-07-27 22:32:50 -04:00
committed by Michael Stapelberg
parent 1ee6bf1077
commit 034c82c0ac
2 changed files with 52 additions and 0 deletions

View File

@ -621,6 +621,14 @@ static bool _tree_next(Con *con, char way, orientation_t orientation, bool wrap)
if (!next)
return false;
/* Raise the floating window on top of other windows preserving
* relative stack order */
while (TAILQ_LAST(&(parent->floating_head), floating_head) != next) {
Con *last = TAILQ_LAST(&(parent->floating_head), floating_head);
TAILQ_REMOVE(&(parent->floating_head), last, floating_windows);
TAILQ_INSERT_HEAD(&(parent->floating_head), last, floating_windows);
}
con_focus(con_descend_focused(next));
return true;
}