-rw-r--r-- | core/launcher/desktop.cpp | 56 |
1 files changed, 30 insertions, 26 deletions
diff --git a/core/launcher/desktop.cpp b/core/launcher/desktop.cpp index 387650b..d2bd8ae 100644 --- a/core/launcher/desktop.cpp +++ b/core/launcher/desktop.cpp | |||
@@ -168,9 +168,11 @@ public: | |||
168 | m_lcd_status = true; | 168 | m_lcd_status = true; |
169 | 169 | ||
170 | m_backlight_bright = -1; | 170 | m_backlight_normal = -1; |
171 | m_backlight_current = -1; | ||
171 | m_backlight_forcedoff = false; | 172 | m_backlight_forcedoff = false; |
172 | 173 | ||
173 | // Make sure the LCD is in fact on, (if opie was killed while the LCD is off it would still be off) | 174 | // Make sure the LCD is in fact on, (if opie was killed while the LCD is off it would still be off) |
174 | ODevice::inst ( ) -> setDisplayStatus ( true ); | 175 | ODevice::inst ( )-> setDisplayStatus ( true ); |
176 | setBacklight ( -1 ); | ||
175 | } | 177 | } |
176 | void restore() | 178 | void restore() |
@@ -181,5 +183,5 @@ public: | |||
181 | } | 183 | } |
182 | 184 | ||
183 | setBacklight ( -1 ); | 185 | setBacklightInternal ( -1 ); |
184 | } | 186 | } |
185 | bool save( int level ) | 187 | bool save( int level ) |
@@ -188,6 +190,6 @@ public: | |||
188 | case 0: | 190 | case 0: |
189 | if ( m_disable_suspend > 0 && m_enable_dim ) { | 191 | if ( m_disable_suspend > 0 && m_enable_dim ) { |
190 | if ( backlight() > 1 ) | 192 | if ( m_backlight_current > 1 ) |
191 | setBacklight( 1 ); // lowest non-off | 193 | setBacklightInternal ( 1 ); // lowest non-off |
192 | } | 194 | } |
193 | return true; | 195 | return true; |
@@ -195,5 +197,5 @@ public: | |||
195 | case 1: | 197 | case 1: |
196 | if ( m_disable_suspend > 1 && m_enable_lightoff ) { | 198 | if ( m_disable_suspend > 1 && m_enable_lightoff ) { |
197 | setBacklight( 0 ); // off | 199 | setBacklightInternal ( 0 ); // off |
198 | } | 200 | } |
199 | return true; | 201 | return true; |
@@ -201,5 +203,5 @@ public: | |||
201 | case 2: | 203 | case 2: |
202 | if ( m_enable_onlylcdoff ) { | 204 | if ( m_enable_onlylcdoff ) { |
203 | ODevice::inst ( ) -> setDisplayStatus ( false ); | 205 | ODevice::inst ( )-> setDisplayStatus ( false ); |
204 | m_lcd_status = false; | 206 | m_lcd_status = false; |
205 | return true; | 207 | return true; |
@@ -270,17 +272,17 @@ public: | |||
270 | m_disable_suspend = mode; | 272 | m_disable_suspend = mode; |
271 | } | 273 | } |
272 | 274 | ||
273 | int backlight ( ) | 275 | void setBacklight ( int bright ) |
274 | { | 276 | { |
275 | if ( m_backlight_bright == -1 ) { | 277 | // Read from config |
276 | // Read from config | 278 | Config config ( "qpe" ); |
277 | Config config ( "qpe" ); | 279 | config. setGroup ( "Screensaver" ); |
278 | config. setGroup ( "Screensaver" ); | 280 | m_backlight_normal = config. readNumEntry ( "Brightness", 255 ); |
279 | m_backlight_bright = config. readNumEntry ( "Brightness", 255 ); | 281 | |
280 | } | 282 | setBacklightInternal ( bright ); |
281 | return m_backlight_bright; | ||
282 | } | 283 | } |
283 | 284 | ||
284 | void setBacklight ( int bright ) | 285 | private: |
286 | void setBacklightInternal ( int bright ) | ||
285 | { | 287 | { |
286 | if ( bright == -3 ) { | 288 | if ( bright == -3 ) { |
@@ -293,16 +295,17 @@ public: | |||
293 | if ( bright == -2 ) { | 295 | if ( bright == -2 ) { |
294 | // Toggle between off and on | 296 | // Toggle between off and on |
295 | bright = m_backlight_bright ? 0 : -1; | 297 | bright = m_backlight_current ? 0 : -1; |
296 | m_backlight_forcedoff = !bright; | 298 | m_backlight_forcedoff = !bright; |
297 | } | 299 | } |
298 | 300 | if ( bright == -1 ) | |
299 | m_backlight_bright = bright; | 301 | bright = m_backlight_normal; |
300 | 302 | ||
301 | bright = backlight ( ); | 303 | if ( bright != m_backlight_current ) { |
302 | ODevice::inst ( ) -> setDisplayBrightness ( bright ); | 304 | ODevice::inst ( )-> setDisplayBrightness ( bright ); |
303 | 305 | m_backlight_current = bright; | |
304 | m_backlight_bright = bright; | 306 | } |
305 | } | 307 | } |
306 | 308 | ||
309 | public: | ||
307 | void setDisplayState ( bool on ) | 310 | void setDisplayState ( bool on ) |
308 | { | 311 | { |
@@ -321,5 +324,6 @@ private: | |||
321 | bool m_lcd_status; | 324 | bool m_lcd_status; |
322 | 325 | ||
323 | int m_backlight_bright; | 326 | int m_backlight_normal; |
327 | int m_backlight_current; | ||
324 | bool m_backlight_forcedoff; | 328 | bool m_backlight_forcedoff; |
325 | }; | 329 | }; |