Support to get the primary output

This makes `primary` output available for assign or move commands.
Fix the issue #2764(https://github.com/i3/i3/issues/2764).
This commit is contained in:
hwangcc23 2017-05-14 16:05:29 +08:00
parent b56cb84e16
commit f99727b518
2 changed files with 28 additions and 7 deletions

View File

@ -1922,7 +1922,7 @@ output::
---------------------------------------------- ----------------------------------------------
focus left|right|down|up focus left|right|down|up
focus parent|child|floating|tiling|mode_toggle focus parent|child|floating|tiling|mode_toggle
focus output left|right|up|down|<output> focus output left|right|up|down|primary|<output>
---------------------------------------------- ----------------------------------------------
*Examples*: *Examples*:
@ -1944,8 +1944,17 @@ bindsym $mod+x focus output right
# Focus the big output # Focus the big output
bindsym $mod+x focus output HDMI-2 bindsym $mod+x focus output HDMI-2
# Focus the primary output
bindsym $mod+x focus output primary
------------------------------------------------- -------------------------------------------------
-------------------------------
Note that you might not have a primary output configured yet. To do so, run:
-------------------------
xrandr --output <output> --primary
-------------------------
=== Moving containers === Moving containers
Use the +move+ command to move a container. Use the +move+ command to move a container.
@ -2162,8 +2171,8 @@ To move a container to another RandR output (addressed by names like +LVDS1+ or
*Syntax*: *Syntax*:
------------------------------------------------------------ ------------------------------------------------------------
move container to output left|right|down|up|current|<output> move container to output left|right|down|up|current|primary|<output>
move workspace to output left|right|down|up|current|<output> move workspace to output left|right|down|up|current|primary|<output>
------------------------------------------------------------ ------------------------------------------------------------
*Examples*: *Examples*:
@ -2174,8 +2183,17 @@ bindsym $mod+x move workspace to output right
# Put this window on the presentation output. # Put this window on the presentation output.
bindsym $mod+x move container to output VGA1 bindsym $mod+x move container to output VGA1
# Put this window on the primary output.
bindsym $mod+x move container to output primary
-------------------------------------------------------- --------------------------------------------------------
-------------------------------
Note that you might not have a primary output configured yet. To do so, run:
-------------------------
xrandr --output <output> --primary
-------------------------
=== Moving containers/windows to marks === Moving containers/windows to marks
To move a container to another container with a specific mark (see <<vim_like_marks>>), To move a container to another container with a specific mark (see <<vim_like_marks>>),

View File

@ -45,10 +45,13 @@ static Output *get_output_by_id(xcb_randr_output_t id) {
*/ */
Output *get_output_by_name(const char *name) { Output *get_output_by_name(const char *name) {
Output *output; Output *output;
TAILQ_FOREACH(output, &outputs, outputs) bool get_primary = (strcasecmp("primary", name) == 0);
if (output->active && TAILQ_FOREACH(output, &outputs, outputs) {
strcasecmp(output->name, name) == 0) if ((output->primary && get_primary) ||
(output->active && strcasecmp(output->name, name) == 0)) {
return output; return output;
}
}
return NULL; return NULL;
} }