From: hwangcc23 Date: Sun, 14 May 2017 08:05:29 +0000 (+0800) Subject: Support to get the primary output X-Git-Tag: 4.14~34^2 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=refs%2Fpull%2F2771%2Fhead;p=i3%2Fi3 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). --- diff --git a/docs/userguide b/docs/userguide index 068ecd87..985ce09b 100644 --- a/docs/userguide +++ b/docs/userguide @@ -1922,7 +1922,7 @@ output:: ---------------------------------------------- focus left|right|down|up focus parent|child|floating|tiling|mode_toggle -focus output left|right|up|down| +focus output left|right|up|down|primary| ---------------------------------------------- *Examples*: @@ -1944,8 +1944,17 @@ bindsym $mod+x focus output right # Focus the big output 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 --primary +------------------------- + === Moving containers 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*: ------------------------------------------------------------ -move container to output left|right|down|up|current| -move workspace to output left|right|down|up|current| +move container to output left|right|down|up|current|primary| +move workspace to output left|right|down|up|current|primary| ------------------------------------------------------------ *Examples*: @@ -2174,8 +2183,17 @@ bindsym $mod+x move workspace to output right # Put this window on the presentation output. 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 --primary +------------------------- + === Moving containers/windows to marks To move a container to another container with a specific mark (see <>), diff --git a/src/randr.c b/src/randr.c index 16ef62b8..8496fd03 100644 --- a/src/randr.c +++ b/src/randr.c @@ -45,10 +45,13 @@ static Output *get_output_by_id(xcb_randr_output_t id) { */ Output *get_output_by_name(const char *name) { Output *output; - TAILQ_FOREACH(output, &outputs, outputs) - if (output->active && - strcasecmp(output->name, name) == 0) - return output; + bool get_primary = (strcasecmp("primary", name) == 0); + TAILQ_FOREACH(output, &outputs, outputs) { + if ((output->primary && get_primary) || + (output->active && strcasecmp(output->name, name) == 0)) { + return output; + } + } return NULL; }