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 @@ -511,214 +511,218 @@ void Desktop::raiseDatebook() } } void Desktop::raiseContacts() { Config cfg("qpe"); //F10, 'Contacts' cfg.setGroup("AppsKey"); QString tempItem; tempItem = cfg.readEntry("Left2nd","Address Book"); if(tempItem == "Address Book" || tempItem.isEmpty()) executeOrModify("Applications/addressbook.desktop"); else { QCopEnvelope e("QPE/System","execute(QString)"); e << tempItem; } } void Desktop::raiseMenu() { Config cfg("qpe"); //F11, 'Menu' cfg.setGroup("AppsKey"); QString tempItem; tempItem = cfg.readEntry("Right2nd","Popup Menu"); if(tempItem == "Popup Menu" || tempItem.isEmpty()) { Global::terminateBuiltin("calibrate"); tb->startMenu()->launch(); } else { QCopEnvelope e("QPE/System","execute(QString)"); e << tempItem; } } void Desktop::raiseEmail() { Config cfg("qpe"); //F13, 'Mail' cfg.setGroup("AppsKey"); QString tempItem; tempItem = cfg.readEntry("RightEnd","Mail"); if(tempItem == "Mail" || tempItem == "qtmail" || tempItem.isEmpty()) executeOrModify("Applications/qtmail.desktop"); else { QCopEnvelope e("QPE/System","execute(QString)"); e << tempItem; } } // autoStarts apps on resume and start void Desktop::execAutoStart() { QString appName; int delay; 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() { if ( type() != GuiServer ) return; ShutdownImpl *sd = new ShutdownImpl( 0, 0, WDestructiveClose ); connect( sd, SIGNAL(shutdown(ShutdownImpl::Type)), this, SLOT(shutdown(ShutdownImpl::Type)) ); sd->showMaximized(); } void DesktopApplication::shutdown( ShutdownImpl::Type t ) { switch ( t ) { case ShutdownImpl::ShutdownSystem: execlp("shutdown", "shutdown", "-h", "now", (void*)0); break; case ShutdownImpl::RebootSystem: execlp("shutdown", "shutdown", "-r", "now", (void*)0); break; case ShutdownImpl::RestartDesktop: restart(); break; case ShutdownImpl::TerminateDesktop: prepareForTermination(FALSE); // This is a workaround for a Qt bug // clipboard applet has to stop its poll timer, or Qt/E // will hang on quit() right before it emits aboutToQuit() emit aboutToQuit ( ); quit(); break; } } void DesktopApplication::restart() { prepareForTermination(TRUE); #ifdef Q_WS_QWS for ( int fd = 3; fd < 100; fd++ ) close( fd ); #if defined(QT_DEMO_SINGLE_FLOPPY) execl( "/sbin/init", "qpe", 0 ); #elif defined(QT_QWS_CASSIOPEIA) execl( "/bin/sh", "sh", 0 ); #else execl( (qpeDir()+"/bin/qpe").latin1(), "qpe", 0 ); #endif exit(1); diff --git a/libopie/odevice.cpp b/libopie/odevice.cpp index 057c344..bf64676 100644 --- a/libopie/odevice.cpp +++ b/libopie/odevice.cpp @@ -213,214 +213,216 @@ OLedState ODevice::led ( uint /*which*/ ) const { return OLED_Off; } bool ODevice::setLed ( uint /*which*/, OLedState /*st*/ ) { return false; } //#if defined( QT_QWS_IPAQ ) // IPAQ void ODeviceIPAQ::init ( ) { d-> m_vendorstr = "HP"; d-> m_vendor = OVENDOR_HP; QFile f ( "/proc/hal/model" ); if ( f. open ( IO_ReadOnly )) { QTextStream ts ( &f ); d-> m_modelstr = "H" + ts. readLine ( ); if ( d-> m_modelstr == "H3100" ) d-> m_model = OMODEL_iPAQ_H31xx; else if ( d-> m_modelstr == "H3600" ) d-> m_model = OMODEL_iPAQ_H36xx; else if ( d-> m_modelstr == "H3700" ) d-> m_model = OMODEL_iPAQ_H37xx; else if ( d-> m_modelstr == "H3800" ) d-> m_model = OMODEL_iPAQ_H38xx; else d-> m_model = OMODEL_Unknown; f. close ( ); } f. setName ( "/etc/familiar-version" ); if ( f. open ( IO_ReadOnly )) { d-> m_systemstr = "Familiar"; d-> m_system = OSYSTEM_Familiar; QTextStream ts ( &f ); d-> m_sysverstr = ts. readLine ( ). mid ( 10 ); 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 { return 1; } OLedState ODeviceIPAQ::led ( uint which ) const { if ( which == 0 ) return d-> m_leds [0]; else return OLED_Off; } bool ODeviceIPAQ::setLed ( uint which, OLedState st ) { static int fd = ::open ( "/dev/touchscreen/0", O_RDWR|O_NONBLOCK ); if ( which == 0 ) { if ( fd >= 0 ) { struct h3600_ts_led leds; ::memset ( &leds, 0, sizeof( leds )); leds. TotalTime = 0; leds. OnTime = 0; leds. OffTime = 1; leds. OffOnBlink = 2; switch ( st ) { case OLED_Off : leds. OffOnBlink = 0; break; case OLED_On : leds. OffOnBlink = 1; break; case OLED_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break; case OLED_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break; } if ( ::ioctl ( fd, LED_ON, &leds ) >= 0 ) { d-> m_leds [0] = st; return true; } } } return false; } //#endif |