From: Michael Stapelberg Date: Tue, 7 Feb 2012 22:42:58 +0000 (-0500) Subject: Merge branch 'master' into next X-Git-Tag: 4.2~88 X-Git-Url: https://git.sur5r.net/?p=i3%2Fi3;a=commitdiff_plain;h=ed2bcc15e384be99225a247435f6cff678e64f0c;hp=-c Merge branch 'master' into next --- ed2bcc15e384be99225a247435f6cff678e64f0c diff --combined src/tree.c index 7e632100,f5bac193..5559908f --- a/src/tree.c +++ b/src/tree.c @@@ -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) { @@@ -88,17 -47,6 +88,17 @@@ 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 71736db4,0dfb99a3..702679ac --- a/testcases/t/122-split.t +++ b/testcases/t/122-split.t @@@ -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;