author | sandman <sandman> | 2002-08-06 21:46:30 (UTC) |
---|---|---|
committer | sandman <sandman> | 2002-08-06 21:46:30 (UTC) |
commit | 2ac1e6ec5a97d3721a3d6513ea68e4e21da1d40b (patch) (side-by-side diff) | |
tree | ad84f4e405da51a6ca14ab4dd33bfd7c9f2a411e | |
parent | 8084d002de5e310491eec7fac0713ef29d0cf30f (diff) | |
download | opie-2ac1e6ec5a97d3721a3d6513ea68e4e21da1d40b.zip opie-2ac1e6ec5a97d3721a3d6513ea68e4e21da1d40b.tar.gz opie-2ac1e6ec5a97d3721a3d6513ea68e4e21da1d40b.tar.bz2 |
- Fix for the "iPAQ won't suspend until apm --suspend is called" problem
- Improved the resume delay until the LCD backlight is on again
-rw-r--r-- | core/launcher/desktop.cpp | 12 | ||||
-rw-r--r-- | libopie/odevice.cpp | 4 |
2 files changed, 11 insertions, 5 deletions
diff --git a/core/launcher/desktop.cpp b/core/launcher/desktop.cpp index 7f24259..552c7c3 100644 --- a/core/launcher/desktop.cpp +++ b/core/launcher/desktop.cpp @@ -559,118 +559,122 @@ void Desktop::execAutoStart() { QDateTime now = QDateTime::currentDateTime(); Config cfg( "autostart" ); cfg.setGroup( "AutoStart" ); appName = cfg.readEntry("Apps", ""); delay = (cfg.readEntry("Delay", "0" )).toInt(); // If the time between suspend and resume was longer then the // value saved as delay, start the app if ( suspendTime.secsTo(now) >= (delay*60) ) { QCopEnvelope e("QPE/System", "execute(QString)"); e << QString(appName); } //else { //} } #if defined(QPE_HAVE_TOGGLELIGHT) #include <qpe/config.h> #include <sys/ioctl.h> #include <sys/types.h> #include <fcntl.h> #include <unistd.h> #include <errno.h> #include <linux/ioctl.h> #include <time.h> #endif static bool blanked=FALSE; static void blankScreen() { if ( !qt_screen ) return; /* Should use a big black window instead. QGfx* g = qt_screen->screenGfx(); g->fillRect(0,0,qt_screen->width(),qt_screen->height()); delete g; */ blanked = TRUE; } static void darkScreen() { extern void qpe_setBacklight(int); qpe_setBacklight(0); // force off } void Desktop::togglePower() { + extern void qpe_setBacklight ( int ); // We need to toggle the LCD fast - no time to send a QCop + static bool excllock = false; if ( excllock ) return; excllock = true; bool wasloggedin = loggedin; loggedin=0; suspendTime = QDateTime::currentDateTime(); - darkScreen(); + + qpe_setBacklight ( 0 ); // force LCD off + if ( wasloggedin ) blankScreen(); ODevice::inst ( )-> suspend ( ); - QWSServer::screenSaverActivate( FALSE ); + QWSServer::screenSaverActivate ( false ); + + qpe_setBacklight ( -3 ); // force LCD on { QCopEnvelope("QPE/Card", "mtabChanged()" ); // might have changed while asleep - QCopEnvelope e("QPE/System", "setBacklight(int)"); - e << -3; // Force on } if ( wasloggedin ) login(TRUE); execAutoStart(); //qcopBridge->closeOpenConnections(); //qDebug("called togglePower()!!!!!!"); qApp-> processEvents ( ); excllock = false; } void Desktop::toggleLight() { QCopEnvelope e("QPE/System", "setBacklight(int)"); e << -2; // toggle } void Desktop::toggleSymbolInput() { tb->toggleSymbolInput(); } void Desktop::toggleNumLockState() { tb->toggleNumLockState(); } void Desktop::toggleCapsLockState() { tb->toggleCapsLockState(); } void Desktop::styleChange( QStyle &s ) { QWidget::styleChange( s ); int displayw = qApp->desktop()->width(); int displayh = qApp->desktop()->height(); QSize sz = tb->sizeHint(); tb->setGeometry( 0, displayh-sz.height(), displayw, sz.height() ); } void DesktopApplication::shutdown() { diff --git a/libopie/odevice.cpp b/libopie/odevice.cpp index 057c344..bf64676 100644 --- a/libopie/odevice.cpp +++ b/libopie/odevice.cpp @@ -261,118 +261,120 @@ void ODeviceIPAQ::init ( ) f. close ( ); } d-> m_leds [0] = OLED_Off; } #include <unistd.h> #include <fcntl.h> #include <sys/ioctl.h> #include <signal.h> #include <sys/time.h> #include <linux/soundcard.h> #include <qapplication.h> #include <qpe/config.h> //#include <linux/h3600_ts.h> // including kernel headers is evil ... typedef struct h3600_ts_led { unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */ unsigned char TotalTime; /* Units of 5 seconds */ unsigned char OnTime; /* units of 100m/s */ unsigned char OffTime; /* units of 100m/s */ } LED_IN; // #define IOC_H3600_TS_MAGIC 'f' // #define LED_ON _IOW(IOC_H3600_TS_MAGIC, 5, struct h3600_ts_led) #define LED_ON (( 1<<30 ) | ( 'f'<<8 ) | ( 5 ) | ( sizeof(struct h3600_ts_led)<<16 )) // _IOW only defined in kernel headers :( //#include <linux/apm_bios.h> //#define APM_IOC_SUSPEND _IO('A',2) #define APM_IOC_SUSPEND (( 0<<30 ) | ( 'A'<<8 ) | ( 2 ) | ( 0<<16 )) void ODeviceIPAQ::tstp_sighandler ( int ) { } bool ODeviceIPAQ::suspend ( ) { int fd; bool res = false; - if (( fd = ::open ( "/dev/apm_bios", O_RDWR )) >= 0 ) { + if ((( fd = ::open ( "/dev/apm_bios", O_RDWR )) >= 0 ) || + (( fd = ::open ( "/dev/misc/apm_bios",O_RDWR )) >= 0 )) { struct timeval tvs, tvn; ::signal ( SIGTSTP, tstp_sighandler ); ::gettimeofday ( &tvs, 0 ); res = ( ::ioctl ( fd, APM_IOC_SUSPEND ) == 0 ); ::close ( fd ); if ( res ) { ::kill ( -::getpid ( ), SIGTSTP ); do { ::usleep ( 200 * 1000 ); ::gettimeofday ( &tvn, 0 ); } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 1500 ); ::kill ( -::getpid ( ), SIGCONT ); } ::signal ( SIGTSTP, SIG_DFL ); } + return res; } void ODeviceIPAQ::alarmSound ( ) { #if defined( QT_QWS_IPAQ ) // IPAQ #ifndef QT_NO_SOUND static Sound snd ( "alarm" ); int fd; int vol; bool vol_reset = false; if ((( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) || (( fd = ::open ( "/dev/mixer", O_RDWR )) >= 0 )) { if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) { Config cfg ( "qpe" ); cfg. setGroup ( "Volume" ); int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); if ( volalarm < 0 ) volalarm = 0; else if ( volalarm > 100 ) volalarm = 100; volalarm |= ( volalarm << 8 ); if (( volalarm & 0xff ) > ( vol & 0xff )) { if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 ) vol_reset = true; } } } snd. play ( ); while ( !snd. isFinished ( )) qApp-> processEvents ( ); if ( fd >= 0 ) { if ( vol_reset ) ::ioctl ( fd, MIXER_WRITE( 0 ), &vol ); ::close ( fd ); } #endif #endif } uint ODeviceIPAQ::hasLeds ( ) const |