diff options
author | Mikhail Gusarov <dottedmag@dottedmag.net> | 2009-10-25 03:41:05 +0600 |
---|---|---|
committer | Matthias Hopf <mhopf@suse.de> | 2010-01-04 17:27:01 +0100 |
commit | b481bd0df87c6b474d8c443b6590bbafac482485 (patch) | |
tree | 32817a73fd76a7754cb860acae25a7551ac15b17 | |
parent | 7d463218c584b683c9946cbff44bc69115eaa11b (diff) |
Add --brightness for CRTC
--brightness n.m adjusts gamma set for CRTC in order to compensate
for overly bright or overly dark unmanageable outputs.
Signed-off-by: Matthias Hopf <mhopf@suse.de>
-rw-r--r-- | xrandr.c | 32 | ||||
-rw-r--r-- | xrandr.man | 4 |
2 files changed, 30 insertions, 6 deletions
@@ -326,6 +326,8 @@ struct _output { float blue; } gamma; + float brightness; + Bool primary; Bool found; @@ -1215,24 +1217,33 @@ set_gamma(void) continue; } + if(output->gamma.red == 0.0 && output->gamma.green == 0.0 && output->gamma.blue == 0.0) + output->gamma.red = output->gamma.green = output->gamma.blue = 1.0; + + if (output->brightness == 0.0) + output->brightness = 1.0; + for (i = 0; i < size; i++) { - if (output->gamma.red == 1.0) + if (output->gamma.red == 1.0 && output->brightness == 1.0) gamma->red[i] = i << 8; else gamma->red[i] = (CARD16)(pow((double)i/(double)(size - 1), - (double)output->gamma.red) * (double)(size - 1) * 256); + (double)output->gamma.red) * (double)(size - 1) + * (double)output->brightness * 256); - if (output->gamma.green == 1.0) + if (output->gamma.green == 1.0 && output->brightness == 1.0) gamma->green[i] = i << 8; else gamma->green[i] = (CARD16)(pow((double)i/(double)(size - 1), - (double)output->gamma.green) * (double)(size - 1) * 256); + (double)output->gamma.green) * (double)(size - 1) + * (double)output->brightness * 256); - if (output->gamma.blue == 1.0) + if (output->gamma.blue == 1.0 && output->brightness == 1.0) gamma->blue[i] = i << 8; else gamma->blue[i] = (CARD16)(pow((double)i/(double)(size - 1), - (double)output->gamma.blue) * (double)(size - 1) * 256); + (double)output->gamma.blue) * (double)(size - 1) + * (double)output->brightness * 256); } XRRSetCrtcGamma(dpy, crtc->crtc.xid, gamma); @@ -2320,6 +2331,15 @@ main (int argc, char **argv) setit_1_2 = True; continue; } + if (!strcmp ("--brightness", argv[i])) { + if (!output) usage(); + if (++i>=argc) usage(); + if (sscanf(argv[i], "%f", &output->brightness) != 1) + usage (); + output->changes |= changes_gamma; + setit_1_2 = True; + continue; + } if (!strcmp ("--primary", argv[i])) { if (!output) usage(); output->changes |= changes_primary; @@ -77,6 +77,7 @@ xrandr \- primitive command line interface to RandR extension [\-\-off] [\-\-crtc \fIcrtc\fP] [\-\-gamma \fIred\fP:\fIgreen\fP:\fIblue\fP] +[\-\-brightness \fIbrightness\fP] .br .B RandR version 1.0 and version 1.1 options @@ -288,6 +289,9 @@ 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 for cloned outputs and that switching an output to another crtc doesn't change the crtc gamma corrections at all. +.IP "\-\-brightness \fIbrightness\fP" +Multiply the gamma values on the crtc currently attached to the output to +specified floating value. Useful for overly bright or overly dim outputs. .PP .SH "RandR version 1.1 options" These options are available for X servers supporting RandR version 1.1 or |