From d88718ee027e329565d2d97c5cadde4aa1b83166 Mon Sep 17 00:00:00 2001 From: Mavridis Philippe Date: Sun, 9 Jun 2024 22:04:25 +0300 Subject: 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 --- ksmserver/server.cpp | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) (limited to 'ksmserver/server.cpp') 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 -- cgit v1.2.3