summaryrefslogtreecommitdiffstats
path: root/tderandr/libtderandr.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tderandr/libtderandr.cpp')
-rw-r--r--tderandr/libtderandr.cpp20
1 files changed, 9 insertions, 11 deletions
diff --git a/tderandr/libtderandr.cpp b/tderandr/libtderandr.cpp
index 412ead858..a0b8158ab 100644
--- a/tderandr/libtderandr.cpp
+++ b/tderandr/libtderandr.cpp
@@ -1097,7 +1097,6 @@ void KRandrSimpleAPI::applyHotplugRules(TQString kde_confdir) {
}
void KRandrSimpleAPI::applyDisplayGamma(TQPtrList<SingleScreenData> screenInfoArray) {
- int i;
Display *randr_display;
XRROutputInfo *output_info;
ScreenInfo *randr_screen_info;
@@ -1108,7 +1107,7 @@ void KRandrSimpleAPI::applyDisplayGamma(TQPtrList<SingleScreenData> screenInfoAr
if (isValid() == true) {
randr_display = tqt_xdisplay();
randr_screen_info = read_screen_info(randr_display);
- for (i = 0; i < screenInfoArray.count(); i++) {
+ for (int i = 0; i < screenInfoArray.count(); i++) {
screendata = screenInfoArray.at(i);
output_info = randr_screen_info->outputs[i]->info;
CrtcInfo *current_crtc = randr_screen_info->outputs[i]->cur_crtc;
@@ -1117,7 +1116,7 @@ void KRandrSimpleAPI::applyDisplayGamma(TQPtrList<SingleScreenData> screenInfoAr
}
// vvvvvvvvv This chunk of code is based on code from the function set_gamma() of xrandr vvvvvvvvvv
int size = XRRGetCrtcGammaSize(randr_display, current_crtc->id);
- if (!size || size > 65536) {
+ if (size <= 0 || size > 65536) {
kdWarning() << "Gamma correction table has wrong size." << endl;
continue;
}
@@ -1126,34 +1125,33 @@ void KRandrSimpleAPI::applyDisplayGamma(TQPtrList<SingleScreenData> screenInfoAr
kdWarning() << "Gamma allocation failed." << endl;
continue;
}
- for (i = 0; i < size; i++) {
+ for (int j = 0; j < size; j++) {
if (screendata->gamma_red == 1.0)
{
- gamma->red[i] = (double)i / (double)(size - 1) * 65530.0;
+ gamma->red[j] = (double)j / (double)(size - 1) * 65530.0;
}
else
{
- gamma->red[i] = fmin(pow((double)i / (double)(size - 1), screendata->gamma_red), 1.0) * 65530.0;
+ 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[i] = (double)i / (double)(size - 1) * 65530.0;
+ gamma->green[j] = (double)j / (double)(size - 1) * 65530.0;
}
else
{
- gamma->green[i] = fmin(pow((double)i / (double)(size - 1), screendata->gamma_green), 1.0) * 65530.0;
+ 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[i] = (double)i / (double)(size - 1) * 65530.0;
+ gamma->blue[j] = (double)j / (double)(size - 1) * 65530.0;
}
else
{
- gamma->blue[i] = fmin(pow((double)i / (double)(size - 1), screendata->gamma_blue), 1.0) * 65530.0;
+ gamma->blue[j] = fmin(pow((double)j / (double)(size - 1), screendata->gamma_blue), 1.0) * 65530.0;
}
-
}
XRRSetCrtcGamma(randr_display, current_crtc->id, gamma);
free(gamma);