summaryrefslogtreecommitdiffstats
path: root/ksmserver/server.cpp
diff options
context:
space:
mode:
authorMavridis Philippe <mavridisf@gmail.com>2024-06-09 22:04:25 +0300
committerMavridis Philippe <mavridisf@gmail.com>2024-08-01 13:02:12 +0300
commitdb3f842c545ce838e40a50e8025268c833c9fc57 (patch)
tree2767fd9b56d84928b6c3f946cf8953f44e1159f4 /ksmserver/server.cpp
parent18d7e66404ccf8c4dcfb1c5f07103e258b576e7e (diff)
downloadtdebase-db3f842c545ce838e40a50e8025268c833c9fc57.tar.gz
tdebase-db3f842c545ce838e40a50e8025268c833c9fc57.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 <mavridisf@gmail.com> (cherry picked from commit d88718ee027e329565d2d97c5cadde4aa1b83166)
Diffstat (limited to 'ksmserver/server.cpp')
-rw-r--r--ksmserver/server.cpp35
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