6
6
7
7
#include "xsct.h"
8
8
9
- static void usage (char * pname )
9
+ static void usage (const char * const pname )
10
10
{
11
11
printf ("Xsct (%s)\n"
12
12
"Usage: %s [options] [temperature] [brightness]\n"
@@ -23,7 +23,7 @@ static void usage(char * pname)
23
23
24
24
static double DoubleTrim (double x , double a , double b )
25
25
{
26
- double buff [3 ] = {a , x , b };
26
+ const double buff [3 ] = {a , x , b };
27
27
return buff [ (int )(x > a ) + (int )(x > b ) ];
28
28
}
29
29
@@ -34,10 +34,9 @@ static struct temp_status get_sct_for_screen(Display *dpy, int screen, int icrtc
34
34
35
35
int n , c ;
36
36
double t = 0.0 ;
37
- double gammar = 0.0 , gammag = 0.0 , gammab = 0.0 , gammad = 0.0 ;
37
+ double gammar = 0.0 , gammag = 0.0 , gammab = 0.0 ;
38
38
struct temp_status temp ;
39
39
temp .temp = 0 ;
40
- temp .brightness = 1.0 ;
41
40
42
41
n = res -> ncrtc ;
43
42
if ((icrtc >= 0 ) && (icrtc < n ))
@@ -70,7 +69,7 @@ static struct temp_status get_sct_for_screen(Display *dpy, int screen, int icrtc
70
69
temp .brightness /= BRIGHTHESS_DIV ;
71
70
temp .brightness = DoubleTrim (temp .brightness , 0.0 , 1.0 );
72
71
if (fdebug > 0 ) fprintf (stderr , "DEBUG: Gamma: %f, %f, %f, brightness: %f\n" , gammar , gammag , gammab , temp .brightness );
73
- gammad = gammab - gammar ;
72
+ const double gammad = gammab - gammar ;
74
73
if (gammad < 0.0 )
75
74
{
76
75
if (gammab > 0.0 )
@@ -97,7 +96,7 @@ static struct temp_status get_sct_for_screen(Display *dpy, int screen, int icrtc
97
96
98
97
static void sct_for_screen (Display * dpy , int screen , int icrtc , struct temp_status temp , int fdebug )
99
98
{
100
- double t = 0.0 , b = 1.0 , g = 0.0 , gammar , gammag , gammab ;
99
+ double t = 0.0 , b = 1.0 , gammar , gammag , gammab ;
101
100
int n , c ;
102
101
Window root = RootWindow (dpy , screen );
103
102
XRRScreenResources * res = XRRGetScreenResourcesCurrent (dpy , root );
@@ -109,7 +108,7 @@ static void sct_for_screen(Display *dpy, int screen, int icrtc, struct temp_stat
109
108
gammar = 1.0 ;
110
109
if (temp .temp > TEMPERATURE_ZERO )
111
110
{
112
- g = log (t - TEMPERATURE_ZERO );
111
+ const double g = log (t - TEMPERATURE_ZERO );
113
112
gammag = DoubleTrim (GAMMA_K0GR + GAMMA_K1GR * g , 0.0 , 1.0 );
114
113
gammab = DoubleTrim (GAMMA_K0BR + GAMMA_K1BR * g , 0.0 , 1.0 );
115
114
}
@@ -121,7 +120,7 @@ static void sct_for_screen(Display *dpy, int screen, int icrtc, struct temp_stat
121
120
}
122
121
else
123
122
{
124
- g = log (t - (TEMPERATURE_NORM - TEMPERATURE_ZERO ));
123
+ const double g = log (t - (TEMPERATURE_NORM - TEMPERATURE_ZERO ));
125
124
gammar = DoubleTrim (GAMMA_K0RB + GAMMA_K1RB * g , 0.0 , 1.0 );
126
125
gammag = DoubleTrim (GAMMA_K0GB + GAMMA_K1GB * g , 0.0 , 1.0 );
127
126
gammab = 1.0 ;
@@ -144,7 +143,7 @@ static void sct_for_screen(Display *dpy, int screen, int icrtc, struct temp_stat
144
143
145
144
for (i = 0 ; i < size ; i ++ )
146
145
{
147
- g = GAMMA_MULT * b * (double )i / (double )size ;
146
+ const double g = GAMMA_MULT * b * (double )i / (double )size ;
148
147
crtc_gamma -> red [i ] = (unsigned short int )(g * gammar + 0.5 );
149
148
crtc_gamma -> green [i ] = (unsigned short int )(g * gammag + 0.5 );
150
149
crtc_gamma -> blue [i ] = (unsigned short int )(g * gammab + 0.5 );
0 commit comments