author | sandman <sandman> | 2002-10-13 16:12:08 (UTC) |
---|---|---|
committer | sandman <sandman> | 2002-10-13 16:12:08 (UTC) |
commit | 467451d6d19a2cf5245afa2d219b7d2b1cd008f5 (patch) (side-by-side diff) | |
tree | 8c59b58615a817377c0ae1db10a4093387fdaa77 | |
parent | 92aabc976e4a8e58d7db0bba42cb8d0f3ebe8982 (diff) | |
download | opie-467451d6d19a2cf5245afa2d219b7d2b1cd008f5.zip opie-467451d6d19a2cf5245afa2d219b7d2b1cd008f5.tar.gz opie-467451d6d19a2cf5245afa2d219b7d2b1cd008f5.tar.bz2 |
- added qcop "QPE/System" "setDisplayState(int)" to toggle the LCD on/off
- removed qcop "QPE/Desktop" "home()" -- this is now handled via
qcop "QPE/Application/qpe" "raise()"
- renamed qcop "QPE/Desktop" "suspend()" to qcop "QPE/System" "suspend()"
-rw-r--r-- | core/launcher/desktop.cpp | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/core/launcher/desktop.cpp b/core/launcher/desktop.cpp index 6ee7132..0e60839 100644 --- a/core/launcher/desktop.cpp +++ b/core/launcher/desktop.cpp @@ -147,66 +147,68 @@ void DesktopPowerAlerter::alert( const QString &text, int priority ) void DesktopPowerAlerter::hideEvent( QHideEvent *e ) { QMessageBox::hideEvent( e ); alertCount = 0; currentPriority = INT_MAX; } class QPEScreenSaver : public QWSScreenSaver { private: int LcdOn; public: QPEScreenSaver() { m_disable_suspend = 100; m_enable_dim = false; m_enable_lightoff = false; m_enable_onlylcdoff = false; m_lcd_status = true; m_backlight_bright = -1; m_backlight_forcedoff = false; // Make sure the LCD is in fact on, (if opie was killed while the LCD is off it would still be off) ODevice::inst ( ) -> setDisplayStatus ( true ); } void restore() { - if ( !m_lcd_status ) // We must have turned it off + if ( !m_lcd_status ) { // We must have turned it off ODevice::inst ( ) -> setDisplayStatus ( true ); + m_lcd_status = true; + } setBacklight ( -3 ); } bool save( int level ) { switch ( level ) { case 0: if ( m_disable_suspend > 0 && m_enable_dim ) { if ( backlight() > 1 ) setBacklight( 1 ); // lowest non-off } return true; break; case 1: if ( m_disable_suspend > 1 && m_enable_lightoff ) { setBacklight( 0 ); // off } return true; break; case 2: if ( m_enable_onlylcdoff ) { ODevice::inst ( ) -> setDisplayStatus ( false ); m_lcd_status = false; return true; } else // We're going to suspend the whole machine { if ( ( m_disable_suspend > 2 ) && ( PowerStatusManager::readStatus().acStatus() != PowerStatus::Online ) && ( !Network::networkOnline ( ) ) ) { QWSServer::sendKeyEvent( 0xffff, Qt::Key_F34, FALSE, TRUE, FALSE ); return true; @@ -274,64 +276,72 @@ public: if ( m_backlight_bright == -1 ) { // Read from config Config config ( "qpe" ); config. setGroup ( "Screensaver" ); m_backlight_bright = config. readNumEntry ( "Brightness", 255 ); } return m_backlight_bright; } void setBacklight ( int bright ) { if ( bright == -3 ) { // Forced on m_backlight_forcedoff = false; bright = -1; } if ( m_backlight_forcedoff && bright != -2 ) return ; if ( bright == -2 ) { // Toggle between off and on bright = m_backlight_bright ? 0 : -1; m_backlight_forcedoff = !bright; } m_backlight_bright = bright; bright = backlight ( ); ODevice::inst ( ) -> setDisplayBrightness ( bright ); m_backlight_bright = bright; } + void setDisplayState ( bool on ) + { + if ( m_lcd_status != on ) { + ODevice::inst ( ) -> setDisplayStatus ( on ); + m_lcd_status = on; + } + } + private: int m_disable_suspend; bool m_enable_dim; bool m_enable_lightoff; bool m_enable_onlylcdoff; bool m_lcd_status; int m_backlight_bright; bool m_backlight_forcedoff; }; void DesktopApplication::switchLCD ( bool on ) { if ( qApp ) { DesktopApplication *dapp = (DesktopApplication *) qApp; if ( dapp-> m_screensaver ) { if ( on ) dapp-> m_screensaver-> restore ( ); //setBacklight ( on ? -3 : -1 ); else dapp-> m_screensaver-> save ( 1 ); } } } DesktopApplication::DesktopApplication( int& argc, char **argv, Type appType ) : QPEApplication( argc, argv, appType ) { @@ -348,99 +358,101 @@ DesktopApplication::DesktopApplication( int& argc, char **argv, Type appType ) channel = new QCopChannel( "QPE/System", this ); connect( channel, SIGNAL( received( const QCString&, const QByteArray& ) ), this, SLOT( systemMessage( const QCString&, const QByteArray& ) ) ); m_screensaver = new QPEScreenSaver; m_screensaver-> setInterval ( -1 ); QWSServer::setScreenSaver( m_screensaver ); } DesktopApplication::~DesktopApplication() { delete ps; delete pa; } void DesktopApplication::desktopMessage( const QCString &msg, const QByteArray &data ) { #ifdef Q_WS_QWS QDataStream stream( data, IO_ReadOnly ); if ( msg == "keyRegister(int key, QString channel, QString message)" ) { int k; QString c, m; stream >> k; stream >> c; stream >> m; qWarning( "KeyRegisterReceived: %i, %s, %s", k, ( const char* ) c, ( const char * ) m ); keyRegisterList.append( QCopKeyRegister( k, c, m ) ); } - else if ( msg == "suspend()" ) { - emit power(); - } - else if ( msg == "home()" ) { - qpedesktop-> home ( ); - } #endif } void DesktopApplication::systemMessage( const QCString & msg, const QByteArray & data ) { #ifdef Q_WS_QWS QDataStream stream ( data, IO_ReadOnly ); if ( msg == "setScreenSaverInterval(int)" ) { int time; stream >> time; m_screensaver-> setInterval( time ); } else if ( msg == "setScreenSaverIntervals(int,int,int)" ) { int t1, t2, t3; stream >> t1 >> t2 >> t3; m_screensaver-> setIntervals( t1, t2, t3 ); } else if ( msg == "setBacklight(int)" ) { int bright; stream >> bright; m_screensaver-> setBacklight( bright ); } else if ( msg == "setScreenSaverMode(int)" ) { int mode; stream >> mode; m_screensaver-> setMode ( mode ); } + else if ( msg == "setDisplayState(int)" ) { + int state; + stream >> state; + m_screensaver-> setDisplayState ( state != 0 ); + } + else if ( msg == "suspend()" ) { + emit power(); + } #endif } enum MemState { Unknown, VeryLow, Low, Normal } memstate = Unknown; #ifdef Q_WS_QWS bool DesktopApplication::qwsEventFilter( QWSEvent *e ) { qpedesktop->checkMemory(); if ( e->type == QWSEvent::Key ) { QWSKeyEvent * ke = ( QWSKeyEvent * ) e; if ( !loggedin && ke->simpleData.keycode != Key_F34 ) return TRUE; bool press = ke->simpleData.is_press; bool autoRepeat = ke->simpleData.is_auto_repeat; /* app that registers key/message to be sent back to the app, when it doesn't have focus, when user presses key, unless keyboard has been requested from app. will not send multiple repeats if user holds key i.e. one shot */ if ( !keyRegisterList.isEmpty() && ke->simpleData.keycode !=0 && press) { // qDebug("<<<<<<<<<<<<<keycode %d", ke->simpleData.keycode); KeyRegisterList::Iterator it; for ( it = keyRegisterList.begin(); it != keyRegisterList.end(); ++it ) { if ( ( *it ).getKeyCode() == ke->simpleData.keycode && !autoRepeat && !keyboardGrabbed() ) { if ( press ) qDebug( "press" ); else qDebug( "release" ); @@ -599,64 +611,66 @@ Desktop::Desktop() : launcher = new Launcher( 0, 0, WStyle_Customize | QWidget::WGroupLeader ); connect( launcher, SIGNAL( busy() ), tb, SLOT( startWait() ) ); connect( launcher, SIGNAL( notBusy( const QString& ) ), tb, SLOT( stopWait( const QString& ) ) ); int displayw = qApp->desktop() ->width(); int displayh = qApp->desktop() ->height(); QSize sz = tb->sizeHint(); setGeometry( 0, displayh - sz.height(), displayw, sz.height() ); tb->setGeometry( 0, displayh - sz.height(), displayw, sz.height() ); tb->show(); launcher->showMaximized(); launcher->show(); launcher->raise(); #if defined(QPE_HAVE_MEMALERTER) initMemalerter(); #endif // start services startTransferServer(); ( void ) new IrServer( this ); rereadVolumes(); packageSlave = new PackageSlave( this ); connect( qApp, SIGNAL( volumeChanged( bool ) ), this, SLOT( rereadVolumes() ) ); qApp->installEventFilter( this ); + + qApp-> setMainWidget ( launcher ); } void Desktop::show() { login( TRUE ); QWidget::show(); } Desktop::~Desktop() { delete launcher; delete tb; delete qcopBridge; delete transferServer; } bool Desktop::recoverMemory() { return tb->recoverMemory(); } void Desktop::checkMemory() { #if defined(QPE_HAVE_MEMALERTER) static bool ignoreNormal = FALSE; static bool existingMessage = FALSE; if ( existingMessage ) return ; // don't show a second message while still on first existingMessage = TRUE; switch ( memstate ) { |