+ /* 4: attach the new split container to the workspace */
+ DLOG("Attaching new split to ws\n");
+ con_attach(new, con, false);
+
+ if (old_focused)
+ con_focus(old_focused);
+
+ con = new;
+ set_focus = false;
+ }
+
+ /* 1: detach the container from its parent */
+ /* TODO: refactor this with tree_close() */
+ TAILQ_REMOVE(&(con->parent->nodes_head), con, nodes);
+ TAILQ_REMOVE(&(con->parent->focus_head), con, focused);
+
+ con_fix_percent(con->parent);
+
+ /* 2: create a new container to render the decoration on, add
+ * it as a floating window to the workspace */
+ Con *nc = con_new(NULL);
+ /* we need to set the parent afterwards instead of passing it as an
+ * argument to con_new() because nc would be inserted into the tiling layer
+ * 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);
+ free(name);
+
+ /* find the height for the decorations */
+ int deco_height = config.font.height + 5;
+
+ DLOG("Original rect: (%d, %d) with %d x %d\n", con->rect.x, con->rect.y, con->rect.width, con->rect.height);
+ Rect zero = { 0, 0, 0, 0 };
+ nc->rect = con->geometry;
+ /* If the geometry was not set (split containers), we need to determine a
+ * sensible one by combining the geometry of all children */
+ if (memcmp(&(nc->rect), &zero, sizeof(Rect)) == 0) {
+ DLOG("Geometry not set, combining children\n");
+ Con *child;
+ TAILQ_FOREACH(child, &(con->nodes_head), nodes) {
+ DLOG("child geometry: %d x %d\n", child->geometry.width, child->geometry.height);
+ nc->rect.width += child->geometry.width;
+ nc->rect.height = max(nc->rect.height, child->geometry.height);