From dad7c0da00226ccaa97c1ba7a602c152fd65ccbb Mon Sep 17 00:00:00 2001 From: Michael Stapelberg Date: Tue, 1 Feb 2011 16:08:47 +0100 Subject: [PATCH] =?utf8?q?Don=E2=80=99t=20create=20a=20split=20container?= =?utf8?q?=20if=20no=20other=20cons=20are=20on=20a=20workspace=20(Thanks?= =?utf8?q?=20mseed)?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit This fixes #306. --- src/tree.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/tree.c b/src/tree.c index ed953b34..165e1516 100644 --- a/src/tree.c +++ b/src/tree.c @@ -396,6 +396,20 @@ void tree_move(char way, orientation_t orientation) { if (TAILQ_EMPTY(&(parent->nodes_head))) break; + /* Check if there are any other cons at all. If not, there is no + * point in creating a new split con and changing workspace + * orientation. Instead, the operation is a no-op. */ + Con *child; + bool other_container = false; + TAILQ_FOREACH(child, &(parent->nodes_head), nodes) + if (child != focused) + other_container = true; + + if (!other_container) { + DLOG("No other container found, we are not creating this split container.\n"); + return; + } + /* 1: create a new split container */ Con *new = con_new(NULL); new->parent = parent; @@ -410,7 +424,6 @@ void tree_move(char way, orientation_t orientation) { /* 3: move the existing cons of this workspace below the new con */ DLOG("Moving cons\n"); - Con *child; while (!TAILQ_EMPTY(&(parent->nodes_head))) { child = TAILQ_FIRST(&(parent->nodes_head)); con_detach(child); -- 2.39.5