[PATCH xrandr v2 1/2] xrandr: allow a single value for --scale

Aaron Plattner aplattner at nvidia.com
Fri Jul 14 00:46:43 UTC 2017


On 06/22/2017 03:39 PM, Giuseppe Bilotta wrote:
> This allows using e.g. --scale 0.5 as a shorthand for --scale 0.5x0.5
> 
> Signed-off-by: Giuseppe Bilotta <giuseppe.bilotta at gmail.com>
> ---
>   man/xrandr.man | 7 ++++---
>   xrandr.c       | 8 ++++++--
>   2 files changed, 10 insertions(+), 5 deletions(-)
> 
> diff --git a/man/xrandr.man b/man/xrandr.man
> index 65ccc2a..e59abbe 100644
> --- a/man/xrandr.man
> +++ b/man/xrandr.man
> @@ -34,7 +34,7 @@ xrandr \- primitive command line interface to RandR extension
>   [\-\-current]
>   [\-\-noprimary]
>   [\-\-panning \fIwidth\fPx\fIheight\fP[+\fIx\fP+\fIy\fP[/\fItrack_width\fPx\fItrack_height\fP+\fItrack_x\fP+\fItrack_y\fP[/\fIborder_left\fP/\fIborder_top\fP/\fIborder_right\fP/\fIborder_bottom\fP]]]]
> -[\-\-scale \fIx\fPx\fIy\fP]
> +[\-\-scale \fIx\fP[x\fIy\fP]]
>   [\-\-scale-from \fIw\fPx\fIh\fP]
>   [\-\-transform \fIa\fP,\fIb\fP,\fIc\fP,\fId\fP,\fIe\fP,\fIf\fP,\fIg\fP,\fIh\fP,\fIi\fP]
>   [\-\-primary]
> @@ -207,8 +207,9 @@ values are used (a unit matrix without filter).
>   Chooses the scaling filter method to be applied when the screen is scaled or
>   transformed.
>   Can be either 'bilinear' or 'nearest'.
> -.IP "\-\-scale \fIx\fPx\fIy\fP"
> -Changes the dimensions of the output picture. Values superior to 1 will lead to
> +.IP "\-\-scale \fIx\fP[x\fIy\fP]"
> +Changes the dimensions of the output picture. If the \fIy\fP value is omitted,
> +the \fIx\fP value will be used for both dimensions. Values superior to 1 will lead to

I think "greater than" or "larger than" are more common than "superior 
to" for numerical comparisons, and new sentences in roff format are 
supposed to start on their own lines. I can send a separate change to 
fix those if you don't feel like fixing them as part of this change.

>   a compressed screen (screen dimension bigger than the dimension of the output
>   mode), and values below 1 leads to a zoom in on the output. This option is
>   actually a shortcut version of the \fI\-\-transform\fP option.
> diff --git a/xrandr.c b/xrandr.c
> index 2d4cb72..4433724 100644
> --- a/xrandr.c
> +++ b/xrandr.c
> @@ -137,7 +137,7 @@ usage(void)
>              "      --below <output>\n"
>              "      --same-as <output>\n"
>              "      --set <property> <value>\n"
> -           "      --scale <x>x<y>\n"
> +           "      --scale <x>[x<y>]\n"
>              "      --scale-from <w>x<h>\n"
>              "      --transform <a>,<b>,<c>,<d>,<e>,<f>,<g>,<h>,<i>\n"
>              "      --filter nearest,bilinear\n"
> @@ -3017,7 +3017,11 @@ main (int argc, char **argv)
>   	    if (!config_output) argerr ("%s must be used after --output\n", argv[i]);
>   	    if (++i >= argc) argerr ("%s requires an argument\n", argv[i-1]);
>   	    if (sscanf (argv[i], "%lfx%lf", &sx, &sy) != 2)
> -		argerr ("failed to parse '%s' as a scaling factor\n", argv[i]);
> +	    {
> +		    if (sscanf (argv[i], "%lf", &sx) != 1)

This looks like it's indented too far. Should be two tabs and no spaces, 
and the next line should be two tabs and four spaces. Yes, this is 
terrible and I hate it. ;)

Otherwise, this seems fine to me.

> +			    argerr ("failed to parse '%s' as a scaling factor\n", argv[i]);
> +		    sy = sx;
> +	    }
>   	    init_transform (&config_output->transform);
>   	    config_output->transform.transform.matrix[0][0] = XDoubleToFixed (sx);
>   	    config_output->transform.transform.matrix[1][1] = XDoubleToFixed (sy);
> 


More information about the xorg-devel mailing list