diff options
Diffstat (limited to 'ksmserver/shutdown.cpp')
-rw-r--r-- | ksmserver/shutdown.cpp | 128 |
1 files changed, 80 insertions, 48 deletions
diff --git a/ksmserver/shutdown.cpp b/ksmserver/shutdown.cpp index e2699a578..4b30d5cf4 100644 --- a/ksmserver/shutdown.cpp +++ b/ksmserver/shutdown.cpp @@ -69,12 +69,12 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include <tdelocale.h> #include <tdeglobal.h> #include <tdeconfig.h> -#include <kstandarddirs.h> +#include <tdestandarddirs.h> #include <unistd.h> #include <tdeapplication.h> #include <kstaticdeleter.h> #include <tdetempfile.h> -#include <kprocess.h> +#include <tdeprocess.h> #include <dcopclient.h> #include <dcopref.h> #include <dmctl.h> @@ -222,45 +222,13 @@ void KSMServer::shutdownInternal( TDEApplication::ShutdownConfirm confirm, if ( !logoutConfirmed ) { int selection; KSMShutdownFeedback::start(); // make the screen gray - logoutConfirmed = - KSMShutdownDlg::confirmShutdown( maysd, mayrb, sdtype, bopt, &selection ); + logoutConfirmed = KSMShutdownDlg::confirmShutdown( maysd, mayrb, sdtype, bopt, &selection ); // ###### We can't make the screen remain gray while talking to the apps, // because this prevents interaction ("do you want to save", etc.) // TODO: turn the feedback widget into a list of apps to be closed, // with an indicator of the current status for each. KSMShutdownFeedback::stop(); // make the screen become normal again - if (selection != SuspendType::NotSpecified) { - // respect lock on resume & disable suspend/hibernate settings - // from power-manager - TDEConfig config("power-managerrc"); - bool lockOnResume = config.readBoolEntry("lockOnResume", true); - if (lockOnResume) { - TQCString replyType; - TQByteArray replyData; - // Block here until lock is complete - // If this is not done the desktop of the locked session will be shown after suspend/hibernate until the lock fully engages! - kapp->dcopClient()->call("kdesktop", "KScreensaverIface", "lock()", TQCString(""), replyType, replyData); - } -#ifdef WITH_TDEHWLIB - TDERootSystemDevice* rootDevice = hwDevices->rootSystemDevice(); - if (rootDevice) { - switch (selection) { - case SuspendType::Freeze: - rootDevice->setPowerState(TDESystemPowerState::Freeze); - break; - case SuspendType::Suspend: - rootDevice->setPowerState(TDESystemPowerState::Suspend); - break; - case SuspendType::Hibernate: - rootDevice->setPowerState(TDESystemPowerState::Hibernate); - break; - case SuspendType::HybridSuspend: - rootDevice->setPowerState(TDESystemPowerState::HybridSuspend); - break; - } - } -#endif - } + suspend(selection); } if ( logoutConfirmed ) { @@ -272,8 +240,8 @@ void KSMServer::shutdownInternal( TDEApplication::ShutdownConfirm confirm, if (showLogoutStatusDlg) { shutdownNotifierIPDlg = KSMShutdownIPDlg::showShutdownIP(); if (shutdownNotifierIPDlg) { - connect(shutdownNotifierIPDlg, SIGNAL(abortLogoutClicked()), this, SLOT(cancelShutdown())); - connect(shutdownNotifierIPDlg, SIGNAL(skipNotificationClicked()), this, SLOT(forceSkipSaveYourself())); + connect(shutdownNotifierIPDlg, TQ_SIGNAL(abortLogoutClicked()), this, TQ_SLOT(cancelShutdown())); + connect(shutdownNotifierIPDlg, TQ_SIGNAL(skipNotificationClicked()), this, TQ_SLOT(forceSkipSaveYourself())); static_cast<KSMShutdownIPDlg*>(shutdownNotifierIPDlg)->setStatusMessage(i18n("Notifying applications of logout request...")); notificationTimer.start( KSMSERVER_NOTIFICATION_MANUAL_OPTIONS_TIMEOUT, true ); } @@ -289,7 +257,7 @@ void KSMServer::shutdownInternal( TDEApplication::ShutdownConfirm confirm, // Set the real desktop background to black so that exit looks // clean regardless of what was on "our" desktop. if (!showLogoutStatusDlg) { - TQT_TQWIDGET(kapp->desktop())->setBackgroundColor( Qt::black ); + tdeApp->desktop()->setBackgroundColor( TQt::black ); } state = Shutdown; wmPhase1WaitingCount = 0; @@ -343,6 +311,70 @@ void KSMServer::shutdown( TDEApplication::ShutdownConfirm confirm, shutdownInternal( confirm, sdtype, sdmode ); } +void KSMServer::suspendInternal(int state) +{ + if (m_lockOnResume) { + TQCString replyType; + TQByteArray replyData; + // Block here until lock is complete + // If this is not done the desktop of the locked session will be shown after suspend/hibernate until the lock fully engages! + tdeApp->dcopClient()->call("kdesktop", "KScreensaverIface", "lock()", TQCString(""), replyType, replyData); + } + +#ifdef WITH_TDEHWLIB + TDERootSystemDevice* rootDevice = hwDevices->rootSystemDevice(); + rootDevice->setPowerState((TDESystemPowerState::TDESystemPowerState)state); +#endif +} + +bool KSMServer::suspend(int stype) +{ + if (stype == SuspendType::NotSpecified) + return false; + + reconfigure(); + +#ifdef WITH_TDEHWLIB + TDERootSystemDevice* rootDevice = hwDevices->rootSystemDevice(); + if (rootDevice) { + switch (stype) { + case SuspendType::Freeze: + if (rootDevice->canFreeze() && !m_disableSuspend) + { + suspendInternal(TDESystemPowerState::Freeze); + return true; + } + break; + + case SuspendType::Suspend: + if (rootDevice->canSuspend() && !m_disableSuspend) + { + suspendInternal(TDESystemPowerState::Suspend); + return true; + } + break; + + case SuspendType::Hibernate: + if (rootDevice->canHibernate() && !m_disableHibernate) + { + suspendInternal(TDESystemPowerState::Hibernate); + return true; + } + break; + + case SuspendType::HybridSuspend: + if (rootDevice->canHybridSuspend() && !m_disableSuspend && !m_disableHibernate) + { + suspendInternal(TDESystemPowerState::HybridSuspend); + return true; + } + break; + } + } +#endif + return false; +} + #include <tdemessagebox.h> void KSMServer::logoutTimed( int sdtype, int sdmode, TQString bootOption ) @@ -764,8 +796,8 @@ void KSMServer::completeShutdownOrCheckpoint() if (!shutdownNotifierIPDlg) { shutdownNotifierIPDlg = KSMShutdownIPDlg::showShutdownIP(); if (shutdownNotifierIPDlg) { - connect(shutdownNotifierIPDlg, SIGNAL(abortLogoutClicked()), this, SLOT(cancelShutdown())); - connect(shutdownNotifierIPDlg, SIGNAL(skipNotificationClicked()), this, SLOT(forceSkipSaveYourself())); + connect(shutdownNotifierIPDlg, TQ_SIGNAL(abortLogoutClicked()), this, TQ_SLOT(cancelShutdown())); + connect(shutdownNotifierIPDlg, TQ_SIGNAL(skipNotificationClicked()), this, TQ_SLOT(forceSkipSaveYourself())); } } while (!KSMShutdownIPFeedback::ispainted()) { @@ -801,12 +833,12 @@ void KSMServer::completeShutdownOrCheckpoint() if ( state == Shutdown ) { bool waitForKNotify = true; - if( !kapp->dcopClient()->connectDCOPSignal( "knotify", "", + if( !tdeApp->dcopClient()->connectDCOPSignal( "knotify", "", "notifySignal(TQString,TQString,TQString,TQString,TQString,int,int,int,int)", "ksmserver", "notifySlot(TQString,TQString,TQString,TQString,TQString,int,int,int,int)", false )) { waitForKNotify = false; } - if( !kapp->dcopClient()->connectDCOPSignal( "knotify", "", + if( !tdeApp->dcopClient()->connectDCOPSignal( "knotify", "", "playingFinished(int,int)", "ksmserver", "logoutSoundFinished(int,int)", false )) { waitForKNotify = false; @@ -876,14 +908,14 @@ void KSMServer::startKilling() kdDebug( 1218 ) << " We killed all clients. We have now clients.count()=" << clients.count() << endl; completeKilling(); - shutdownTimer.start( KSMSERVER_SHUTDOWN_CLIENT_UNRESPONSIVE_TIMEOUT, TRUE ); + shutdownTimer.start( KSMSERVER_SHUTDOWN_CLIENT_UNRESPONSIVE_TIMEOUT, true ); } void KSMServer::completeKilling() { // Activity detected; reset forcible shutdown timer... if (shutdownTimer.isActive()) { - shutdownTimer.start( KSMSERVER_SHUTDOWN_CLIENT_UNRESPONSIVE_TIMEOUT, TRUE ); + shutdownTimer.start( KSMSERVER_SHUTDOWN_CLIENT_UNRESPONSIVE_TIMEOUT, true ); } SHUTDOWN_MARKER("completeKilling"); kdDebug( 1218 ) << "KSMServer::completeKilling clients.count()=" << clients.count() << endl; @@ -963,7 +995,7 @@ void KSMServer::killWM() } if( iswm ) { completeKillingWM(); - TQTimer::singleShot( 5000, this, TQT_SLOT( timeoutWMQuit() ) ); + TQTimer::singleShot( 5000, this, TQ_SLOT( timeoutWMQuit() ) ); } else { killingCompleted(); @@ -992,7 +1024,7 @@ void KSMServer::killingCompleted() pid_t child; child = fork(); if (child != 0) { - kapp->quit(); + tdeApp->quit(); } else if (child == 0) { // If any remaining client(s) do not exit quickly (e.g. drkonqui) terminate so that they can be seen and interacted with @@ -1001,7 +1033,7 @@ void KSMServer::killingCompleted() } } else { - kapp->quit(); + tdeApp->quit(); } } |