From eef9042713bd9b26c23e42f1bf07100113e1f599 Mon Sep 17 00:00:00 2001 From: jj Date: Fri, 11 Oct 2013 20:12:05 +0200 Subject: [PATCH] Fix endless loop when trying to kill a visible workspace This regression was introduced with commit 97b086efd9833d2a787e54417789b279143e43a6 fixes #1103 --- src/tree.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/tree.c b/src/tree.c index 4df9f593..65d709a5 100644 --- a/src/tree.c +++ b/src/tree.c @@ -229,11 +229,6 @@ bool tree_close(Con *con, kill_window_t kill_window, bool dont_kill_parent, bool return false; } - if (workspace_is_visible(con)) { - DLOG("A visible workspace cannot be killed.\n"); - return false; - } - if (con->window != NULL) { if (kill_window != DONT_KILL_WINDOW) { x_window_kill(con->window->id, kill_window); @@ -369,6 +364,19 @@ void tree_close_con(kill_window_t kill_window) { assert(focused->type != CT_OUTPUT); assert(focused->type != CT_ROOT); + if (focused->type == CT_WORKSPACE) { + DLOG("Workspaces cannot be close, closing all children instead\n"); + Con *child, *nextchild; + for (child = TAILQ_FIRST(&(focused->nodes_head)); child; ) { + nextchild = TAILQ_NEXT(child, nodes); + DLOG("killing child=%p\n", child); + tree_close(child, kill_window, false, false); + child = nextchild; + } + + return; + } + /* Kill con */ tree_close(focused, kill_window, false, false); } -- 2.39.5