CONFIG BREAK: kick the 'next'/'prev' commands, introduce 'focus left' etc.
Instead of the cryptic next/prev commands, we now provide an argument to the focus command. Userguide and default config is updated.
This commit is contained in:
parent
30501e7c8a
commit
d68e4710fe
@ -629,23 +629,22 @@ bindsym Mod1+t mode toggle
|
||||
|
||||
=== Focusing/Moving containers
|
||||
|
||||
To change the focus, use one of the +prev h+, +next v+, +prev v+ and +next h+
|
||||
commands, meaning left, down, up, right (respectively).
|
||||
To change the focus, use the focus command: +focus left+, +focus right+, +focus down+ and +focus up+.
|
||||
|
||||
For moving, use +move left+, +move right+, +move down+ and +move up+.
|
||||
|
||||
*Examples*:
|
||||
----------------------
|
||||
# Focus clients on the left, bottom, top, right:
|
||||
bindsym Mod1+j prev h
|
||||
bindsym Mod1+k next v
|
||||
bindsym Mod1+j prev v
|
||||
bindsym Mod1+semicolon next h
|
||||
bindsym Mod1+j focus left
|
||||
bindsym Mod1+k focus down
|
||||
bindsym Mod1+l focus up
|
||||
bindsym Mod1+semicolon focus right
|
||||
|
||||
# Move client to the left, bottom, top, right:
|
||||
bindsym Mod1+j move left
|
||||
bindsym Mod1+k move down
|
||||
bindsym Mod1+j move up
|
||||
bindsym Mod1+l move up
|
||||
bindsym Mod1+semicolon move right
|
||||
----------------------
|
||||
|
||||
|
16
i3.config
16
i3.config
@ -57,16 +57,16 @@ bindsym Mod1+Shift+j reload
|
||||
bindsym Mod1+Shift+l exit
|
||||
|
||||
# Focus (Mod1+n/r/t/d)
|
||||
bindsym Mod1+n prev h
|
||||
bindsym Mod1+r next v
|
||||
bindsym Mod1+t prev v
|
||||
bindsym Mod1+d next h
|
||||
bindsym Mod1+n focus left
|
||||
bindsym Mod1+r focus down
|
||||
bindsym Mod1+t focus up
|
||||
bindsym Mod1+d focus right
|
||||
|
||||
# alternatively, you can use the cursor keys:
|
||||
bindsym Mod1+Left prev h
|
||||
bindsym Mod1+Right next h
|
||||
bindsym Mod1+Down next v
|
||||
bindsym Mod1+Up prev v
|
||||
bindsym Mod1+Left focus left
|
||||
bindsym Mod1+Down focus down
|
||||
bindsym Mod1+Up focus up
|
||||
bindsym Mod1+Right focus right
|
||||
|
||||
# Move
|
||||
bindsym Mod1+Shift+n move left
|
||||
|
@ -120,7 +120,6 @@ workspace { WS_STRING; return TOK_WORKSPACE; }
|
||||
focus { return TOK_FOCUS; }
|
||||
move { return TOK_MOVE; }
|
||||
open { return TOK_OPEN; }
|
||||
next { return TOK_NEXT; }
|
||||
prev { return TOK_PREV; }
|
||||
split { return TOK_SPLIT; }
|
||||
horizontal { return TOK_HORIZONTAL; }
|
||||
|
@ -140,7 +140,6 @@ char *parse_cmd(const char *new) {
|
||||
%token TOK_FOCUS "focus"
|
||||
%token TOK_MOVE "move"
|
||||
%token TOK_OPEN "open"
|
||||
%token TOK_NEXT "next"
|
||||
%token TOK_PREV "prev"
|
||||
%token TOK_SPLIT "split"
|
||||
%token TOK_HORIZONTAL "horizontal"
|
||||
@ -333,8 +332,6 @@ operation:
|
||||
| kill
|
||||
| open
|
||||
| fullscreen
|
||||
| next
|
||||
| prev
|
||||
| split
|
||||
| mode
|
||||
| level
|
||||
@ -400,6 +397,33 @@ focus:
|
||||
|
||||
tree_render();
|
||||
}
|
||||
| TOK_FOCUS direction
|
||||
{
|
||||
int direction = $2;
|
||||
switch (direction) {
|
||||
case TOK_LEFT:
|
||||
LOG("Focusing left\n");
|
||||
tree_next('p', HORIZ);
|
||||
break;
|
||||
case TOK_RIGHT:
|
||||
LOG("Focusing right\n");
|
||||
tree_next('n', HORIZ);
|
||||
break;
|
||||
case TOK_UP:
|
||||
LOG("Focusing up\n");
|
||||
tree_next('p', VERT);
|
||||
break;
|
||||
case TOK_DOWN:
|
||||
LOG("Focusing down\n");
|
||||
tree_next('n', VERT);
|
||||
break;
|
||||
default:
|
||||
ELOG("Invalid focus direction (%d)\n", direction);
|
||||
break;
|
||||
}
|
||||
|
||||
tree_render();
|
||||
}
|
||||
;
|
||||
|
||||
kill:
|
||||
@ -469,28 +493,6 @@ fullscreen:
|
||||
}
|
||||
;
|
||||
|
||||
next:
|
||||
TOK_NEXT direction
|
||||
{
|
||||
/* TODO: use matches */
|
||||
printf("should select next window in direction %c\n", $2);
|
||||
tree_next('n', ($2 == 'v' ? VERT : HORIZ));
|
||||
|
||||
tree_render();
|
||||
}
|
||||
;
|
||||
|
||||
prev:
|
||||
TOK_PREV direction
|
||||
{
|
||||
/* TODO: use matches */
|
||||
printf("should select prev window in direction %c\n", $2);
|
||||
tree_next('p', ($2 == 'v' ? VERT : HORIZ));
|
||||
|
||||
tree_render();
|
||||
}
|
||||
;
|
||||
|
||||
split:
|
||||
TOK_SPLIT direction
|
||||
{
|
||||
|
@ -44,20 +44,20 @@ sub focus_after {
|
||||
$focus = $x->input_focus;
|
||||
is($focus, $bottom->id, "Latest window focused");
|
||||
|
||||
$focus = focus_after("prev v");
|
||||
$focus = focus_after('focus up');
|
||||
is($focus, $mid->id, "Middle window focused");
|
||||
|
||||
$focus = focus_after("prev v");
|
||||
$focus = focus_after('focus up');
|
||||
is($focus, $top->id, "Top window focused");
|
||||
|
||||
#####################################################################
|
||||
# Test focus wrapping
|
||||
#####################################################################
|
||||
|
||||
$focus = focus_after("prev v");
|
||||
$focus = focus_after('focus up');
|
||||
is($focus, $bottom->id, "Bottom window focused (wrapping to the top works)");
|
||||
|
||||
$focus = focus_after("next v");
|
||||
$focus = focus_after('focus down');
|
||||
is($focus, $top->id, "Top window focused (wrapping to the bottom works)");
|
||||
|
||||
###############################################
|
||||
|
@ -45,7 +45,7 @@ sub focus_after {
|
||||
$focus = $x->input_focus;
|
||||
is($focus, $bottom->id, "Latest window focused");
|
||||
|
||||
$focus = focus_after("prev h");
|
||||
$focus = focus_after('focus left');
|
||||
is($focus, $mid->id, "Middle window focused");
|
||||
|
||||
#####################################################################
|
||||
@ -59,7 +59,7 @@ is($focus, $mid->id, "focus unchanged");
|
||||
|
||||
$i3->command("mark $random_mark")->recv;
|
||||
|
||||
$focus = focus_after("prev h");
|
||||
$focus = focus_after('focus left');
|
||||
is($focus, $top->id, "Top window focused");
|
||||
|
||||
$focus = focus_after(qq|[con_mark="$random_mark"] focus|);
|
||||
|
@ -8,23 +8,23 @@ use i3test;
|
||||
my $tmp = fresh_workspace;
|
||||
|
||||
######################################################################
|
||||
# Open one container, verify that 'next v' and 'next h' do nothing
|
||||
# Open one container, verify that 'focus down' and 'focus right' do nothing
|
||||
######################################################################
|
||||
cmd 'open';
|
||||
|
||||
my ($nodes, $focus) = get_ws_content($tmp);
|
||||
my $old_focused = $focus->[0];
|
||||
|
||||
cmd 'next v';
|
||||
cmd 'focus down';
|
||||
($nodes, $focus) = get_ws_content($tmp);
|
||||
is($focus->[0], $old_focused, 'focus did not change with only one con');
|
||||
|
||||
cmd 'next h';
|
||||
cmd 'focus right';
|
||||
($nodes, $focus) = get_ws_content($tmp);
|
||||
is($focus->[0], $old_focused, 'focus did not change with only one con');
|
||||
|
||||
######################################################################
|
||||
# Open another container, verify that 'next h' switches
|
||||
# Open another container, verify that 'focus right' switches
|
||||
######################################################################
|
||||
my $left = $old_focused;
|
||||
|
||||
@ -38,44 +38,32 @@ cmd 'open';
|
||||
isnt($old_focused, $focus->[0], 'new container is focused');
|
||||
my $right = $focus->[0];
|
||||
|
||||
cmd 'next h';
|
||||
cmd 'focus right';
|
||||
($nodes, $focus) = get_ws_content($tmp);
|
||||
isnt($focus->[0], $right, 'focus did change');
|
||||
is($focus->[0], $left, 'left container focused (wrapping)');
|
||||
|
||||
cmd 'next h';
|
||||
cmd 'focus right';
|
||||
($nodes, $focus) = get_ws_content($tmp);
|
||||
is($focus->[0], $mid, 'middle container focused');
|
||||
|
||||
cmd 'next h';
|
||||
cmd 'focus right';
|
||||
($nodes, $focus) = get_ws_content($tmp);
|
||||
is($focus->[0], $right, 'right container focused');
|
||||
|
||||
cmd 'prev h';
|
||||
cmd 'focus left';
|
||||
($nodes, $focus) = get_ws_content($tmp);
|
||||
is($focus->[0], $mid, 'middle container focused');
|
||||
|
||||
cmd 'prev h';
|
||||
cmd 'focus left';
|
||||
($nodes, $focus) = get_ws_content($tmp);
|
||||
is($focus->[0], $left, 'left container focused');
|
||||
|
||||
cmd 'prev h';
|
||||
cmd 'focus left';
|
||||
($nodes, $focus) = get_ws_content($tmp);
|
||||
is($focus->[0], $right, 'right container focused');
|
||||
|
||||
|
||||
######################################################################
|
||||
# Test synonyms (horizontal/vertical instead of h/v)
|
||||
######################################################################
|
||||
|
||||
cmd 'prev horizontal';
|
||||
($nodes, $focus) = get_ws_content($tmp);
|
||||
is($focus->[0], $mid, 'middle container focused');
|
||||
|
||||
cmd 'next horizontal';
|
||||
($nodes, $focus) = get_ws_content($tmp);
|
||||
is($focus->[0], $right, 'right container focused');
|
||||
|
||||
######################################################################
|
||||
# Test focus command
|
||||
######################################################################
|
||||
|
@ -121,11 +121,11 @@ cmd "open";
|
||||
cmd "open";
|
||||
cmd "split v";
|
||||
cmd "open";
|
||||
cmd "prev h";
|
||||
cmd 'focus left';
|
||||
cmd "split v";
|
||||
cmd "open";
|
||||
cmd "move right";
|
||||
cmd "prev h";
|
||||
cmd 'focus left';
|
||||
cmd "move right";
|
||||
|
||||
$content = get_ws_content($otmp);
|
||||
|
@ -64,11 +64,11 @@ cmd 'split v';
|
||||
$first = open_empty_con($i3);
|
||||
my $bottom = open_empty_con($i3);
|
||||
|
||||
cmd 'prev v';
|
||||
cmd 'focus up';
|
||||
cmd 'split h';
|
||||
my $middle = open_empty_con($i3);
|
||||
my $right = open_empty_con($i3);
|
||||
cmd 'next v';
|
||||
cmd 'focus down';
|
||||
|
||||
# We have the following layout now (second is focused):
|
||||
# .----------------------------.
|
||||
|
@ -28,10 +28,10 @@ isnt($first, $second, 'two different containers opened');
|
||||
cmd 'layout stacking';
|
||||
is(get_focused($tmp), $second, 'second container still focused');
|
||||
|
||||
cmd 'next v';
|
||||
cmd 'focus down';
|
||||
is(get_focused($tmp), $first, 'first container focused');
|
||||
|
||||
cmd 'prev v';
|
||||
cmd 'focus up';
|
||||
is(get_focused($tmp), $second, 'second container focused again');
|
||||
|
||||
##############################################################
|
||||
@ -42,10 +42,10 @@ cmd 'level up';
|
||||
cmd 'split h';
|
||||
cmd 'level down';
|
||||
|
||||
cmd 'next v';
|
||||
cmd 'focus down';
|
||||
is(get_focused($tmp), $first, 'first container focused');
|
||||
|
||||
cmd 'prev v';
|
||||
cmd 'focus up';
|
||||
is(get_focused($tmp), $second, 'second container focused again');
|
||||
|
||||
|
||||
|
@ -36,7 +36,7 @@ diag("left = " . $left->id . ", mid = " . $mid->id . ", right = " . $right->id);
|
||||
|
||||
is($x->input_focus, $right->id, 'Right window focused');
|
||||
|
||||
cmd 'prev h';
|
||||
cmd 'focus left';
|
||||
|
||||
is($x->input_focus, $mid->id, 'Mid window focused');
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user