summaryrefslogtreecommitdiff
path: root/library/qpeapplication.cpp
Side-by-side diff
Diffstat (limited to 'library/qpeapplication.cpp') (more/less context) (show whitespace changes)
-rw-r--r--library/qpeapplication.cpp27
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
@@ -299,94 +299,121 @@ static void setBacklight(int bright)
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:
+ 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);