Commit cf25d585 authored by Giuseppe Bilotta's avatar Giuseppe Bilotta

xrandr: allow single value for --gamma

Similarly to --scale, accept a single value to be used for all three
components, and refuse values with extra junk after the acceptable
values.
Signed-off-by: Giuseppe Bilotta's avatarGiuseppe Bilotta <giuseppe.bilotta@gmail.com>
Reviewed-by: default avatarAlex Deucher <alexander.deucher@amd.com>
Reviewed-by: Keith Packard's avatarKeith Packard <keithp@keithp.com>
parent 289bc0f1
......@@ -63,7 +63,7 @@ xrandr \- primitive command line interface to RandR extension
[\-\-set \fIproperty\fP \fIvalue\fP]
[\-\-off]
[\-\-crtc \fIcrtc\fP]
[\-\-gamma \fIred\fP:\fIgreen\fP:\fIblue\fP]
[\-\-gamma \fIred\fP[:\fIgreen\fP:\fIblue\fP]]
[\-\-brightness \fIbrightness\fP]
[\-o \fIorientation\fP]
[\-s \fIsize\fP]
......@@ -303,9 +303,12 @@ Uses the specified crtc (either as an index in the list of CRTCs or XID).
In normal usage, this option is not required as xrandr tries to make
sensible choices about which crtc to use with each output. When that fails
for some reason, this option can override the normal selection.
.IP "\-\-gamma \fIred\fP:\fIgreen\fP:\fIblue\fP"
.IP "\-\-gamma \fIred\fP[:\fIgreen\fP:\fIblue\fP]"
Set the specified floating point values as gamma correction on the crtc
currently attached to this output. Note that you cannot get two different values
currently attached to this output.
If green and blue are not specified, the red value will be used
for all three components.
Note that you cannot get two different values
for cloned outputs (i.e.: which share the same crtc) and that switching an output to another crtc doesn't change
the crtc gamma corrections at all.
.IP "\-\-brightness \fIbrightness\fP"
......
......@@ -144,7 +144,7 @@ usage(void)
" --off\n"
" --crtc <crtc>\n"
" --panning <w>x<h>[+<x>+<y>[/<track:w>x<h>+<x>+<y>[/<border:l>/<t>/<r>/<b>]]]\n"
" --gamma <r>:<g>:<b>\n"
" --gamma <r>[:<g>:<b>]\n"
" --brightness <value>\n"
" --primary\n"
" --noprimary\n"
......@@ -2967,11 +2967,18 @@ main (int argc, char **argv)
continue;
}
if (!strcmp ("--gamma", argv[i])) {
char junk;
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], "%f:%f:%f", &config_output->gamma.red,
&config_output->gamma.green, &config_output->gamma.blue) != 3)
argerr ("%s: invalid argument '%s'\n", argv[i-1], argv[i]);
if (sscanf(argv[i], "%f:%f:%f%c", &config_output->gamma.red,
&config_output->gamma.green, &config_output->gamma.blue, &junk) != 3)
{
/* check if it's a single floating-point value,
* to be applied to all components */
if (sscanf(argv[i], "%f%c", &config_output->gamma.red, &junk) != 1)
argerr ("%s: invalid argument '%s'\n", argv[i-1], argv[i]);
config_output->gamma.green = config_output->gamma.blue = config_output->gamma.red;
}
config_output->changes |= changes_gamma;
setit_1_2 = True;
continue;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment