tderandr: use different variables for nested for loops

Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it>
pull/321/head
Michele Calgaro 2 weeks ago committed by TDE Gitea
parent 61b9e1c901
commit 96114858d8

@ -1097,7 +1097,6 @@ void KRandrSimpleAPI::applyHotplugRules(TQString kde_confdir) {
} }
void KRandrSimpleAPI::applyDisplayGamma(TQPtrList<SingleScreenData> screenInfoArray) { void KRandrSimpleAPI::applyDisplayGamma(TQPtrList<SingleScreenData> screenInfoArray) {
int i;
Display *randr_display; Display *randr_display;
XRROutputInfo *output_info; XRROutputInfo *output_info;
ScreenInfo *randr_screen_info; ScreenInfo *randr_screen_info;
@ -1108,7 +1107,7 @@ void KRandrSimpleAPI::applyDisplayGamma(TQPtrList<SingleScreenData> screenInfoAr
if (isValid() == true) { if (isValid() == true) {
randr_display = tqt_xdisplay(); randr_display = tqt_xdisplay();
randr_screen_info = read_screen_info(randr_display); 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); screendata = screenInfoArray.at(i);
output_info = randr_screen_info->outputs[i]->info; output_info = randr_screen_info->outputs[i]->info;
CrtcInfo *current_crtc = randr_screen_info->outputs[i]->cur_crtc; 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 // 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); 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; kdWarning() << "Gamma correction table has wrong size." << endl;
continue; continue;
} }
@ -1126,34 +1125,33 @@ void KRandrSimpleAPI::applyDisplayGamma(TQPtrList<SingleScreenData> screenInfoAr
kdWarning() << "Gamma allocation failed." << endl; kdWarning() << "Gamma allocation failed." << endl;
continue; continue;
} }
for (i = 0; i < size; i++) { for (int j = 0; j < size; j++) {
if (screendata->gamma_red == 1.0) 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 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) 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 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) 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 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); XRRSetCrtcGamma(randr_display, current_crtc->id, gamma);
free(gamma); free(gamma);

Loading…
Cancel
Save