Skip to content

Commit

Permalink
Fix 'layout toggle split'
Browse files Browse the repository at this point in the history
Fix the issue i3#2846 (i3#2846)

1). Create a new split container when switching a workspace container to split layout (credit: Streetwalrus)
2). Add one regression test in 167-workspace_layout.t:
    - Get a fresh workspace
    - Set the layout to something
    - Create windows
    - Try to switch to another layout
    - Check if successful
    - Repeat for all 12 possible transitions
3). Add another regression test in 167-workspace_layout.t:
    - Check that the command 'layout toggle split' works regardless of what layout we're
  • Loading branch information
hwangcc23 committed Aug 18, 2017
1 parent e4da07e commit c7437c8
Show file tree
Hide file tree
Showing 2 changed files with 203 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/con.c
Expand Up @@ -1674,7 +1674,7 @@ void con_set_layout(Con *con, layout_t layout) {
con->workspace_layout = ws_layout;
DLOG("Setting layout to %d\n", layout);
con->layout = layout;
} else if (layout == L_STACKED || layout == L_TABBED) {
} else if (layout == L_STACKED || layout == L_TABBED || layout == L_SPLITV || layout == L_SPLITH) {
DLOG("Creating new split container\n");
/* 1: create a new split container */
Con *new = con_new(NULL, NULL);
Expand Down
202 changes: 202 additions & 0 deletions testcases/t/167-workspace_layout.t
Expand Up @@ -375,7 +375,209 @@ ok(@content == 2, 'two containers opened');
isnt($content[0]->{layout}, 'tabbed', 'layout not tabbed');
isnt($content[1]->{layout}, 'tabbed', 'layout not tabbed');

exit_gracefully($pid);

#####################################################################
# 16: Check that the command 'layout toggle split' works regardless
# of what layout we're
#####################################################################

$config = <<EOT;
# i3 config file (v4)
font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
workspace_layout default
EOT

$pid = launch_with_config($config);

$tmp = fresh_workspace;

cmd 'layout splith';
$first = open_window;
$second = open_window;
cmd 'layout toggle split';
@content = @{get_ws_content($tmp)};
is($content[0]->{layout}, 'splitv', 'layout toggles to splitv');

cmd '[id="' . $first->id . '"] kill';
cmd '[id="' . $second->id . '"] kill';
sync_with_i3;

cmd 'layout splitv';
$first = open_window;
$second = open_window;
cmd 'layout toggle split';
@content = @{get_ws_content($tmp)};
is($content[0]->{layout}, 'splith', 'layout toggles to splith');

cmd '[id="' . $first->id . '"] kill';
cmd '[id="' . $second->id . '"] kill';
sync_with_i3;

cmd 'layout tabbed';
$first = open_window;
$second = open_window;
cmd 'layout toggle split';
@content = @{get_ws_content($tmp)};
is($content[0]->{layout}, 'splith', 'layout toggles to splith');

cmd '[id="' . $first->id . '"] kill';
cmd '[id="' . $second->id . '"] kill';
sync_with_i3;

cmd 'layout stacked';
$first = open_window;
$second = open_window;
cmd 'layout toggle split';
@content = @{get_ws_content($tmp)};
is($content[0]->{layout}, 'splith', 'layout toggles to splith');

exit_gracefully($pid);

#####################################################################
# 17: Check about setting a new layout
#####################################################################

$config = <<EOT;
# i3 config file (v4)
font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
workspace_layout default
EOT

$pid = launch_with_config($config);

$tmp = fresh_workspace;

cmd 'layout splith';
$first = open_window;
$second = open_window;
cmd 'layout splitv';
@content = @{get_ws_content($tmp)};
is($content[0]->{layout}, 'splitv', 'layout changes to splitv');

cmd '[id="' . $first->id . '"] kill';
cmd '[id="' . $second->id . '"] kill';
sync_with_i3;

cmd 'layout splith';
$first = open_window;
$second = open_window;
cmd 'layout tabbed';
@content = @{get_ws_content($tmp)};
is($content[0]->{layout}, 'tabbed', 'layout changed to tabbed');

cmd '[id="' . $first->id . '"] kill';
cmd '[id="' . $second->id . '"] kill';
sync_with_i3;

cmd 'layout splith';
$first = open_window;
$second = open_window;
cmd 'layout stacked';
@content = @{get_ws_content($tmp)};
is($content[0]->{layout}, 'stacked', 'layout changed to stacked');

cmd '[id="' . $first->id . '"] kill';
cmd '[id="' . $second->id . '"] kill';
sync_with_i3;

cmd 'layout splitv';
$first = open_window;
$second = open_window;
cmd 'layout splith';
@content = @{get_ws_content($tmp)};
is($content[0]->{layout}, 'splith', 'layout changes to splith');

cmd '[id="' . $first->id . '"] kill';
cmd '[id="' . $second->id . '"] kill';
sync_with_i3;

cmd 'layout splitv';
$first = open_window;
$second = open_window;
cmd 'layout tabbed';
@content = @{get_ws_content($tmp)};
is($content[0]->{layout}, 'tabbed', 'layout changed to tabbed');

cmd '[id="' . $first->id . '"] kill';
cmd '[id="' . $second->id . '"] kill';
sync_with_i3;

cmd 'layout splitv';
$first = open_window;
$second = open_window;
cmd 'layout stacked';
@content = @{get_ws_content($tmp)};
is($content[0]->{layout}, 'stacked', 'layout changed to stacked');

cmd '[id="' . $first->id . '"] kill';
cmd '[id="' . $second->id . '"] kill';
sync_with_i3;

cmd 'layout tabbed';
$first = open_window;
$second = open_window;
cmd 'layout splith';
@content = @{get_ws_content($tmp)};
is($content[0]->{layout}, 'splith', 'layout changes to splith');

cmd '[id="' . $first->id . '"] kill';
cmd '[id="' . $second->id . '"] kill';
sync_with_i3;

cmd 'layout tabbed';
$first = open_window;
$second = open_window;
cmd 'layout splitv';
@content = @{get_ws_content($tmp)};
is($content[0]->{layout}, 'splitv', 'layout changed to splitv');

cmd '[id="' . $first->id . '"] kill';
cmd '[id="' . $second->id . '"] kill';
sync_with_i3;

cmd 'layout tabbed';
$first = open_window;
$second = open_window;
cmd 'layout stacked';
@content = @{get_ws_content($tmp)};
is($content[0]->{layout}, 'stacked', 'layout changed to stacked');

cmd '[id="' . $first->id . '"] kill';
cmd '[id="' . $second->id . '"] kill';
sync_with_i3;

cmd 'layout stacked';
$first = open_window;
$second = open_window;
cmd 'layout splith';
@content = @{get_ws_content($tmp)};
is($content[0]->{layout}, 'splith', 'layout changes to splith');

cmd '[id="' . $first->id . '"] kill';
cmd '[id="' . $second->id . '"] kill';
sync_with_i3;

cmd 'layout stacked';
$first = open_window;
$second = open_window;
cmd 'layout splitv';
@content = @{get_ws_content($tmp)};
is($content[0]->{layout}, 'splitv', 'layout changed to splitv');

cmd '[id="' . $first->id . '"] kill';
cmd '[id="' . $second->id . '"] kill';
sync_with_i3;

cmd 'layout stacked';
$first = open_window;
$second = open_window;
cmd 'layout tabbed';
@content = @{get_ws_content($tmp)};
is($content[0]->{layout}, 'tabbed', 'layout changed to tabbed');

cmd '[id="' . $first->id . '"] kill';
cmd '[id="' . $second->id . '"] kill';
sync_with_i3;

done_testing;

0 comments on commit c7437c8

Please sign in to comment.