]> git.sur5r.net Git - i3/i3/blobdiff - src/workspace.c
Merge branch 'master' into next
[i3/i3] / src / workspace.c
index 3a5844cb8c1794d1adbe50e6e713046d582739d0..ef6a2adde69f82e4bbd7ad1212ae070dd5a61883 100644 (file)
@@ -212,6 +212,7 @@ Con *create_workspace_on_output(Output *output, Con *content) {
 
     ws->fullscreen_mode = CF_OUTPUT;
 
+    ws->workspace_layout = config.default_layout;
     _workspace_apply_default_orientation(ws);
 
     return ws;
@@ -365,7 +366,7 @@ static void _workspace_show(Con *workspace) {
 
     workspace_reassign_sticky(workspace);
 
-    LOG("switching to %p\n", workspace);
+    DLOG("switching to %p / %s\n", workspace, workspace->name);
     Con *next = con_descend_focused(workspace);
 
     /* Memorize current output */
@@ -400,6 +401,7 @@ static void _workspace_show(Con *workspace) {
     } else
         con_focus(next);
 
+    DLOG("old = %p / %s\n", old, (old ? old->name : "(null)"));
     /* Close old workspace if necessary. This must be done *after* doing
      * urgency handling, because tree_close() will do a con_focus() on the next
      * client, which will clear the urgency flag too early. Also, there is no
@@ -829,3 +831,34 @@ Con *workspace_attach_to(Con *ws) {
 
     return new;
 }
+
+/**
+ * Creates a new container and re-parents all of children from the given
+ * workspace into it.
+ *
+ * The container inherits the layout from the workspace.
+ */
+Con *workspace_encapsulate(Con *ws) {
+    if (TAILQ_EMPTY(&(ws->nodes_head))) {
+        ELOG("Workspace %p / %s has no children to encapsulate\n", ws, ws->name);
+        return NULL;
+    }
+
+    Con *new = con_new(NULL, NULL);
+    new->parent = ws;
+    new->layout = ws->layout;
+
+    DLOG("Moving children of workspace %p / %s into container %p\n",
+        ws, ws->name, new);
+
+    Con *child;
+    while (!TAILQ_EMPTY(&(ws->nodes_head))) {
+        child = TAILQ_FIRST(&(ws->nodes_head));
+        con_detach(child);
+        con_attach(child, new, true);
+    }
+
+    con_attach(new, ws, true);
+
+    return new;
+}