cmd_focus_output: Multiple outputs
This commit is contained in:
parent
34ef7f8c33
commit
93b2b44893
@ -2212,7 +2212,7 @@ output::
|
||||
focus left|right|down|up
|
||||
focus parent|child|floating|tiling|mode_toggle
|
||||
focus next|prev [sibling]
|
||||
focus output left|right|up|down|primary|<output>
|
||||
focus output left|right|down|up|current|primary|next|<output1> [output2]…
|
||||
----------------------------------------------
|
||||
|
||||
*Examples*:
|
||||
@ -2232,6 +2232,9 @@ bindsym $mod+u focus parent
|
||||
# Focus last floating/tiling container
|
||||
bindsym $mod+g focus mode_toggle
|
||||
|
||||
# Focus the next output (effectively toggles when you only have two outputs)
|
||||
bindsym $mod+x move workspace to output next
|
||||
|
||||
# Focus the output right to the current one
|
||||
bindsym $mod+x focus output right
|
||||
|
||||
@ -2240,6 +2243,9 @@ bindsym $mod+x focus output HDMI-2
|
||||
|
||||
# Focus the primary output
|
||||
bindsym $mod+x focus output primary
|
||||
|
||||
# Cycle focus between outputs VGA1 and LVDS1 but not DVI0
|
||||
bindsym $mod+x move workspace to output VGA1 LVDS1
|
||||
-------------------------------------------------
|
||||
|
||||
Note that you might not have a primary output configured yet. To do so, run:
|
||||
|
@ -166,8 +166,10 @@ state FOCUS_AUTO:
|
||||
-> call cmd_focus_direction($direction)
|
||||
|
||||
state FOCUS_OUTPUT:
|
||||
output = string
|
||||
-> call cmd_focus_output($output)
|
||||
output = word
|
||||
-> call cmd_focus_output($output); FOCUS_OUTPUT
|
||||
end
|
||||
-> call cmd_focus_output(NULL); INITIAL
|
||||
|
||||
# kill [window|client]
|
||||
state KILL:
|
||||
|
1
release-notes/changes/3-focus-outputs
Normal file
1
release-notes/changes/3-focus-outputs
Normal file
@ -0,0 +1 @@
|
||||
Add support for multiple outputs in focus command
|
@ -1768,6 +1768,17 @@ void cmd_open(I3_CMD) {
|
||||
*
|
||||
*/
|
||||
void cmd_focus_output(I3_CMD, const char *name) {
|
||||
static user_output_names_head names = TAILQ_HEAD_INITIALIZER(names);
|
||||
if (name) {
|
||||
user_output_names_add(&names, name);
|
||||
return;
|
||||
}
|
||||
|
||||
if (TAILQ_EMPTY(&names)) {
|
||||
yerror("At least one output must be specified");
|
||||
return;
|
||||
}
|
||||
|
||||
HANDLE_EMPTY_MATCH;
|
||||
|
||||
if (TAILQ_EMPTY(&owindows)) {
|
||||
@ -1776,25 +1787,29 @@ void cmd_focus_output(I3_CMD, const char *name) {
|
||||
}
|
||||
|
||||
Output *current_output = get_output_for_con(TAILQ_FIRST(&owindows)->con);
|
||||
Output *output = get_output_from_string(current_output, name);
|
||||
Output *target_output = user_output_names_find_next(&names, current_output);
|
||||
user_output_names_free(&names);
|
||||
bool success = false;
|
||||
if (target_output) {
|
||||
success = true;
|
||||
|
||||
if (!output) {
|
||||
yerror("Output %s not found.", name);
|
||||
return;
|
||||
/* get visible workspace on output */
|
||||
Con *ws = NULL;
|
||||
GREP_FIRST(ws, output_get_content(target_output->con), workspace_is_visible(child));
|
||||
if (!ws) {
|
||||
yerror("BUG: No workspace found on output.");
|
||||
return;
|
||||
}
|
||||
|
||||
workspace_show(ws);
|
||||
}
|
||||
|
||||
/* get visible workspace on output */
|
||||
Con *ws = NULL;
|
||||
GREP_FIRST(ws, output_get_content(output->con), workspace_is_visible(child));
|
||||
if (!ws) {
|
||||
yerror("BUG: No workspace found on output.");
|
||||
return;
|
||||
cmd_output->needs_tree_render = success;
|
||||
if (success) {
|
||||
ysuccess(true);
|
||||
} else {
|
||||
yerror("No output matched");
|
||||
}
|
||||
|
||||
workspace_show(ws);
|
||||
|
||||
cmd_output->needs_tree_render = true;
|
||||
ysuccess(true);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -14,7 +14,7 @@
|
||||
# • http://onyxneon.com/books/modern_perl/modern_perl_a4.pdf
|
||||
# (unless you are already familiar with Perl)
|
||||
#
|
||||
# Test using multiple workspaces for 'move workspace to output …'
|
||||
# Test using multiple outputs for 'move workspace to output …'
|
||||
# Ticket: #4337
|
||||
use i3test i3_config => <<EOT;
|
||||
# i3 config file (v4)
|
||||
|
67
testcases/t/544-focus-multiple-outputs.t
Normal file
67
testcases/t/544-focus-multiple-outputs.t
Normal file
@ -0,0 +1,67 @@
|
||||
#!perl
|
||||
# vim:ts=4:sw=4:expandtab
|
||||
#
|
||||
# Please read the following documents before working on tests:
|
||||
# • https://build.i3wm.org/docs/testsuite.html
|
||||
# (or docs/testsuite)
|
||||
#
|
||||
# • https://build.i3wm.org/docs/lib-i3test.html
|
||||
# (alternatively: perldoc ./testcases/lib/i3test.pm)
|
||||
#
|
||||
# • https://build.i3wm.org/docs/ipc.html
|
||||
# (or docs/ipc)
|
||||
#
|
||||
# • http://onyxneon.com/books/modern_perl/modern_perl_a4.pdf
|
||||
# (unless you are already familiar with Perl)
|
||||
#
|
||||
# Test using multiple output for 'focus output …'
|
||||
# Ticket: #4619
|
||||
use i3test i3_config => <<EOT;
|
||||
# i3 config file (v4)
|
||||
font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
|
||||
|
||||
fake-outputs 1024x768+0+0,1024x768+1024+0,1024x768+0+768,1024x768+1024+768
|
||||
EOT
|
||||
|
||||
###############################################################################
|
||||
# Test using "next" special keyword
|
||||
###############################################################################
|
||||
|
||||
is(focused_output, "fake-0", 'sanity check');
|
||||
|
||||
for (my $i = 1; $i < 9; $i++) {
|
||||
cmd 'focus output next';
|
||||
|
||||
my $out = $i % 4;
|
||||
is(focused_output, "fake-$out", 'focus output next cycle');
|
||||
}
|
||||
|
||||
###############################################################################
|
||||
# Same as above but explicitely type all the outputs
|
||||
###############################################################################
|
||||
|
||||
is(focused_output, "fake-0", 'sanity check');
|
||||
|
||||
for (my $i = 1; $i < 10; $i++) {
|
||||
cmd 'focus output fake-0 fake-1 fake-2 fake-3';
|
||||
|
||||
my $out = $i % 4;
|
||||
is(focused_output, "fake-$out", 'focus output next cycle');
|
||||
}
|
||||
|
||||
###############################################################################
|
||||
# Use a subset of the outputs plus some non-existing outputs
|
||||
###############################################################################
|
||||
|
||||
cmd 'focus output fake-1';
|
||||
is(focused_output, "fake-1", 'start from fake-1 which is not included in output list');
|
||||
|
||||
my @order = (0, 3, 2);
|
||||
for (my $i = 0; $i < 10; $i++) {
|
||||
cmd 'focus output doesnotexist fake-0 alsodoesnotexist fake-3 fake-2';
|
||||
|
||||
my $out = $order[$i % 3];
|
||||
is(focused_output, "fake-$out", 'focus output next cycle');
|
||||
}
|
||||
|
||||
done_testing;
|
Loading…
Reference in New Issue
Block a user