author | llornkcor <llornkcor> | 2002-04-17 03:20:37 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-04-17 03:20:37 (UTC) |
commit | 4db3abc59c27022211222187a48eb649460c5432 (patch) (unidiff) | |
tree | 78fda069e80cadd5eb05c411c8cb5f2725dae6d9 | |
parent | 530f334d28c6156c4a50ba072b6d638a507c9686 (diff) | |
download | opie-4db3abc59c27022211222187a48eb649460c5432.zip opie-4db3abc59c27022211222187a48eb649460c5432.tar.gz opie-4db3abc59c27022211222187a48eb649460c5432.tar.bz2 |
LCD off(only) on suspend patch
-rw-r--r-- | library/qpeapplication.cpp | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/library/qpeapplication.cpp b/library/qpeapplication.cpp index c154689..ba9db71 100644 --- a/library/qpeapplication.cpp +++ b/library/qpeapplication.cpp | |||
@@ -319,54 +319,81 @@ static int disable_suspend = 100; | |||
319 | static bool powerOnline() | 319 | static bool powerOnline() |
320 | { | 320 | { |
321 | return PowerStatusManager::readStatus().acStatus() == PowerStatus::Online; | 321 | return PowerStatusManager::readStatus().acStatus() == PowerStatus::Online; |
322 | } | 322 | } |
323 | 323 | ||
324 | static bool networkOnline() | 324 | static bool networkOnline() |
325 | { | 325 | { |
326 | return Network::networkOnline(); | 326 | return Network::networkOnline(); |
327 | } | 327 | } |
328 | 328 | ||
329 | class QPEScreenSaver : public QWSScreenSaver | 329 | class QPEScreenSaver : public QWSScreenSaver |
330 | { | 330 | { |
331 | private: | ||
332 | int LcdOn; | ||
331 | 333 | ||
332 | public: | 334 | public: |
333 | QPEScreenSaver() | 335 | QPEScreenSaver() |
334 | { | 336 | { |
337 | int fd; | ||
338 | |||
339 | LcdOn = TRUE; | ||
340 | // Make sure the LCD is in fact on, (if opie was killed while the LCD is off it would still be off) | ||
341 | fd=open("/dev/fb0",O_RDWR); | ||
342 | if (fd != -1) { ioctl(fd,FBIOBLANK,VESA_NO_BLANKING); close(fd); } | ||
335 | } | 343 | } |
336 | void restore() | 344 | void restore() |
337 | { | 345 | { |
346 | if (!LcdOn) // We must have turned it off | ||
347 | { | ||
348 | int fd; | ||
349 | fd=open("/dev/fb0",O_RDWR); | ||
350 | if (fd != -1) { ioctl(fd,FBIOBLANK,VESA_NO_BLANKING); close(fd); } | ||
351 | } | ||
338 | setBacklight(-1); | 352 | setBacklight(-1); |
339 | } | 353 | } |
340 | bool save(int level) | 354 | bool save(int level) |
341 | { | 355 | { |
356 | int fd; | ||
357 | |||
342 | switch ( level ) { | 358 | switch ( level ) { |
343 | case 0: | 359 | case 0: |
344 | if ( disable_suspend > 0 && dim_on ) { | 360 | if ( disable_suspend > 0 && dim_on ) { |
345 | if (backlight() > 1) | 361 | if (backlight() > 1) |
346 | setBacklight(1); // lowest non-off | 362 | setBacklight(1); // lowest non-off |
347 | } | 363 | } |
348 | return TRUE; | 364 | return TRUE; |
349 | break; | 365 | break; |
350 | case 1: | 366 | case 1: |
351 | if ( disable_suspend > 1 && lightoff_on ) { | 367 | if ( disable_suspend > 1 && lightoff_on ) { |
352 | setBacklight(0); // off | 368 | setBacklight(0); // off |
353 | } | 369 | } |
354 | return TRUE; | 370 | return TRUE; |
355 | break; | 371 | break; |
356 | case 2: | 372 | case 2: |
373 | Config config( "qpe" ); | ||
374 | config.setGroup( "Screensaver" ); | ||
375 | if (config.readNumEntry("LcdOffOnly",0) != 0) // We're only turning off the LCD | ||
376 | { | ||
377 | fd=open("/dev/fb0",O_RDWR); | ||
378 | if (fd != -1) { ioctl(fd,FBIOBLANK,VESA_POWERDOWN); close(fd); } | ||
379 | LcdOn = FALSE; | ||
380 | } | ||
381 | else // We're going to suspend the whole machine | ||
382 | { | ||
357 | if ( disable_suspend > 2 && !powerOnline() && !networkOnline() ) { | 383 | if ( disable_suspend > 2 && !powerOnline() && !networkOnline() ) { |
358 | QWSServer::sendKeyEvent( 0xffff, Qt::Key_F34, FALSE, TRUE, FALSE ); | 384 | QWSServer::sendKeyEvent( 0xffff, Qt::Key_F34, FALSE, TRUE, FALSE ); |
359 | return TRUE; | 385 | return TRUE; |
360 | } | 386 | } |
387 | } | ||
361 | break; | 388 | break; |
362 | } | 389 | } |
363 | return FALSE; | 390 | return FALSE; |
364 | } | 391 | } |
365 | }; | 392 | }; |
366 | 393 | ||
367 | static int ssi(int interval, Config &config, const QString &enable, const QString& value, int def) | 394 | static int ssi(int interval, Config &config, const QString &enable, const QString& value, int def) |
368 | { | 395 | { |
369 | if ( !enable.isEmpty() && config.readNumEntry(enable,0) == 0 ) | 396 | if ( !enable.isEmpty() && config.readNumEntry(enable,0) == 0 ) |
370 | return 0; | 397 | return 0; |
371 | 398 | ||
372 | if ( interval < 0 ) { | 399 | if ( interval < 0 ) { |