[PATCH xrandr v5 1/6] xrandr: allow a single value for --scale
Giuseppe Bilotta
giuseppe.bilotta at gmail.com
Tue Feb 27 11:20:17 UTC 2018
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
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);
--
2.14.1.439.g647b9b4702
More information about the xorg-devel
mailing list