diff options
-rw-r--r-- | tderandr/libtderandr.cpp | 41 |
1 files changed, 15 insertions, 26 deletions
diff --git a/tderandr/libtderandr.cpp b/tderandr/libtderandr.cpp index a0b8158ab..f510ca8ab 100644 --- a/tderandr/libtderandr.cpp +++ b/tderandr/libtderandr.cpp @@ -1126,31 +1126,15 @@ void KRandrSimpleAPI::applyDisplayGamma(TQPtrList<SingleScreenData> screenInfoAr continue; } for (int j = 0; j < size; j++) { - if (screendata->gamma_red == 1.0) - { - gamma->red[j] = (double)j / (double)(size - 1) * 65530.0; + if (size == 1) { + gamma->red[j] = 0.0; + gamma->green[j] = 0.0; + gamma->blue[j] = 0.0; } - else - { - gamma->red[j] = fmin(pow((double)j / (double)(size - 1), screendata->gamma_red), 1.0) * 65530.0; - } - - if (screendata->gamma_green == 1.0) - { - gamma->green[j] = (double)j / (double)(size - 1) * 65530.0; - } - else - { - gamma->green[j] = fmin(pow((double)j / (double)(size - 1), screendata->gamma_green), 1.0) * 65530.0; - } - - if (screendata->gamma_blue == 1.0) - { - gamma->blue[j] = (double)j / (double)(size - 1) * 65530.0; - } - else - { - gamma->blue[j] = fmin(pow((double)j / (double)(size - 1), screendata->gamma_blue), 1.0) * 65530.0; + else { + gamma->red[j] = fmin(pow((double)j / (double)(size - 1), screendata->gamma_red), 1.0) * 65535.0; + gamma->green[j] = fmin(pow((double)j / (double)(size - 1), screendata->gamma_green), 1.0) * 65535.0; + gamma->blue[j] = fmin(pow((double)j / (double)(size - 1), screendata->gamma_blue), 1.0) * 65535.0; } } XRRSetCrtcGamma(randr_display, current_crtc->id, gamma); @@ -1395,8 +1379,13 @@ TQPtrList<SingleScreenData> KRandrSimpleAPI::readCurrentDisplayConfiguration() { //int slot = 127; int slot = 7; int size = XRRGetCrtcGammaSize(randr_display, current_crtc->id); - if(size>0) { - XRRCrtcGamma *gammastruct = XRRGetCrtcGamma (randr_display, current_crtc->id); + XRRCrtcGamma *gammastruct = XRRGetCrtcGamma (randr_display, current_crtc->id); + if (size == 1) { + screendata->gamma_red = 0.0; + screendata->gamma_green = 0.0; + screendata->gamma_blue = 0.0; + } + else if (size > 1) { screendata->gamma_red = log(gammastruct->red[slot]/((size-1.0)*256.0))/log(slot/(size-1.0)); screendata->gamma_green = log(gammastruct->green[slot]/((size-1.0)*256.0))/log(slot/(size-1.0)); screendata->gamma_blue = log(gammastruct->blue[slot]/((size-1.0)*256.0))/log(slot/(size-1.0)); |