Validate matched containers for "kill" command correctly.

We now execute the validations when "kill" is executed even if match
criteria are used. This prevents users from killing workspace containers,
which instead kills all clients (as before when not using criteria).

fixes #1761
This commit is contained in:
Ingo Bürk
2015-12-27 22:11:51 -05:00
parent 0dd71674de
commit 19c273a2ad
6 changed files with 44 additions and 44 deletions

View File

@ -220,6 +220,36 @@ void con_focus(Con *con) {
}
}
/*
* Closes the given container.
*
*/
void con_close(Con *con, kill_window_t kill_window) {
assert(con != NULL);
DLOG("Closing con = %p.\n", con);
/* We never close output or root containers. */
if (con->type == CT_OUTPUT || con->type == CT_ROOT) {
DLOG("con = %p is of type %d, not closing anything.\n", con, con->type);
return;
}
if (con->type == CT_WORKSPACE) {
DLOG("con = %p is a workspace, closing all children instead.\n", con);
Con *child, *nextchild;
for (child = TAILQ_FIRST(&(con->focus_head)); child;) {
nextchild = TAILQ_NEXT(child, focused);
DLOG("killing child = %p.\n", child);
tree_close_internal(child, kill_window, false, false);
child = nextchild;
}
return;
}
tree_close_internal(con, kill_window, false, false);
}
/*
* Returns true when this node is a leaf node (has no children)
*