summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2017-05-17 17:20:50 +0200
committerGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2018-02-27 12:18:07 +0100
commit4e655b2cfc79b02d0ca7cea82b09f1f1133f1a0a (patch)
treeb47c94eb6f85919312cbd84a78b9ad99f05a01fc
parent8969b3c651eaae3e3a2370ec45f4eeae9750111d (diff)
xrandr: allow a single value for --scale
This allows using e.g. --scale 0.5 as a shorthand for --scale 0.5x0.5 Signed-off-by: Giuseppe Bilotta <giuseppe.bilotta@gmail.com> Reviewed-by: Alex Deucher <alexander.deucher@amd.com> Reviewed-by: Keith Packard <keithp@keithp.com>
-rw-r--r--man/xrandr.man7
-rw-r--r--xrandr.c8
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
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..1085a95 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)
+ 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);