From 08a04d6a844bb0ac98bb4e84803c886dfdec98c2 Mon Sep 17 00:00:00 2001 From: Eric Piel Date: Sun, 10 Jan 2010 00:08:53 +0100 Subject: [PATCH 1/2] xrandr: fix maximum gamma set MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Gamma is an array of 3 16-bit values. Currently, the maximum value assigned is 255*256, which is only 65280. Make sure that when we set the gamma, the maximum value is 65535. It's slightly brighter but also helps to avoid kludges to detect clamped values when reading back the gamma. Signed-off-by: Éric Piel --- xrandr.c | 18 +++++++++--------- 1 files changed, 9 insertions(+), 9 deletions(-) diff --git a/xrandr.c b/xrandr.c index 65e0623..76c1342 100644 --- a/xrandr.c +++ b/xrandr.c @@ -1225,25 +1225,25 @@ set_gamma(void) for (i = 0; i < size; i++) { if (output->gamma.red == 1.0 && output->brightness == 1.0) - gamma->red[i] = i << 8; + gamma->red[i] = (i << 8) + i; else gamma->red[i] = dmin(pow((double)i/(double)(size - 1), - (double)output->gamma.red) * (double)(size - 1) - * (double)output->brightness * 256, 65535.0); + output->gamma.red) * output->brightness, + 1.0) * 65535.0; if (output->gamma.green == 1.0 && output->brightness == 1.0) - gamma->green[i] = i << 8; + gamma->green[i] = (i << 8) + i; else gamma->green[i] = dmin(pow((double)i/(double)(size - 1), - (double)output->gamma.green) * (double)(size - 1) - * (double)output->brightness * 256, 65535); + output->gamma.green) * output->brightness, + 1.0) * 65535.0; if (output->gamma.blue == 1.0 && output->brightness == 1.0) - gamma->blue[i] = i << 8; + gamma->blue[i] = (i << 8) + i; else gamma->blue[i] = dmin(pow((double)i/(double)(size - 1), - (double)output->gamma.blue) * (double)(size - 1) - * (double)output->brightness * 256, 65535); + output->gamma.blue) * output->brightness, + 1.0) * 65535.0; } XRRSetCrtcGamma(dpy, crtc->crtc.xid, gamma); -- 1.7.0.3