=== 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
----------------------
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
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; }
%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"
| kill
| open
| fullscreen
- | next
- | prev
| split
| mode
| level
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:
}
;
-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
{
$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)");
###############################################
$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");
#####################################################################
$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|);
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;
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
######################################################################
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);
$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):
# .----------------------------.
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');
##############################################################
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');
is($x->input_focus, $right->id, 'Right window focused');
-cmd 'prev h';
+cmd 'focus left';
is($x->input_focus, $mid->id, 'Mid window focused');