Don’t force wrapping when focusing in a direction would work (+test)

Think of the following layout:

 -------------
 | tab |     |
 | con | win |
 |     |     |
 -------------

The tabbed container on the left has two children. Assume you have focused the
second/right child in the tabbed container. i3 used to focus the first/left
container of the tabbed container when using 'focus right' (it wrapped focus).

With this commit, the default behaviour is to instead focus the window on the
right of the screen.

The intention is to make focus switching more intuitive, especially with tabbed
containers supporting 'focus left'/'focus right' in tree. You should end up
using less 'focus parent' :).

You can force the old behaviour with 'force_focus_wrapping true' in your
config.

Code coverage is 62.5% with this commit.
This commit is contained in:
Michael Stapelberg
2011-06-11 19:15:16 +02:00
parent 931a5c749a
commit d641e1da3b
5 changed files with 180 additions and 27 deletions

View File

@ -235,6 +235,7 @@ void parse_file(const char *f) {
%token TOK_NONE "none"
%token TOK_1PIXEL "1pixel"
%token TOKFOCUSFOLLOWSMOUSE "focus_follows_mouse"
%token TOK_FORCE_FOCUS_WRAPPING "force_focus_wrapping"
%token TOKWORKSPACEBAR "workspace_bar"
%token TOK_DEFAULT "default"
%token TOK_STACKING "stacking"
@ -285,6 +286,7 @@ line:
| workspace_layout
| new_window
| focus_follows_mouse
| force_focus_wrapping
| workspace_bar
| workspace
| assign
@ -592,6 +594,14 @@ focus_follows_mouse:
}
;
force_focus_wrapping:
TOK_FORCE_FOCUS_WRAPPING bool
{
DLOG("force focus wrapping = %d\n", $2);
config.force_focus_wrapping = $2;
}
;
workspace_bar:
TOKWORKSPACEBAR bool
{