Implement 'focus floating', 'focus tiling' and 'focus mode_toggle' (+test +docs)
This commit is contained in:
parent
71741d7620
commit
c408fef021
|
@ -627,6 +627,20 @@ bindsym Mod1+t floating toggle
|
||||||
|
|
||||||
To change the focus, use the focus command: +focus left+, +focus right+, +focus down+ and +focus up+.
|
To change the focus, use the focus command: +focus left+, +focus right+, +focus down+ and +focus up+.
|
||||||
|
|
||||||
|
There are a few special parameters you can use for the focus command:
|
||||||
|
|
||||||
|
parent::
|
||||||
|
Sets focus to the +Parent Container+ of the current +Container+.
|
||||||
|
child::
|
||||||
|
The opposite of +focus parent+, sets the focus to the last focused
|
||||||
|
child container.
|
||||||
|
floating::
|
||||||
|
Sets focus to the last focused floating container.
|
||||||
|
tiling::
|
||||||
|
Sets focus to the last focused tiling container.
|
||||||
|
mode_toggle::
|
||||||
|
Toggles between floating/tiling containers.
|
||||||
|
|
||||||
For moving, use +move left+, +move right+, +move down+ and +move up+.
|
For moving, use +move left+, +move right+, +move down+ and +move up+.
|
||||||
|
|
||||||
*Examples*:
|
*Examples*:
|
||||||
|
@ -637,6 +651,12 @@ bindsym Mod1+k focus down
|
||||||
bindsym Mod1+l focus up
|
bindsym Mod1+l focus up
|
||||||
bindsym Mod1+semicolon focus right
|
bindsym Mod1+semicolon focus right
|
||||||
|
|
||||||
|
# Focus parent container
|
||||||
|
bindsym Mod1+u focus parent
|
||||||
|
|
||||||
|
# Focus last floating/tiling container
|
||||||
|
bindsym Mod1+g focus mode_toggle
|
||||||
|
|
||||||
# Move client to the left, bottom, top, right:
|
# Move client to the left, bottom, top, right:
|
||||||
bindsym Mod1+j move left
|
bindsym Mod1+j move left
|
||||||
bindsym Mod1+k move down
|
bindsym Mod1+k move down
|
||||||
|
@ -758,32 +778,6 @@ Alternatively, if you do not want to mess with +i3-input+, you could create
|
||||||
seperate bindings for a specific set of labels and then only use those labels.
|
seperate bindings for a specific set of labels and then only use those labels.
|
||||||
///////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
|
||||||
TODO: not yet implemented
|
|
||||||
=== Traveling the focus stack
|
|
||||||
|
|
||||||
This mechanism can be thought of as the opposite of the +jump+ command.
|
|
||||||
It travels the focus stack and jumps to the window which had focus previously.
|
|
||||||
|
|
||||||
*Syntax*:
|
|
||||||
--------------
|
|
||||||
focus [number] | floating | tiling | ft
|
|
||||||
--------------
|
|
||||||
|
|
||||||
Where +number+ by default is 1 meaning that the next client in the focus stack
|
|
||||||
will be selected.
|
|
||||||
|
|
||||||
The special values have the following meaning:
|
|
||||||
|
|
||||||
floating::
|
|
||||||
The next floating window is selected.
|
|
||||||
tiling::
|
|
||||||
The next tiling window is selected.
|
|
||||||
ft::
|
|
||||||
If the current window is floating, the next tiling window will be
|
|
||||||
selected; and vice-versa.
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
=== Changing border style
|
=== Changing border style
|
||||||
|
|
||||||
To change the border of the current client, you can use +border normal+ to use the normal
|
To change the border of the current client, you can use +border normal+ to use the normal
|
||||||
|
|
|
@ -121,6 +121,7 @@ mode { BEGIN(WANT_QSTRING); return TOK_MODE; }
|
||||||
tiling { return TOK_TILING; }
|
tiling { return TOK_TILING; }
|
||||||
floating { return TOK_FLOATING; }
|
floating { return TOK_FLOATING; }
|
||||||
toggle { return TOK_TOGGLE; }
|
toggle { return TOK_TOGGLE; }
|
||||||
|
mode_toggle { return TOK_MODE_TOGGLE; }
|
||||||
workspace { WS_STRING; return TOK_WORKSPACE; }
|
workspace { WS_STRING; return TOK_WORKSPACE; }
|
||||||
focus { return TOK_FOCUS; }
|
focus { return TOK_FOCUS; }
|
||||||
move { return TOK_MOVE; }
|
move { return TOK_MOVE; }
|
||||||
|
|
|
@ -135,6 +135,7 @@ char *parse_cmd(const char *new) {
|
||||||
%token TOK_MODE "mode"
|
%token TOK_MODE "mode"
|
||||||
%token TOK_TILING "tiling"
|
%token TOK_TILING "tiling"
|
||||||
%token TOK_FLOATING "floating"
|
%token TOK_FLOATING "floating"
|
||||||
|
%token TOK_MODE_TOGGLE "mode_toggle"
|
||||||
%token TOK_ENABLE "enable"
|
%token TOK_ENABLE "enable"
|
||||||
%token TOK_DISABLE "disable"
|
%token TOK_DISABLE "disable"
|
||||||
%token TOK_WORKSPACE "workspace"
|
%token TOK_WORKSPACE "workspace"
|
||||||
|
@ -175,6 +176,7 @@ char *parse_cmd(const char *new) {
|
||||||
%type <number> split_direction
|
%type <number> split_direction
|
||||||
%type <number> fullscreen_mode
|
%type <number> fullscreen_mode
|
||||||
%type <number> level
|
%type <number> level
|
||||||
|
%type <number> window_mode
|
||||||
%type <number> boolean
|
%type <number> boolean
|
||||||
%type <number> border_style
|
%type <number> border_style
|
||||||
%type <number> layout_mode
|
%type <number> layout_mode
|
||||||
|
@ -447,6 +449,38 @@ focus:
|
||||||
|
|
||||||
tree_render();
|
tree_render();
|
||||||
}
|
}
|
||||||
|
| TOK_FOCUS window_mode
|
||||||
|
{
|
||||||
|
printf("should focus: ");
|
||||||
|
|
||||||
|
if ($2 == TOK_TILING)
|
||||||
|
printf("tiling\n");
|
||||||
|
else if ($2 == TOK_FLOATING)
|
||||||
|
printf("floating\n");
|
||||||
|
else printf("mode toggle\n");
|
||||||
|
|
||||||
|
Con *ws = con_get_workspace(focused);
|
||||||
|
Con *current;
|
||||||
|
if (ws != NULL) {
|
||||||
|
int to_focus = $2;
|
||||||
|
if ($2 == TOK_MODE_TOGGLE) {
|
||||||
|
current = TAILQ_FIRST(&(ws->focus_head));
|
||||||
|
if (current->type == CT_FLOATING_CON)
|
||||||
|
to_focus = TOK_TILING;
|
||||||
|
else to_focus = TOK_FLOATING;
|
||||||
|
}
|
||||||
|
TAILQ_FOREACH(current, &(ws->focus_head), focused) {
|
||||||
|
if ((to_focus == TOK_FLOATING && current->type != CT_FLOATING_CON) ||
|
||||||
|
(to_focus == TOK_TILING && current->type == CT_FLOATING_CON))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
con_focus(con_descend_focused(current));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
tree_render();
|
||||||
|
}
|
||||||
| TOK_FOCUS level
|
| TOK_FOCUS level
|
||||||
{
|
{
|
||||||
if ($2 == TOK_PARENT)
|
if ($2 == TOK_PARENT)
|
||||||
|
@ -457,6 +491,12 @@ focus:
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
|
window_mode:
|
||||||
|
TOK_TILING { $$ = TOK_TILING; }
|
||||||
|
| TOK_FLOATING { $$ = TOK_FLOATING; }
|
||||||
|
| TOK_MODE_TOGGLE { $$ = TOK_MODE_TOGGLE; }
|
||||||
|
;
|
||||||
|
|
||||||
level:
|
level:
|
||||||
TOK_PARENT { $$ = TOK_PARENT; }
|
TOK_PARENT { $$ = TOK_PARENT; }
|
||||||
| TOK_CHILD { $$ = TOK_CHILD; }
|
| TOK_CHILD { $$ = TOK_CHILD; }
|
||||||
|
|
|
@ -125,4 +125,50 @@ sleep 0.25;
|
||||||
|
|
||||||
is($x->input_focus, $first->id, 'first con focused after killing all floating cons');
|
is($x->input_focus, $first->id, 'first con focused after killing all floating cons');
|
||||||
|
|
||||||
|
#############################################################################
|
||||||
|
# 5: see if the 'focus tiling' and 'focus floating' commands work
|
||||||
|
#############################################################################
|
||||||
|
|
||||||
|
$tmp = fresh_workspace;
|
||||||
|
|
||||||
|
$first = open_standard_window($x, '#ff0000'); # window 8
|
||||||
|
$second = open_standard_window($x, '#00ff00'); # window 9
|
||||||
|
|
||||||
|
is($x->input_focus, $second->id, 'second container focused');
|
||||||
|
|
||||||
|
cmd 'floating enable';
|
||||||
|
|
||||||
|
is($x->input_focus, $second->id, 'second container focused');
|
||||||
|
|
||||||
|
cmd 'focus tiling';
|
||||||
|
|
||||||
|
sleep 0.25;
|
||||||
|
|
||||||
|
is($x->input_focus, $first->id, 'first (tiling) container focused');
|
||||||
|
|
||||||
|
cmd 'focus floating';
|
||||||
|
|
||||||
|
sleep 0.25;
|
||||||
|
|
||||||
|
is($x->input_focus, $second->id, 'second (floating) container focused');
|
||||||
|
|
||||||
|
cmd 'focus floating';
|
||||||
|
|
||||||
|
sleep 0.25;
|
||||||
|
|
||||||
|
is($x->input_focus, $second->id, 'second (floating) container still focused');
|
||||||
|
|
||||||
|
cmd 'focus mode_toggle';
|
||||||
|
|
||||||
|
sleep 0.25;
|
||||||
|
|
||||||
|
is($x->input_focus, $first->id, 'first (tiling) container focused');
|
||||||
|
|
||||||
|
cmd 'focus mode_toggle';
|
||||||
|
|
||||||
|
sleep 0.25;
|
||||||
|
|
||||||
|
is($x->input_focus, $second->id, 'second (floating) container focused');
|
||||||
|
|
||||||
|
|
||||||
done_testing;
|
done_testing;
|
||||||
|
|
Loading…
Reference in New Issue