From a5e075c154aadb77790b1d76395a2bffd24f745d Mon Sep 17 00:00:00 2001 From: Michael Stapelberg Date: Mon, 14 Feb 2011 16:43:41 +0100 Subject: [PATCH] Automatically close empty parent cons when making their last child floating (Thanks mseed) This fixes #313 --- src/floating.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/floating.c b/src/floating.c index c912dc71..25afa832 100644 --- a/src/floating.c +++ b/src/floating.c @@ -78,6 +78,12 @@ void floating_enable(Con *con, bool automatic) { * otherwise. */ nc->parent = con_get_workspace(con); + /* check if the parent container is empty and close it if so */ + if ((con->parent->type == CT_CON || con->parent->type == CT_FLOATING_CON) && con_num_children(con->parent) == 0) { + DLOG("Old container empty after setting this child to floating, closing\n"); + tree_close(con->parent, false, false); + } + char *name; asprintf(&name, "[i3 con] floatingcon around %p", con); x_set_name(nc, name); -- 2.39.5