diff options
author | Mavridis Philippe <[email protected]> | 2024-06-09 22:04:25 +0300 |
---|---|---|
committer | Mavridis Philippe <[email protected]> | 2024-08-01 13:00:28 +0300 |
commit | d88718ee027e329565d2d97c5cadde4aa1b83166 (patch) | |
tree | a4a471e94c5afcf4d5540961c94df707a707bd24 /ksmserver/server.cpp | |
parent | 352d2ee3da00e402c4d362ab90a031df76d617ad (diff) | |
download | tdebase-d88718ee027e329565d2d97c5cadde4aa1b83166.tar.gz tdebase-d88718ee027e329565d2d97c5cadde4aa1b83166.zip |
KSMServer: improve suspend code
1. Some code deduplication. Suspending is now handled via the public method `suspend(int)` which is DCOP-accessible and maps SuspendType values to corresponding TDEHWLib TDESystemPowerState values, and the internal method `suspendInternal(int)` which performs the chosen suspend and optionally locks the screen beforehand.
2. Options are now read from power-managerrc on startup and stored in memory to avoid reading the configuration file every time a suspend is requested.
3. SuspendType is now a member of KSMServer class (instead of KSMShutdownDlg)
4. A new DCOP-accessible method `suspendOptions()` returns a TQStringList of all available suspend options.
Signed-off-by: Mavridis Philippe <[email protected]>
Diffstat (limited to 'ksmserver/server.cpp')
-rw-r--r-- | ksmserver/server.cpp | 35 |
1 files changed, 34 insertions, 1 deletions
diff --git a/ksmserver/server.cpp b/ksmserver/server.cpp index be5ed0bcc..2cfb2e671 100644 --- a/ksmserver/server.cpp +++ b/ksmserver/server.cpp @@ -689,6 +689,8 @@ KSMServer::KSMServer( const TQString& windowManager, const TQString& windowManag connect( &restoreTimer, TQ_SIGNAL( timeout() ), this, TQ_SLOT( tryRestoreNext() ) ); connect( &shutdownTimer, TQ_SIGNAL( timeout() ), this, TQ_SLOT( timeoutQuit() ) ); connect( kapp, TQ_SIGNAL( shutDown() ), this, TQ_SLOT( cleanUp() ) ); + + reconfigure(); } KSMServer::~KSMServer() @@ -697,6 +699,16 @@ KSMServer::~KSMServer() cleanUp(); } +void KSMServer::reconfigure() +{ + // respect lock on resume & disable suspend/hibernate settings + // from power-manager + TDEConfig cfg("power-managerrc"); + m_disableSuspend = cfg.readBoolEntry("disableSuspend", false); + m_disableHibernate = cfg.readBoolEntry("disableHibernate", false); + m_lockOnResume = cfg.readBoolEntry("lockOnResume", true); +} + void KSMServer::cleanUp() { if (clean) return; @@ -919,6 +931,27 @@ void KSMServer::storeSession() config->sync(); } +TQStringList KSMServer::suspendOptions() +{ + TQStringList sopt; + +#ifdef WITH_TDEHWLIB + TDERootSystemDevice* rootDevice = hwDevices->rootSystemDevice(); + if (rootDevice->canFreeze() && !m_disableSuspend) + sopt << "freeze"; + + if (rootDevice->canSuspend() && !m_disableSuspend) + sopt << "suspend"; + + if (rootDevice->canHibernate() && !m_disableHibernate) + sopt << "hibernate"; + + if (rootDevice->canHybridSuspend() && !m_disableSuspend && !m_disableHibernate) + sopt << "hybridSuspend"; +#endif + + return sopt; +} TQStringList KSMServer::sessionList() { @@ -995,4 +1028,4 @@ bool KSMServer::defaultSession() const bool KSMServer::startupCompleted() { return m_startupCompleted; -} +}
\ No newline at end of file |