-rw-r--r-- | library/qpeapplication.cpp | 35 |
1 files changed, 31 insertions, 4 deletions
diff --git a/library/qpeapplication.cpp b/library/qpeapplication.cpp index c154689..ba9db71 100644 --- a/library/qpeapplication.cpp +++ b/library/qpeapplication.cpp @@ -283,126 +283,153 @@ static void setBacklight(int bright) typedef struct { unsigned char mode; unsigned char pwr; unsigned char brightness; } FLITE_IN; # ifndef FLITE_ON # ifndef _LINUX_IOCTL_H # include <linux/ioctl.h> # endif # define FLITE_ON _IOW('f', 7, FLITE_IN) # endif int fd; if ( QFile::exists("/dev/ts") ) fd = open("/dev/ts", O_WRONLY); else fd = open("/dev/h3600_ts", O_WRONLY); if (fd >= 0 ) { FLITE_IN bl; bl.mode = 1; bl.pwr = bright ? 1 : 0; bl.brightness = bright; ioctl(fd, FLITE_ON, &bl); close(fd); } } #endif #endif curbl = bright; } void qpe_setBacklight(int bright) { setBacklight(bright); } static bool dim_on = FALSE; static bool lightoff_on = FALSE; static int disable_suspend = 100; static bool powerOnline() { return PowerStatusManager::readStatus().acStatus() == PowerStatus::Online; } static bool networkOnline() { return Network::networkOnline(); } class QPEScreenSaver : public QWSScreenSaver { +private: + int LcdOn; public: QPEScreenSaver() { + int fd; + + LcdOn = TRUE; + // Make sure the LCD is in fact on, (if opie was killed while the LCD is off it would still be off) + fd=open("/dev/fb0",O_RDWR); + if (fd != -1) { ioctl(fd,FBIOBLANK,VESA_NO_BLANKING); close(fd); } } void restore() { + if (!LcdOn) // We must have turned it off + { + int fd; + fd=open("/dev/fb0",O_RDWR); + if (fd != -1) { ioctl(fd,FBIOBLANK,VESA_NO_BLANKING); close(fd); } + } setBacklight(-1); } bool save(int level) { + int fd; + switch ( level ) { case 0: if ( disable_suspend > 0 && dim_on ) { if (backlight() > 1) setBacklight(1); // lowest non-off } return TRUE; break; case 1: if ( disable_suspend > 1 && lightoff_on ) { setBacklight(0); // off } return TRUE; break; case 2: - if ( disable_suspend > 2 && !powerOnline() && !networkOnline() ) { - QWSServer::sendKeyEvent( 0xffff, Qt::Key_F34, FALSE, TRUE, FALSE ); - return TRUE; - } + Config config( "qpe" ); + config.setGroup( "Screensaver" ); + if (config.readNumEntry("LcdOffOnly",0) != 0) // We're only turning off the LCD + { + fd=open("/dev/fb0",O_RDWR); + if (fd != -1) { ioctl(fd,FBIOBLANK,VESA_POWERDOWN); close(fd); } + LcdOn = FALSE; + } + else // We're going to suspend the whole machine + { + if ( disable_suspend > 2 && !powerOnline() && !networkOnline() ) { + QWSServer::sendKeyEvent( 0xffff, Qt::Key_F34, FALSE, TRUE, FALSE ); + return TRUE; + } + } break; } return FALSE; } }; static int ssi(int interval, Config &config, const QString &enable, const QString& value, int def) { if ( !enable.isEmpty() && config.readNumEntry(enable,0) == 0 ) return 0; if ( interval < 0 ) { // Restore screen blanking and power saving state interval = config.readNumEntry( value, def ); } return interval; } static void setScreenSaverIntervals(int i1, int i2, int i3) { Config config( "qpe" ); config.setGroup( "Screensaver" ); int v[4]; i1 = ssi(i1, config, "Dim","Interval_Dim", 30); i2 = ssi(i2, config, "LightOff","Interval_LightOff", 20); i3 = ssi(i3, config, "","Interval", 60); //qDebug("screen saver intervals: %d %d %d", i1, i2, i3); v[0] = QMAX( 1000*i1, 100); v[1] = QMAX( 1000*i2, 100); v[2] = QMAX( 1000*i3, 100); v[3] = 0; dim_on = ( (i1 != 0) ? config.readNumEntry("Dim",1) : FALSE ); lightoff_on = ( (i2 != 0 ) ? config.readNumEntry("LightOff",1) : FALSE ); if ( !i1 && !i2 && !i3 ) QWSServer::setScreenSaverInterval(0); else QWSServer::setScreenSaverIntervals(v); } static void setScreenSaverInterval(int interval) { setScreenSaverIntervals(-1,-1,interval); } |