[PATCH xrandr 1/2] xrandr: allow a single value for --scale
Giuseppe Bilotta
giuseppe.bilotta at gmail.com
Wed May 17 16:30:45 UTC 2017
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 5742286..1be771d 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]
@@ -200,8 +200,9 @@ As a special argument, instead of
passing a matrix, one can pass the string \fInone\fP, in which case the default
values are used (a unit matrix without filter).
.RE
-.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 2aad946..9f73d0f 100644
--- a/xrandr.c
+++ b/xrandr.c
@@ -132,7 +132,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"
" --off\n"
@@ -2984,7 +2984,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);
--
2.13.0.rc0.207.gb442654931
More information about the xorg-devel
mailing list