-rw-r--r-- | core/launcher/desktop.cpp | 22 | ||||
-rw-r--r-- | core/launcher/main.cpp | 40 |
2 files changed, 51 insertions, 11 deletions
diff --git a/core/launcher/desktop.cpp b/core/launcher/desktop.cpp index f90da1a..7f24259 100644 --- a/core/launcher/desktop.cpp +++ b/core/launcher/desktop.cpp @@ -604,6 +604,13 @@ static void darkScreen() void Desktop::togglePower() { + static bool excllock = false; + + if ( excllock ) + return; + + excllock = true; + bool wasloggedin = loggedin; loggedin=0; suspendTime = QDateTime::currentDateTime(); @@ -611,23 +618,26 @@ void Desktop::togglePower() if ( wasloggedin ) blankScreen(); - system("apm --suspend"); - - + ODevice::inst ( )-> suspend ( ); QWSServer::screenSaverActivate( FALSE ); + { QCopEnvelope("QPE/Card", "mtabChanged()" ); // might have changed while asleep QCopEnvelope e("QPE/System", "setBacklight(int)"); e << -3; // Force on } - if ( wasloggedin ) { + + if ( wasloggedin ) login(TRUE); - } - sleep(1); + execAutoStart(); //qcopBridge->closeOpenConnections(); //qDebug("called togglePower()!!!!!!"); + + qApp-> processEvents ( ); + + excllock = false; } void Desktop::toggleLight() diff --git a/core/launcher/main.cpp b/core/launcher/main.cpp index a19da14..1e741d5 100644 --- a/core/launcher/main.cpp +++ b/core/launcher/main.cpp @@ -333,20 +333,50 @@ int initApplication( int argc, char ** argv ) return rv; } +static const char *pidfile_path = "/var/run/opie.pid"; + +void create_pidfile ( ) +{ + FILE *f; + + if (( f = ::fopen ( pidfile_path, "w" ))) { + ::fprintf ( f, "%d", getpid ( )); + ::fclose ( f ); + } +} + +void remove_pidfile ( ) +{ + ::unlink ( pidfile_path ); +} + +void handle_sigterm ( int sig ) +{ + if ( qApp ) + qApp-> quit ( ); +} + int main( int argc, char ** argv ) { #ifndef SINGLE_APP - signal( SIGCHLD, SIG_IGN ); + ::signal( SIGCHLD, SIG_IGN ); + + ::signal ( SIGTERM, handle_sigterm ); + + ::setsid ( ); + ::setpgid ( 0, 0 ); + + ::atexit ( remove_pidfile ); + create_pidfile ( ); #endif int retVal = initApplication( argc, argv ); #ifndef SINGLE_APP // Kill them. Kill them all. - setpgid( getpid(), getppid() ); - killpg( getpid(), SIGTERM ); - sleep( 1 ); - killpg( getpid(), SIGKILL ); + ::kill ( 0, SIGTERM ); + ::sleep( 1 ); + ::kill ( 0, SIGKILL ); #endif return retVal; |