]> git.sur5r.net Git - i3/i3/commitdiff
Merge branch 'master' into next
authorMichael Stapelberg <michael@stapelberg.de>
Tue, 7 Feb 2012 22:42:58 +0000 (17:42 -0500)
committerMichael Stapelberg <michael@stapelberg.de>
Tue, 7 Feb 2012 22:42:58 +0000 (17:42 -0500)
1  2 
src/tree.c
testcases/t/122-split.t

diff --combined src/tree.c
index 7e6321003ca260ddee8780110e7109ee38ecf853,f5bac1939b0425b84f106d7a6d990323eb31b44f..5559908f0738d20afbbed8e9b5f048a7609a4e65
@@@ -15,48 -15,7 +15,48 @@@ struct Con *focused
  struct all_cons_head all_cons = TAILQ_HEAD_INITIALIZER(all_cons);
  
  /*
 - * Loads tree from ~/.i3/_restart.json (used for in-place restarts).
 + * Create the pseudo-output __i3. Output-independent workspaces such as
 + * __i3_scratch will live there.
 + *
 + */
 +static Con *_create___i3() {
 +    Con *__i3 = con_new(croot, NULL);
 +    FREE(__i3->name);
 +    __i3->name = sstrdup("__i3");
 +    __i3->type = CT_OUTPUT;
 +    __i3->layout = L_OUTPUT;
 +    con_fix_percent(croot);
 +    x_set_name(__i3, "[i3 con] pseudo-output __i3");
 +    /* For retaining the correct position/size of a scratchpad window, the
 +     * dimensions of the real outputs should be multiples of the __i3
 +     * pseudo-output. */
 +    __i3->rect.width = 1280;
 +    __i3->rect.height = 1024;
 +
 +    /* Add a content container. */
 +    DLOG("adding main content container\n");
 +    Con *content = con_new(NULL, NULL);
 +    content->type = CT_CON;
 +    FREE(content->name);
 +    content->name = sstrdup("content");
 +
 +    x_set_name(content, "[i3 con] content __i3");
 +    con_attach(content, __i3, false);
 +
 +    /* Attach the __i3_scratch workspace. */
 +    Con *ws = con_new(NULL, NULL);
 +    ws->type = CT_WORKSPACE;
 +    ws->num = -1;
 +    ws->name = sstrdup("__i3_scratch");
 +    con_attach(ws, content, false);
 +    x_set_name(ws, "[i3 con] workspace __i3_scratch");
 +    ws->fullscreen_mode = CF_OUTPUT;
 +
 +    return __i3;
 +}
 +
 +/*
 + * Loads tree from 'path' (used for in-place restarts).
   *
   */
  bool tree_restore(const char *path, xcb_get_geometry_reply_t *geometry) {
      Con *ws = TAILQ_FIRST(&(out->nodes_head));
      printf("ws = %p\n", ws);
  
 +    /* For in-place restarting into v4.2, we need to make sure the new
 +     * pseudo-output __i3 is present. */
 +    if (strcmp(out->name, "__i3") != 0) {
 +        DLOG("Adding pseudo-output __i3 during inplace restart\n");
 +        Con *__i3 = _create___i3();
 +        /* Ensure that it is the first output, other places in the code make
 +         * that assumption. */
 +        TAILQ_REMOVE(&(croot->nodes_head), __i3, nodes);
 +        TAILQ_INSERT_HEAD(&(croot->nodes_head), __i3, nodes);
 +    }
 +
      return true;
  }
  
@@@ -118,8 -66,6 +118,8 @@@ void tree_init(xcb_get_geometry_reply_
          geometry->width,
          geometry->height
      };
 +
 +    _create___i3();
  }
  
  /*
@@@ -342,15 -288,11 +342,16 @@@ void tree_split(Con *con, orientation_
      }
  
      Con *parent = con->parent;
 +
 +    /* Force re-rendering to make the indicator border visible. */
 +    FREE(con->deco_render_params);
 +    FREE(parent->deco_render_params);
 +
      /* if we are in a container whose parent contains only one
       * child (its split functionality is unused so far), we just change the
       * orientation (more intuitive than splitting again) */
-     if (con_num_children(parent) == 1) {
+     if (con_num_children(parent) == 1 &&
+         parent->layout == L_DEFAULT) {
          parent->orientation = orientation;
          DLOG("Just changing orientation of existing container\n");
          return;
diff --combined testcases/t/122-split.t
index 71736db462fd7e8d47400f5f25e4cf754d36d12e,0dfb99a37afb81f595db415c5e07b35af10bd6a7..702679ac41e734880fc2a951231b2d853c81dcfd
@@@ -4,6 -4,7 +4,6 @@@
  # Tests splitting
  #
  use i3test;
 -use X11::XCB qw(:all);
  
  my $tmp = fresh_workspace;
  
@@@ -88,4 -89,25 +88,25 @@@ cmd 'split v'
  my $count = sum_nodes(\@content);
  is($count, $old_count, 'not more windows after splitting again');
  
+ ######################################################################
+ # In the special case of being inside a stacked or tabbed container, we don’t
+ # want this to happen.
+ ######################################################################
+ $tmp = fresh_workspace;
+ cmd 'open';
+ @content = @{get_ws_content($tmp)};
+ is(scalar @content, 1, 'Precisely one container on this ws');
+ cmd 'layout stacked';
+ @content = @{get_ws_content($tmp)};
+ is(scalar @content, 1, 'Still one container on this ws');
+ is(scalar @{$content[0]->{nodes}}, 1, 'Stacked con has one child node');
+ cmd 'split h';
+ cmd 'open';
+ @content = @{get_ws_content($tmp)};
+ is(scalar @content, 1, 'Still one container on this ws');
+ is(scalar @{$content[0]->{nodes}}, 1, 'Stacked con still has one child node');
  done_testing;