parent
a1e4b44955
commit
30131ed697
@ -965,7 +965,7 @@ considered.
|
||||
*Syntax*:
|
||||
------------------------------------------------------------
|
||||
assign <criteria> [→] [workspace] [number] <workspace>
|
||||
assign <criteria> [→] output left|right|up|down|primary|<output>
|
||||
assign <criteria> [→] output left|right|up|down|primary|nonprimary|<output>
|
||||
------------------------------------------------------------
|
||||
|
||||
*Examples*:
|
||||
@ -997,6 +997,9 @@ assign [class="^URxvt$"] → output right
|
||||
|
||||
# Assign urxvt to the primary output
|
||||
assign [class="^URxvt$"] → output primary
|
||||
|
||||
# Assign urxvt to the first non-primary output
|
||||
assign [class="^URxvt$"] → output nonprimary
|
||||
----------------------
|
||||
|
||||
Note that you might not have a primary output configured yet. To do so, run:
|
||||
@ -2423,7 +2426,7 @@ output::
|
||||
focus left|right|down|up
|
||||
focus parent|child|floating|tiling|mode_toggle
|
||||
focus next|prev [sibling]
|
||||
focus output left|right|down|up|current|primary|next|<output1> [output2]…
|
||||
focus output left|right|down|up|current|primary|nonprimary|next|<output1> [output2]…
|
||||
----------------------------------------------
|
||||
|
||||
*Examples*:
|
||||
@ -2455,6 +2458,9 @@ bindsym $mod+x focus output HDMI-2
|
||||
# Focus the primary output
|
||||
bindsym $mod+x focus output primary
|
||||
|
||||
# Cycle focus through non-primary outputs
|
||||
bindsym $mod+x focus output nonprimary
|
||||
|
||||
# Cycle focus between outputs VGA1 and LVDS1 but not DVI0
|
||||
bindsym $mod+x move workspace to output VGA1 LVDS1
|
||||
-------------------------------------------------
|
||||
@ -2719,8 +2725,8 @@ To move a container to another RandR output (addressed by names like +LVDS1+ or
|
||||
|
||||
*Syntax*:
|
||||
-------------------------------------------------------------------------------------
|
||||
move container to output left|right|down|up|current|primary|next|<output1> [output2]…
|
||||
move workspace to output left|right|down|up|current|primary|next|<output1> [output2]…
|
||||
move container to output left|right|down|up|current|primary|nonprimary|next|<output1> [output2]…
|
||||
move workspace to output left|right|down|up|current|primary|nonprimary|next|<output1> [output2]…
|
||||
-------------------------------------------------------------------------------------
|
||||
|
||||
*Examples*:
|
||||
|
1
release-notes/changes/3-nonprimary
Normal file
1
release-notes/changes/3-nonprimary
Normal file
@ -0,0 +1 @@
|
||||
Support nonprimary keyword for outputs
|
@ -1032,11 +1032,16 @@ typedef struct user_output_name {
|
||||
typedef TAILQ_HEAD(user_output_names_head, user_output_name) user_output_names_head;
|
||||
|
||||
static void user_output_names_add(user_output_names_head *list, const char *name) {
|
||||
if (strcmp(name, "next") == 0) {
|
||||
/* "next" here works like a wildcard: It "expands" to all available
|
||||
* outputs. */
|
||||
const bool get_non_primary = (strcasecmp("nonprimary", name) == 0);
|
||||
if (get_non_primary || strcmp(name, "next") == 0) {
|
||||
/* "next" (or "nonprimary") here work like a wildcard: It "expands" to
|
||||
* all available (or non-primary) outputs. */
|
||||
Output *output;
|
||||
TAILQ_FOREACH (output, &outputs, outputs) {
|
||||
if (get_non_primary && output->primary) {
|
||||
continue;
|
||||
}
|
||||
|
||||
user_output_name *co = scalloc(sizeof(user_output_name), 1);
|
||||
co->name = sstrdup(output_primary_name(output));
|
||||
TAILQ_INSERT_TAIL(list, co, user_output_names);
|
||||
|
@ -48,8 +48,10 @@ static Output *get_output_by_id(xcb_randr_output_t id) {
|
||||
*
|
||||
*/
|
||||
Output *get_output_by_name(const char *name, const bool require_active) {
|
||||
const bool get_primary = (strcasecmp("primary", name) == 0);
|
||||
const bool get_non_primary = (strcasecmp("nonprimary", name) == 0);
|
||||
|
||||
Output *output;
|
||||
bool get_primary = (strcasecmp("primary", name) == 0);
|
||||
TAILQ_FOREACH (output, &outputs, outputs) {
|
||||
if (require_active && !output->active) {
|
||||
continue;
|
||||
@ -57,6 +59,9 @@ Output *get_output_by_name(const char *name, const bool require_active) {
|
||||
if (output->primary && get_primary) {
|
||||
return output;
|
||||
}
|
||||
if (!output->primary && get_non_primary) {
|
||||
return output;
|
||||
}
|
||||
struct output_name *output_name;
|
||||
SLIST_FOREACH (output_name, &output->names_head, names) {
|
||||
if (strcasecmp(output_name->name, name) == 0) {
|
||||
|
@ -326,6 +326,42 @@ is_num_children('left-bottom', 2, 'two children on left-bottom');
|
||||
kill_all_windows;
|
||||
exit_gracefully($pid);
|
||||
|
||||
#####################################################################
|
||||
# Test assignments to primary / nonprimary outputs
|
||||
#####################################################################
|
||||
$config = <<'EOT';
|
||||
# i3 config file (v4)
|
||||
font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
|
||||
|
||||
fake-outputs 1024x768+0+0P,1024x768+1024+0
|
||||
|
||||
workspace primary output fake-0
|
||||
workspace nonprimary output fake-1
|
||||
|
||||
assign [class="current"] → output current
|
||||
assign [class="^primary$"] → output primary
|
||||
assign [class="nonprimary"] → output nonprimary
|
||||
EOT
|
||||
|
||||
$pid = launch_with_config($config);
|
||||
|
||||
cmd 'workspace primary';
|
||||
open_special(wm_class => 'current');
|
||||
sync_with_i3;
|
||||
is_num_children('primary', 1, 'one window in current workspace');
|
||||
|
||||
open_special(wm_class => 'nonprimary');
|
||||
sync_with_i3;
|
||||
is_num_children('nonprimary', 1, 'one child on nonprimary');
|
||||
|
||||
cmd 'workspace nonprimary';
|
||||
open_special(wm_class => 'primary');
|
||||
sync_with_i3;
|
||||
is_num_children('primary', 2, 'two children on primary');
|
||||
|
||||
kill_all_windows;
|
||||
exit_gracefully($pid);
|
||||
|
||||
#####################################################################
|
||||
# regression test: dock clients with floating assignments should not crash
|
||||
# (instead, nothing should happen - dock clients can’t float)
|
||||
|
@ -86,6 +86,8 @@ workspace 5 output fake-0
|
||||
workspace 5:xxx output fake-1
|
||||
workspace 6:xxx output fake-0
|
||||
workspace 6 output fake-1
|
||||
workspace 7 output nonprimary primary
|
||||
workspace 8 output doesnotexist primary
|
||||
EOT
|
||||
|
||||
$pid = launch_with_config($config);
|
||||
@ -98,7 +100,9 @@ do_test('5', 'fake-0', 'Numbered assignment ok');
|
||||
do_test('5:xxx', 'fake-1', 'Named assignment overrides number');
|
||||
do_test('6', 'fake-1', 'Numbered assignment ok');
|
||||
do_test('6:xxx', 'fake-0', 'Named assignment overrides number');
|
||||
do_test('7', 'fake-2', 'Numbered initialization for fake-2');
|
||||
do_test('7', 'fake-1', 'Non-primary output');
|
||||
do_test('8', 'fake-0', 'Primary output');
|
||||
do_test('9', 'fake-2', 'Numbered initialization for fake-2');
|
||||
|
||||
cmd 'focus output fake-0, workspace foo';
|
||||
check_output('foo', 'fake-0', 'Workspace with only non-existing assigned outputs opened in current output');
|
||||
|
@ -20,7 +20,7 @@ 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
|
||||
fake-outputs 1024x768+0+0P,1024x768+1024+0,1024x768+0+768,1024x768+1024+768
|
||||
EOT
|
||||
|
||||
###############################################################################
|
||||
@ -64,4 +64,19 @@ for (my $i = 0; $i < 10; $i++) {
|
||||
is(focused_output, "fake-$out", 'focus output next cycle');
|
||||
}
|
||||
|
||||
###############################################################################
|
||||
# Use nonprimary to cycle outputs
|
||||
###############################################################################
|
||||
|
||||
cmd 'focus output fake-0';
|
||||
is(focused_output, "fake-0", 'start from fake-0 which is the primary');
|
||||
|
||||
my @order = (1, 2, 3);
|
||||
for (my $i = 0; $i < 10; $i++) {
|
||||
cmd 'focus output nonprimary';
|
||||
|
||||
my $out = $order[$i % 3];
|
||||
is(focused_output, "fake-$out", 'focus output nonprimary cycle');
|
||||
}
|
||||
|
||||
done_testing;
|
||||
|
Loading…
Reference in New Issue
Block a user