diff options
author | Michele Calgaro <michele.calgaro@yahoo.it> | 2024-11-28 18:10:06 +0900 |
---|---|---|
committer | TDE Gitea <gitea@mirror.git.trinitydesktop.org> | 2024-12-05 09:20:41 +0000 |
commit | 96114858d884974d9c704f79fb7ba61a0d52ab21 (patch) | |
tree | 6c0222f7cc76ff014272ba0511b3553614a12d35 /tderandr | |
parent | 61b9e1c9019822a6e4bfcbfbded46c48c4d4446d (diff) | |
download | tdelibs-96114858d884974d9c704f79fb7ba61a0d52ab21.tar.gz tdelibs-96114858d884974d9c704f79fb7ba61a0d52ab21.zip |
tderandr: use different variables for nested for loops
Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it>
Diffstat (limited to 'tderandr')
-rw-r--r-- | tderandr/libtderandr.cpp | 20 |
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); |