diff options
author | Michele Calgaro <michele.calgaro@yahoo.it> | 2016-05-02 23:34:35 +1000 |
---|---|---|
committer | Michele Calgaro <michele.calgaro@yahoo.it> | 2016-05-02 23:34:35 +1000 |
commit | 92394e2850e50efa0f3334ef3526421befe33072 (patch) | |
tree | c166efd9d3b0a5828b6afe555c57952e90e34a1b /tdecore | |
parent | a29712773b22aee0b5fefb3cc4b87499baa8db01 (diff) | |
download | tdelibs-92394e2850e50efa0f3334ef3526421befe33072.tar.gz tdelibs-92394e2850e50efa0f3334ef3526421befe33072.zip |
tdecore: Improved code for hybrid suspend (aka suspend to RAM + suspend to disk).
Now code is more consistent. This relates to bug 2601.
Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it>
Diffstat (limited to 'tdecore')
-rw-r--r-- | tdecore/tdehw/tdehardwaredevices.cpp | 28 | ||||
-rw-r--r-- | tdecore/tdehw/tderootsystemdevice.cpp | 6 | ||||
-rw-r--r-- | tdecore/tdehw/tderootsystemdevice.h | 3 |
3 files changed, 25 insertions, 12 deletions
diff --git a/tdecore/tdehw/tdehardwaredevices.cpp b/tdecore/tdehw/tdehardwaredevices.cpp index e2a935e61..e9c7daff1 100644 --- a/tdecore/tdehw/tdehardwaredevices.cpp +++ b/tdecore/tdehw/tdehardwaredevices.cpp @@ -3325,6 +3325,10 @@ void TDEHardwareDevices::updateExistingDeviceInformation(TDEGenericDevice* exist if (dirlist) { TQFileInfoListIterator valuesdirit(*dirlist); TQFileInfo *dirfi; + TDESystemPowerStateList powerstates; + TDESystemHibernationMethodList hibernationmethods; + TDESystemHibernationMethod::TDESystemHibernationMethod hibernationmethod = + TDESystemHibernationMethod::Unsupported; while ( (dirfi = valuesdirit.current()) != 0 ) { nodename = dirfi->fileName(); TQFile file( valuesnodename + nodename ); @@ -3333,7 +3337,6 @@ void TDEHardwareDevices::updateExistingDeviceInformation(TDEGenericDevice* exist TQString line; line = stream.readLine(); if (nodename == "state") { - TDESystemPowerStateList powerstates; // Always assume that these two fully on/fully off states are available powerstates.append(TDESystemPowerState::Active); powerstates.append(TDESystemPowerState::PowerOff); @@ -3347,13 +3350,11 @@ void TDEHardwareDevices::updateExistingDeviceInformation(TDEGenericDevice* exist powerstates.append(TDESystemPowerState::Suspend); } if (line.contains("disk")) { - powerstates.append(TDESystemPowerState::Hibernate); + powerstates.append(TDESystemPowerState::Disk); } - rdevice->internalSetPowerStates(powerstates); } if (nodename == "disk") { // Get list of available hibernation methods - TDESystemHibernationMethodList hibernationmethods; if (line.contains("platform")) { hibernationmethods.append(TDESystemHibernationMethod::Platform); } @@ -3372,12 +3373,10 @@ void TDEHardwareDevices::updateExistingDeviceInformation(TDEGenericDevice* exist if (line.contains("test")) { hibernationmethods.append(TDESystemHibernationMethod::Test); } - rdevice->internalSetHibernationMethods(hibernationmethods); // Get current hibernation method line.truncate(line.findRev("]")); line.remove(0, line.findRev("[")+1); - TDESystemHibernationMethod::TDESystemHibernationMethod hibernationmethod = TDESystemHibernationMethod::Unsupported; if (line.contains("platform")) { hibernationmethod = TDESystemHibernationMethod::Platform; } @@ -3396,7 +3395,6 @@ void TDEHardwareDevices::updateExistingDeviceInformation(TDEGenericDevice* exist if (line.contains("test")) { hibernationmethod = TDESystemHibernationMethod::Test; } - rdevice->internalSetHibernationMethod(hibernationmethod); } if (nodename == "image_size") { rdevice->internalSetDiskSpaceNeededForHibernation(line.toULong()); @@ -3405,6 +3403,22 @@ void TDEHardwareDevices::updateExistingDeviceInformation(TDEGenericDevice* exist } ++valuesdirit; } + // Hibernation and Hybrid Suspend are not real power states, being just two different + // ways of suspending to disk. Since they are very common and it is very convenient to + // treat them as power states, we do so, as other power frameworks also do. + if (powerstates.contains(TDESystemPowerState::Disk) && + hibernationmethods.contains(TDESystemHibernationMethod::Platform)) { + powerstates.append(TDESystemPowerState::Hibernate); + } + if (powerstates.contains(TDESystemPowerState::Disk) && + hibernationmethods.contains(TDESystemHibernationMethod::Suspend)) { + powerstates.append(TDESystemPowerState::HybridSuspend); + } + powerstates.remove(TDESystemPowerState::Disk); + // Set power states and hibernation methods + rdevice->internalSetPowerStates(powerstates); + rdevice->internalSetHibernationMethods(hibernationmethods); + rdevice->internalSetHibernationMethod(hibernationmethod); } } diff --git a/tdecore/tdehw/tderootsystemdevice.cpp b/tdecore/tdehw/tderootsystemdevice.cpp index 7ced4a279..37154126f 100644 --- a/tdecore/tdehw/tderootsystemdevice.cpp +++ b/tdecore/tdehw/tderootsystemdevice.cpp @@ -300,8 +300,7 @@ bool TDERootSystemDevice::canHibernate() { int state_rval = access (statenode.ascii(), W_OK); int disk_rval = access (disknode.ascii(), W_OK); if (state_rval == 0 && disk_rval == 0) { - if (powerStates().contains(TDESystemPowerState::Hibernate) && - hibernationMethods().contains(TDESystemHibernationMethod::Platform)) { + if (powerStates().contains(TDESystemPowerState::Hibernate)) { return TRUE; } else { @@ -416,8 +415,7 @@ bool TDERootSystemDevice::canHybridSuspend() { int state_rval = access (statenode.ascii(), W_OK); int disk_rval = access (disknode.ascii(), W_OK); if (state_rval == 0 && disk_rval == 0) { - if (powerStates().contains(TDESystemPowerState::Hibernate) && - hibernationMethods().contains(TDESystemHibernationMethod::Suspend)) { + if (powerStates().contains(TDESystemPowerState::HybridSuspend)) { return TRUE; } else { diff --git a/tdecore/tdehw/tderootsystemdevice.h b/tdecore/tdehw/tderootsystemdevice.h index a28ff62a1..2e866e65d 100644 --- a/tdecore/tdehw/tderootsystemdevice.h +++ b/tdecore/tdehw/tderootsystemdevice.h @@ -42,7 +42,8 @@ enum TDESystemPowerState { Hibernate, PowerOff, Reboot, - HybridSuspend + HybridSuspend, + Disk // Used temporarily to detect hibernation and hybrid suspend capability }; }; |