Bugfix: Close containers which are empty due to a move (Thanks fernando)

This commit is contained in:
Michael Stapelberg
2010-11-13 14:55:11 +01:00
parent 4aef09ab34
commit dc10c67060
5 changed files with 48 additions and 8 deletions

@ -286,6 +286,20 @@ Con *con_for_window(i3Window *window, Match **store_match) {
return NULL;
}
/*
* Returns the number of children of this container.
*
*/
int con_num_children(Con *con) {
Con *child;
int children = 0;
TAILQ_FOREACH(child, &(con->nodes_head), nodes)
children++;
return children;
}
/*
* 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
@ -294,9 +308,7 @@ Con *con_for_window(i3Window *window, Match **store_match) {
*/
void con_fix_percent(Con *con, int action) {
Con *child;
int children = 0;
TAILQ_FOREACH(child, &(con->nodes_head), nodes)
children++;
int children = con_num_children(con);
/* TODO: better document why this math works */
double fix;
if (action == WINDOW_ADD)
@ -446,4 +458,6 @@ Rect con_border_style_rect(Con *con) {
if (con->border_style == BS_NONE)
return (Rect){0, 0, 0, 0};
assert(false);
}