]> git.sur5r.net Git - i3/i3/commitdiff
Make splitting a container which was already split a noop
authorMichael Stapelberg <michael@stapelberg.de>
Tue, 1 Jun 2010 20:45:18 +0000 (22:45 +0200)
committerMichael Stapelberg <michael@stapelberg.de>
Tue, 1 Jun 2010 20:45:18 +0000 (22:45 +0200)
include/data.h
src/tree.c
src/workspace.c

index 22884aa75e914de63c81ac91e12b79c68d45057d..def5d4b776394df5c593597a7ae68b7f34862c8d 100644 (file)
@@ -41,7 +41,7 @@ typedef struct Window i3Window;
  * Helper types
  *****************************************************************************/
 typedef enum { D_LEFT, D_RIGHT, D_UP, D_DOWN } direction_t;
-typedef enum { HORIZ, VERT, NO_ORIENTATION } orientation_t;
+typedef enum { NO_ORIENTATION = 0, HORIZ, VERT } orientation_t;
 
 enum {
     BIND_NONE = 0,
index 7b31ea6bd34456c9c85c1168ff92c6544c4b25c0..c4315e313ddbabae129af691af2ab242b0938bb4 100644 (file)
@@ -74,6 +74,7 @@ void tree_init() {
         ws->type = CT_WORKSPACE;
         ws->name = strdup("1");
         ws->fullscreen_mode = CF_OUTPUT;
+        ws->orientation = HORIZ;
     }
 
     con_focus(ws);
@@ -203,9 +204,17 @@ void tree_split(Con *con, orientation_t orientation) {
         con->orientation = orientation;
         return;
     }
+
+    Con *parent = con->parent;
+    /* if we are in a container whose parent contains only one
+     * child and has the same orientation like we are trying to
+     * set, this operation is a no-op to not confuse the user */
+    if (parent->orientation == orientation &&
+        TAILQ_NEXT(con, nodes) == TAILQ_END(&(parent->nodes_head)))
+        return;
+
     /* 2: replace it with a new Con */
     Con *new = con_new(NULL);
-    Con *parent = con->parent;
     TAILQ_REPLACE(&(parent->nodes_head), con, new, nodes);
     TAILQ_REPLACE(&(parent->focus_head), con, new, focused);
     new->parent = parent;
index 457603ee9edd41c3f51c5d24ec320dbffb66a4e5..17986bafd87f15bbd611ac8bb69dda866c45cf32 100644 (file)
@@ -41,6 +41,7 @@ Con *workspace_get(const char *num) {
         workspace = con_new(output);
         workspace->type = CT_WORKSPACE;
         workspace->name = strdup(num);
+        workspace->orientation = HORIZ;
 
         ipc_send_event("workspace", I3_IPC_EVENT_WORKSPACE, "{\"change\":\"init\"}");
     }