From 96114858d884974d9c704f79fb7ba61a0d52ab21 Mon Sep 17 00:00:00 2001 From: Michele Calgaro Date: Thu, 28 Nov 2024 18:10:06 +0900 Subject: tderandr: use different variables for nested for loops Signed-off-by: Michele Calgaro --- tderandr/libtderandr.cpp | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) (limited to 'tderandr') 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 screenInfoArray) { - int i; Display *randr_display; XRROutputInfo *output_info; ScreenInfo *randr_screen_info; @@ -1108,7 +1107,7 @@ void KRandrSimpleAPI::applyDisplayGamma(TQPtrList 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 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 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); -- cgit v1.2.1