Correctly count the number of windows for no_focus. (#2296)

Previously we counted the number of (direct) children of the workspace to
decide whether no_focus should be applied or not. However, this doesn't
work correctly if there's a single container with multiple windows on the
workspace.

This patch correctly counts all windows on the workspace.

fixes #2292
This commit is contained in:
Ingo Bürk
2016-04-15 09:26:42 +02:00
committed by Michael Stapelberg
parent 83c8740bf1
commit 80dddd9961
3 changed files with 27 additions and 1 deletions

View File

@ -727,6 +727,26 @@ int con_num_children(Con *con) {
return children;
}
/*
* Count the number of windows (i.e., leaf containers).
*
*/
int con_num_windows(Con *con) {
if (con == NULL)
return 0;
if (con_has_managed_window(con))
return 1;
int num = 0;
Con *current = NULL;
TAILQ_FOREACH(current, &(con->nodes_head), nodes) {
num += con_num_windows(current);
}
return num;
}
/*
* Updates the percent attribute of the children of the given container. This
* function needs to be called when a window is added or removed from a