summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichele Calgaro <michele.calgaro@yahoo.it>2016-05-07 04:03:59 +1000
committerMichele Calgaro <michele.calgaro@yahoo.it>2016-05-07 04:03:59 +1000
commita3caab905b3c008aaa0ff9627c6647615330205d (patch)
tree36800621beebc1279d89a5cc3d0daef59522058a
parent676fba0b9f08d41e68b115bc91931b5d0aa53376 (diff)
downloadtdepowersave-a3caab905b3c008aaa0ff9627c6647615330205d.tar.gz
tdepowersave-a3caab905b3c008aaa0ff9627c6647615330205d.zip
Added support for hybrid suspend (aka suspend to RAM + suspend to disk).
This relates to bug 2601. Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it>
-rw-r--r--src/config/tdepowersaverc_default4
-rw-r--r--src/configuredialog.cpp19
-rw-r--r--src/countdowndialog.cpp2
-rw-r--r--src/eventsrc12
-rw-r--r--src/hardware.cpp50
-rw-r--r--src/hardware.h12
-rw-r--r--src/settings.cpp8
-rw-r--r--src/settings.h3
-rw-r--r--src/suspenddialog.cpp4
-rw-r--r--src/tdepowersave.cpp152
-rw-r--r--src/tdepowersave.h7
11 files changed, 233 insertions, 40 deletions
diff --git a/src/config/tdepowersaverc_default b/src/config/tdepowersaverc_default
index 7f230af..df291b0 100644
--- a/src/config/tdepowersaverc_default
+++ b/src/config/tdepowersaverc_default
@@ -7,7 +7,7 @@ ActionOnPowerButton=SHUTDOWN
ActionOnPowerButtonValue=
ActionOnSleepButton=SUSPEND2RAM
ActionOnS2DiskButton=SUSPEND2DISK
-buttonsAllowedActions=SHUTDOWN,LOGOUT_DIALOG,SUSPEND2DISK,SUSPEND2RAM,FREEZE
+buttonsAllowedActions=LOGOUT_DIALOG,FREEZE,SUSPEND2RAM,SUSPEND2DISK,SUSPEND_HYBRID,SHUTDOWN
AutoSuspendCountdown=true
AutoSuspendCountdownTimeOut=30
Autostart=true
@@ -32,7 +32,7 @@ batteryLowActionValue=1
batteryCritical=2
batteryCriticalAction=SHUTDOWN
batteryCriticalActionValue=
-batteryAllowedActions=SHUTDOWN,SUSPEND2DISK,SUSPEND2RAM,FREEZE,CPUFREQ_POWERSAVE,CPUFREQ_PERFORMANCE,CPUFREQ_DYNAMIC,BRIGHTNESS
+batteryAllowedActions=FREEZE,SUSPEND2RAM,SUSPEND2DISK,SUSPEND_HYBRID,SHUTDOWN,CPUFREQ_POWERSAVE,CPUFREQ_PERFORMANCE,CPUFREQ_DYNAMIC,BRIGHTNESS
[default-scheme]
specSsSettings=false
diff --git a/src/configuredialog.cpp b/src/configuredialog.cpp
index a6763ec..384a9c9 100644
--- a/src/configuredialog.cpp
+++ b/src/configuredialog.cpp
@@ -88,17 +88,20 @@ ConfigureDialog::ConfigureDialog( TDEConfig *_config, HardwareInfo *_hwinfo, Set
// get the correct available suspend types
SuspendStates suspend = hwinfo->getSuspendSupport();
+ if ( suspend.freeze && (suspend.freeze_allowed || suspend.freeze_allowed == -1)) {
+ actions.append("Freeze");
+ }
+ if ( suspend.standby && (suspend.standby_allowed || suspend.standby_allowed == -1)) {
+ actions.append("Standby");
+ }
if( suspend.suspend2ram && (suspend.suspend2ram_allowed || suspend.suspend2ram_allowed == -1)) {
actions.append("Sleep");
}
if ( suspend.suspend2disk && (suspend.suspend2disk_allowed || suspend.suspend2disk_allowed == -1)) {
actions.append("Hibernate");
}
- if ( suspend.freeze && (suspend.freeze_allowed || suspend.freeze_allowed == -1)) {
- actions.append("Freeze");
- }
- if ( suspend.standby && (suspend.standby_allowed || suspend.standby_allowed == -1)) {
- actions.append("Standby");
+ if ( suspend.suspend_hybrid && (suspend.suspend_hybrid_allowed || suspend.suspend_hybrid_allowed == -1)) {
+ actions.append("Hybrid Suspend");
}
setIcons();
@@ -1800,6 +1803,9 @@ TQString ConfigureDialog::mapActionToDescription( TQString action ) {
} else if (action.startsWith("SUSPEND2DISK")) {
if (actions.contains("Hibernate"))
ret = i18n("Hibernate");
+ } else if (action.startsWith("SUSPEND_HYBRID")) {
+ if (actions.contains("Hybrid Suspend"))
+ ret = i18n("Hybrid Suspend");
} else if (action.startsWith("SUSPEND2RAM")) {
if (actions.contains("Sleep"))
ret = i18n("Sleep");
@@ -1842,6 +1848,9 @@ TQString ConfigureDialog::mapDescriptionToAction( TQString description ) {
} else if (description.startsWith("Hibernate") ||
description.startsWith(i18n("Hibernate"))) {
ret = "SUSPEND2DISK";
+ } else if (description.startsWith("Hybrid Suspend") ||
+ description.startsWith(i18n("Hybrid Suspend"))) {
+ ret = "SUSPEND_HYBRID";
} else if (description.startsWith("Sleep") ||
description.startsWith(i18n("Sleep"))) {
ret = "SUSPEND2RAM";
diff --git a/src/countdowndialog.cpp b/src/countdowndialog.cpp
index 0037100..a745035 100644
--- a/src/countdowndialog.cpp
+++ b/src/countdowndialog.cpp
@@ -76,6 +76,8 @@ void countDownDialog::setPixmap( TQString type )
if(type.startsWith("suspend2disk")){
pixmap = TDEGlobal::iconLoader()->loadIcon("suspend_to_disk", TDEIcon::NoGroup, TDEIcon::SizeLarge);
+ } else if(type.startsWith("suspend_hybrid")){
+ pixmap = TDEGlobal::iconLoader()->loadIcon("suspend_to_disk", TDEIcon::NoGroup, TDEIcon::SizeLarge);
} else if (type.startsWith("suspend2ram")) {
pixmap = TDEGlobal::iconLoader()->loadIcon("suspend_to_ram", TDEIcon::NoGroup, TDEIcon::SizeLarge);
} else if (type.startsWith("freeze")) {
diff --git a/src/eventsrc b/src/eventsrc
index fe33525..7bb8f47 100644
--- a/src/eventsrc
+++ b/src/eventsrc
@@ -234,6 +234,12 @@ Comment[zh_CN]=启动暂挂到磁盘
Comment[zh_TW]=已啟動「暫停寫入到磁碟」
default_presentation=0
+[suspend_hybrid_event]
+Name=HybridSuspendEvent
+Comment=Hybrid Suspend is started
+Comment[it]=Sospensione ibrida avviata
+default_presentation=0
+
[suspend2ram_event]
Name=SuspendToRamEvent
Comment=Sleep mode is started
@@ -291,6 +297,12 @@ Comment[zh_CN]=已从暂挂到磁盘恢复
Comment[zh_TW]=從「暫停寫入到磁碟」繼續
default_presentation=0
+[resume_from_suspend_hybrid_event]
+Name=ResumeFromHybridSuspendEvent
+Comment=Resumed from Hybrid Suspend
+Comment[it]=Ripristinato da Sospensione ibrida
+default_presentation=0
+
[resume_from_suspend2ram_event]
Name=ResumeFromSuspendToRamEvent
Comment=Resumed from Sleep mode
diff --git a/src/hardware.cpp b/src/hardware.cpp
index 7b1c215..54d5027 100644
--- a/src/hardware.cpp
+++ b/src/hardware.cpp
@@ -390,6 +390,9 @@ void HardwareInfo::checkSuspend() {
suspend_states.standby = false;
suspend_states.standby_can = false;
suspend_states.standby_allowed = -1;
+ suspend_states.suspend_hybrid = false;
+ suspend_states.suspend_hybrid_can = false;
+ suspend_states.suspend_hybrid_allowed = -1;
TDERootSystemDevice* rdevice = m_hwdevices->rootSystemDevice();
TDESystemPowerStateList powerStates = rdevice->powerStates();
@@ -399,27 +402,32 @@ void HardwareInfo::checkSuspend() {
if ((*it) == TDESystemPowerState::Active) {
//
}
- if ((*it) == TDESystemPowerState::Standby) {
+ else if ((*it) == TDESystemPowerState::Standby) {
suspend_states.standby = true;
suspend_states.standby_allowed = rdevice->canStandby();
- suspend_states.standby_can = suspend_states.standby_allowed & suspend_states.standby;
+ suspend_states.standby_can = suspend_states.standby_allowed && suspend_states.standby;
}
- if ((*it) == TDESystemPowerState::Freeze) {
+ else if ((*it) == TDESystemPowerState::Freeze) {
suspend_states.freeze = true;
suspend_states.freeze_allowed = rdevice->canFreeze();
- suspend_states.freeze_can = suspend_states.freeze_allowed & suspend_states.freeze;
+ suspend_states.freeze_can = suspend_states.freeze_allowed && suspend_states.freeze;
}
- if ((*it) == TDESystemPowerState::Suspend) {
+ else if ((*it) == TDESystemPowerState::Suspend) {
suspend_states.suspend2ram = true;
suspend_states.suspend2ram_allowed = rdevice->canSuspend();
- suspend_states.suspend2ram_can = suspend_states.suspend2ram_allowed & suspend_states.suspend2ram;
+ suspend_states.suspend2ram_can = suspend_states.suspend2ram_allowed && suspend_states.suspend2ram;
}
- if ((*it) == TDESystemPowerState::Hibernate) {
+ else if ((*it) == TDESystemPowerState::Hibernate) {
suspend_states.suspend2disk = true;
suspend_states.suspend2disk_allowed = rdevice->canHibernate();
- suspend_states.suspend2disk_can = suspend_states.suspend2disk_allowed & suspend_states.suspend2disk;
+ suspend_states.suspend2disk_can = suspend_states.suspend2disk_allowed && suspend_states.suspend2disk;
}
- if ((*it) == TDESystemPowerState::PowerOff) {
+ else if ((*it) == TDESystemPowerState::HybridSuspend) {
+ suspend_states.suspend_hybrid = true;
+ suspend_states.suspend_hybrid_allowed = rdevice->canHybridSuspend();
+ suspend_states.suspend_hybrid_can = suspend_states.suspend_hybrid_allowed && suspend_states.suspend_hybrid;
+ }
+ else if ((*it) == TDESystemPowerState::PowerOff) {
//
}
}
@@ -801,6 +809,27 @@ bool HardwareInfo::suspend( suspend_type suspend ) {
return false;
}
break;
+
+ case SUSPEND_HYBRID:
+ if (suspend_states.suspend_hybrid && (suspend_states.suspend_hybrid_allowed != 0)) {
+ if (rdevice->setPowerState(TDESystemPowerState::HybridSuspend)) {
+ calledSuspend.start();
+ handleResumeSignal(0);
+ return true;
+ } else {
+ handleResumeSignal(-1);
+ return false;
+ }
+ } else {
+ if ( !suspend_states.suspend_hybrid )
+ kdDebug() << "The machine does not support hybrid suspension." << endl;
+ else
+ kdWarning() << "Policy forbid user to trigger hybrid suspension" << endl;
+
+ return false;
+ }
+ break;
+
case SUSPEND2RAM:
if (suspend_states.suspend2ram && (suspend_states.suspend2ram_allowed != 0)) {
if (rdevice->setPowerState(TDESystemPowerState::Suspend)) {
@@ -820,6 +849,7 @@ bool HardwareInfo::suspend( suspend_type suspend ) {
return false;
}
break;
+
case FREEZE:
if (suspend_states.freeze && (suspend_states.freeze_allowed != 0)) {
if (rdevice->setPowerState(TDESystemPowerState::Freeze)) {
@@ -839,6 +869,7 @@ bool HardwareInfo::suspend( suspend_type suspend ) {
return false;
}
break;
+
case STANDBY:
if (suspend_states.standby && (suspend_states.standby_allowed != 0)) {
if (rdevice->setPowerState(TDESystemPowerState::Standby)) {
@@ -858,6 +889,7 @@ bool HardwareInfo::suspend( suspend_type suspend ) {
return false;
}
break;
+
default:
return false;
}
diff --git a/src/hardware.h b/src/hardware.h
index b173aa5..d6120b6 100644
--- a/src/hardware.h
+++ b/src/hardware.h
@@ -56,7 +56,8 @@ enum suspend_type {
SUSPEND2DISK,
SUSPEND2RAM,
FREEZE,
- STANDBY
+ STANDBY,
+ SUSPEND_HYBRID,
};
enum cpufreq_type {
@@ -106,6 +107,12 @@ typedef struct SuspendStates {
bool standby_can;
//! true if the machine support standby and PolicyKit allow to call the interface
int standby_allowed;
+ //! true if the machine support hybrid suspend and the interface is available
+ bool suspend_hybrid;
+ //! true if the machine support hybrid suspend, but no interface available
+ bool suspend_hybrid_can;
+ //! true if the machine support hybrid suspend and PolicyKit allow to call the interface
+ int suspend_hybrid_allowed;
SuspendStates () {
suspend2ram = false;
@@ -120,6 +127,9 @@ typedef struct SuspendStates {
standby = false;
standby_can = false;
standby_allowed = -1;
+ suspend_hybrid = false;
+ suspend_hybrid_can = false;
+ suspend_hybrid_allowed = -1;
}
} SuspendStates;
diff --git a/src/settings.cpp b/src/settings.cpp
index 4fc92a1..d7b549a 100644
--- a/src/settings.cpp
+++ b/src/settings.cpp
@@ -297,12 +297,14 @@ bool Settings::load_general_settings(){
}
sleepButtonAction = mapActionToType(tdeconfig->readEntry("ActionOnSleepButton",""));
- if ((sleepButtonAction != GO_SUSPEND2RAM) && (sleepButtonAction != GO_SUSPEND2DISK) && (sleepButtonAction != GO_FREEZE)) {
+ if ((sleepButtonAction != GO_SUSPEND2RAM) && (sleepButtonAction != GO_SUSPEND2DISK) &&
+ (sleepButtonAction != GO_FREEZE) && (sleepButtonAction != GO_SUSPEND_HYBRID)) {
sleepButtonAction = NONE;
}
s2diskButtonAction = mapActionToType(tdeconfig->readEntry("ActionOnS2DiskButton",""));
- if ((s2diskButtonAction != GO_SUSPEND2RAM) && (s2diskButtonAction != GO_SUSPEND2DISK) && (s2diskButtonAction != GO_FREEZE)) {
+ if ((s2diskButtonAction != GO_SUSPEND2RAM) && (s2diskButtonAction != GO_SUSPEND2DISK) &&
+ (s2diskButtonAction != GO_FREEZE) && (s2diskButtonAction != GO_SUSPEND_HYBRID)) {
s2diskButtonAction = NONE;
}
@@ -327,6 +329,8 @@ action Settings::mapActionToType (TQString _action) {
return LOGOUT_DIALOG;
} else if (_action.startsWith("SUSPEND2DISK")) {
return GO_SUSPEND2DISK;
+ } else if (_action.startsWith("SUSPEND_HYBRID")) {
+ return GO_SUSPEND_HYBRID;
} else if (_action.startsWith("SUSPEND2RAM")) {
return GO_SUSPEND2RAM;
} else if (_action.startsWith("FREEZE")) {
diff --git a/src/settings.h b/src/settings.h
index b38cb2a..c1044be 100644
--- a/src/settings.h
+++ b/src/settings.h
@@ -47,7 +47,8 @@ enum action{
BRIGHTNESS,
CPUFREQ_POWERSAVE,
CPUFREQ_DYNAMIC,
- CPUFREQ_PERFORMANCE
+ CPUFREQ_PERFORMANCE,
+ GO_SUSPEND_HYBRID
};
/*!
diff --git a/src/suspenddialog.cpp b/src/suspenddialog.cpp
index 5431938..cdd82c0 100644
--- a/src/suspenddialog.cpp
+++ b/src/suspenddialog.cpp
@@ -58,7 +58,9 @@ suspendDialog::~suspendDialog()
void suspendDialog::setPixmap( TQString type )
{
TQPixmap pixmap = 0;
- if(type.startsWith("suspend2disk")){// || type.startsWith("NULL")) {
+ if(type.startsWith("suspend2disk")){
+ pixmap = TDEGlobal::iconLoader()->loadIcon("suspend_to_disk", TDEIcon::NoGroup, TDEIcon::SizeLarge);
+ } else if(type.startsWith("suspend_hybrid")){
pixmap = TDEGlobal::iconLoader()->loadIcon("suspend_to_disk", TDEIcon::NoGroup, TDEIcon::SizeLarge);
} else if (type.startsWith("suspend2ram")) {
pixmap = TDEGlobal::iconLoader()->loadIcon("suspend_to_ram", TDEIcon::NoGroup, TDEIcon::SizeLarge);
diff --git a/src/tdepowersave.cpp b/src/tdepowersave.cpp
index d214a3b..e6d6e53 100644
--- a/src/tdepowersave.cpp
+++ b/src/tdepowersave.cpp
@@ -74,12 +74,12 @@ tdepowersave::tdepowersave( bool force_acpi_check, bool trace_func ) : KSystemTr
config->writeEntry("AlreadyStarted", true);
// check whether APM, ACPI, PMU, CPUFreq or Suspend2Disk/ram supported, otherwise end up
// and don't start tdepowersave ever again until force_acpi_check == true.
- if (!hwinfo->hasACPI() && !hwinfo->hasAPM() && !hwinfo->hasPMU() &&
- !hwinfo->supportCPUFreq() && !suspend.suspend2disk && !suspend.suspend2ram){
+ if (!hwinfo->hasACPI() && !hwinfo->hasAPM() && !hwinfo->hasPMU() && !hwinfo->supportCPUFreq() &&
+ !suspend.suspend2disk && !suspend.suspend2ram && !suspend.suspend_hybrid) {
config->writeEntry("Autostart", false);
config->sync();
- kdError() << "This machine does not support ACPI, APM, PMU, CPUFreq, Suspend2Disk nor "
- << "Suspend2RAM. Please close tdepowersave now." << endl;
+ kdError() << "This machine does not support ACPI, APM, PMU, CPUFreq, Suspend2Disk, "
+ << "Suspend2RAM nor Hybrid Suspend. Please close tdepowersave now." << endl;
exit(-1);
}
}
@@ -186,18 +186,16 @@ void tdepowersave::initMenu() {
#endif
SLEEP_SEPARATOR_MENU_ID = this->contextMenu()->insertSeparator();
- SUSPEND2DISK_MENU_ID = this->contextMenu()->insertItem( SmallIconSet("suspend_to_disk",
- TQIconSet::Automatic),
- i18n("Hibernate"), this,
- TQT_SLOT(do_suspend2disk()));
- SUSPEND2RAM_MENU_ID = this->contextMenu()->insertItem( SmallIconSet("suspend_to_ram",
- TQIconSet::Automatic),
- i18n("Sleep"), this,
- TQT_SLOT(do_suspend2ram()));
FREEZE_MENU_ID = this->contextMenu()->insertItem( SmallIconSet("suspend_to_ram", TQIconSet::Automatic),
i18n("Freeze"), this, TQT_SLOT(do_freeze()));
STANDBY_MENU_ID = this->contextMenu()->insertItem( SmallIconSet("stand_by", TQIconSet::Automatic),
i18n("Standby"), this, TQT_SLOT(do_standby()));
+ SUSPEND2RAM_MENU_ID = this->contextMenu()->insertItem( SmallIconSet("suspend_to_ram",
+ TQIconSet::Automatic), i18n("Sleep"), this, TQT_SLOT(do_suspend2ram()));
+ SUSPEND2DISK_MENU_ID = this->contextMenu()->insertItem( SmallIconSet("suspend_to_disk",
+ TQIconSet::Automatic), i18n("Hibernate"), this, TQT_SLOT(do_suspend2disk()));
+ SUSPEND_HYBRID_MENU_ID = this->contextMenu()->insertItem( SmallIconSet("suspend_to_disk",
+ TQIconSet::Automatic), i18n("Hybrid Suspend"), this, TQT_SLOT(do_suspend_hybrid()));
speed_menu = new TQPopupMenu(this, i18n("Set CPU Frequency Policy").ascii());
speed_menu->insertItem(i18n("Performance"), PERFORMANCE);
@@ -691,7 +689,7 @@ void tdepowersave::slotConfigProcessExited(TDEProcess *proc){
/*!
* \b TQT_SLOT to send the command for "suspend to disk" to TDE hardware library.
- * If there is a error while "suspend to disk" the user get e messagebox.
+ * If there is a error while "suspend to disk" the user get a messagebox.
* This function need a power management backend in TDE hardware library for "suspend to disk".
* \return boolean with the result of the operation
* \retval true if successful
@@ -746,6 +744,62 @@ bool tdepowersave::do_suspend2disk(){
}
/*!
+ * \b TQT_SLOT to send the command for "hybrid suspend" to TDE hardware library.
+ * If there is a error while "hybrid suspend" the user get a messagebox.
+ * This function need a power management backend in TDE hardware library for "hybrid suspend".
+ * \return boolean with the result of the operation
+ * \retval true if successful
+ * \retval false if command not supported or if powersaved not running
+ */
+bool tdepowersave::do_suspend_hybrid(){
+ kdDebugFuncIn(trace);
+
+ if (suspend.suspend_hybrid) {
+ if (suspend.suspend_hybrid_allowed || suspend.suspend_hybrid_allowed == -1) {
+ calledSuspend = SUSPEND_HYBRID;
+ if (!handleMounts(true)) {
+ kdWarning() << "Could not umount ..." << endl;
+ calledSuspend = -1;
+ kdDebugFuncOut(trace);
+ return false;
+ }
+
+ if(settings->lockOnSuspend) {
+ display->lockScreen( settings->lockmethod );
+ }
+
+ autoSuspend->stop();
+ autoDimm->stop();
+ notifySuspend(calledSuspend);
+ bool ret = hwinfo->suspend(SUSPEND_HYBRID);
+
+ if (ret) {
+ kdDebugFuncOut(trace);
+ return true;
+ } else {
+ KPassivePopup::message( i18n("WARNING"),i18n("Hybrid Suspend failed"),
+ SmallIcon("messagebox_warning", 20), this,
+ i18n("Warning").ascii(), 15000);
+ kdDebugFuncOut(trace);
+ return false;
+ }
+ } else {
+ KPassivePopup::message( i18n("WARNING"),
+ i18n("Hybrid Suspend disabled by administrator."),
+ SmallIcon("messagebox_warning", 20),
+ this, i18n("Warning").ascii(), 15000);
+ this->contextMenu()->setItemEnabled(SUSPEND_HYBRID_MENU_ID, false);
+ kdDebugFuncOut(trace);
+ return false;
+ }
+ } else {
+ kdWarning() << "This machine does not provide hybrid suspend state" << endl;
+ kdDebugFuncOut(trace);
+ return false;
+ }
+}
+
+/*!
* \b TQT_SLOT to send the command for "suspend to RAM" to the TDE hardware library.
* If there is a error while "suspend to RAM" the user get a messagebox.
* This function need a power management backend in TDE hardware library for "suspend to RAM".
@@ -927,6 +981,11 @@ void tdepowersave::do_autosuspendWarn() {
allowed = true;
}
}
+ else if(settings->autoInactiveAction == "Hybrid Suspend") {
+ if ( suspend.suspend_hybrid && (suspend.suspend_hybrid_allowed || suspend.suspend_hybrid_allowed == -1)) {
+ allowed = true;
+ }
+ }
else if (settings->autoInactiveAction == "Sleep") {
if( suspend.suspend2ram && (suspend.suspend2ram_allowed || suspend.suspend2ram_allowed == -1)) {
allowed = true;
@@ -953,6 +1012,8 @@ void tdepowersave::do_autosuspendWarn() {
if(settings->autoInactiveAction == "Hibernate") {
countdown->setPixmap("suspend2disk");
+ } else if(settings->autoInactiveAction == "Hybrid Suspend") {
+ countdown->setPixmap("suspend2disk");
} else if (settings->autoInactiveAction == "Sleep") {
countdown->setPixmap("suspend2ram");
} else if (settings->autoInactiveAction == "Freeze") {
@@ -995,8 +1056,6 @@ void tdepowersave::do_autosuspendWarn() {
*/
bool tdepowersave::do_autosuspend(bool cancel) {
kdDebugFuncIn(trace);
-
- // TODO: check if this is really needed, it get called also on the suspend methodes
autoSuspend->stop();
if (!cancel) {
@@ -1008,6 +1067,8 @@ bool tdepowersave::do_autosuspend(bool cancel) {
if(settings->autoSuspend && !contextMenu()->isItemChecked(AUTOSUSPEND_MENU_ID)) {
if(settings->autoInactiveAction == "Hibernate") {
return do_suspend2disk();
+ } else if(settings->autoInactiveAction == "Hybrid Suspend") {
+ return do_suspend_hybrid();
} else if (settings->autoInactiveAction == "Sleep") {
return do_suspend2ram();
} else if (settings->autoInactiveAction == "Freeze") {
@@ -1456,10 +1517,11 @@ void tdepowersave::update(){
redraw_pixmap = 1;
}
if (!hwinfo->isOnline()){
- this->contextMenu()->setItemVisible(SUSPEND2DISK_MENU_ID, false);
- this->contextMenu()->setItemVisible(SUSPEND2RAM_MENU_ID, false);
this->contextMenu()->setItemVisible(FREEZE_MENU_ID, false);
this->contextMenu()->setItemVisible(STANDBY_MENU_ID, false);
+ this->contextMenu()->setItemVisible(SUSPEND2RAM_MENU_ID, false);
+ this->contextMenu()->setItemVisible(SUSPEND2DISK_MENU_ID, false);
+ this->contextMenu()->setItemVisible(SUSPEND_HYBRID_MENU_ID, false);
this->contextMenu()->setItemVisible(SLEEP_SEPARATOR_MENU_ID, false);
this->contextMenu()->setItemVisible(SCHEME_SEPARATOR_MENU_ID, false);
this->contextMenu()->setItemVisible(SCHEME_MENU_ID, false);
@@ -1479,10 +1541,11 @@ void tdepowersave::update(){
hwinfo->update_info_cpufreq_policy_changed = true;
suspend = hwinfo->getSuspendSupport();
}
- this->contextMenu()->setItemVisible(SUSPEND2DISK_MENU_ID, true);
- this->contextMenu()->setItemVisible(SUSPEND2RAM_MENU_ID, true);
this->contextMenu()->setItemVisible(FREEZE_MENU_ID, true);
this->contextMenu()->setItemVisible(STANDBY_MENU_ID, true);
+ this->contextMenu()->setItemVisible(SUSPEND2RAM_MENU_ID, true);
+ this->contextMenu()->setItemVisible(SUSPEND2DISK_MENU_ID, true);
+ this->contextMenu()->setItemVisible(SUSPEND_HYBRID_MENU_ID, true);
this->contextMenu()->setItemVisible(SLEEP_SEPARATOR_MENU_ID, true);
this->contextMenu()->setItemVisible(SCHEME_SEPARATOR_MENU_ID, true);
this->contextMenu()->setItemVisible(SCHEME_MENU_ID, true);
@@ -1500,6 +1563,16 @@ void tdepowersave::update(){
this->contextMenu()->setItemEnabled(SUSPEND2DISK_MENU_ID, false);
}
+ if (suspend.suspend_hybrid && (suspend.suspend_hybrid_allowed ||
+ suspend.suspend_hybrid_allowed == -1)) {
+ this->contextMenu()->setItemEnabled(SUSPEND_HYBRID_MENU_ID, true);
+ } else {
+ if (!suspend.suspend_hybrid)
+ this->contextMenu()->setItemVisible(SUSPEND_HYBRID_MENU_ID, false);
+ else
+ this->contextMenu()->setItemEnabled(SUSPEND_HYBRID_MENU_ID, false);
+ }
+
if (suspend.suspend2ram && (suspend.suspend2ram_allowed ||
suspend.suspend2ram_allowed == -1)) {
this->contextMenu()->setItemEnabled(SUSPEND2RAM_MENU_ID, true);
@@ -1907,6 +1980,11 @@ void tdepowersave::setAutoSuspend( bool resumed ){
allowed = true;
}
}
+ else if(settings->autoInactiveAction == "Hybrid Suspend") {
+ if ( suspend.suspend_hybrid && (suspend.suspend_hybrid_allowed || suspend.suspend_hybrid_allowed == -1)) {
+ allowed = true;
+ }
+ }
else if (settings->autoInactiveAction == "Sleep") {
if( suspend.suspend2ram && (suspend.suspend2ram_allowed || suspend.suspend2ram_allowed == -1)) {
allowed = true;
@@ -2148,6 +2226,9 @@ void tdepowersave::handleActionCall ( action action, int value , bool checkAC, b
case GO_SUSPEND2DISK:
TQTimer::singleShot(100, this, TQT_SLOT(do_suspend2disk()));
break;
+ case GO_SUSPEND_HYBRID:
+ TQTimer::singleShot(100, this, TQT_SLOT(do_suspend_hybrid()));
+ break;
case GO_FREEZE:
TQTimer::singleShot(100, this, TQT_SLOT(do_freeze()));
break;
@@ -2269,6 +2350,11 @@ void tdepowersave::notifySuspend( int suspendType ) {
i18n("System is going into %1 now.").
arg(i18n("hibernation")));
break;
+ case SUSPEND_HYBRID:
+ KNotifyClient::event( this->winId(), "suspend_hybrid_event",
+ i18n("System is going into %1 now.").
+ arg(i18n("hybrid suspension")));
+ break;
case SUSPEND2RAM:
KNotifyClient::event( this->winId(), "suspend2ram_event",
i18n("System is going into %1 now.").
@@ -2334,6 +2420,11 @@ void tdepowersave::handleResumeSignal() {
i18n("System is resumed from %1.").arg(
i18n("hibernation")));
break;
+ case SUSPEND_HYBRID:
+ KNotifyClient::event( this->winId(), "resume_from_suspend_hybrid_event",
+ i18n("System is resumed from %1.").arg(
+ i18n("hybrid suspension")));
+ break;
case SUSPEND2RAM:
KNotifyClient::event( this->winId(), "resume_from_suspend2ram_event",
i18n("System is resumed from %1.").arg(
@@ -2389,6 +2480,10 @@ void tdepowersave::handleResumeSignal() {
logview = new LogViewer ("/var/log/suspend2disk.log");
logview->show();
break;
+ case SUSPEND_HYBRID:
+ logview = new LogViewer ("/var/log/suspend_hybrid.log");
+ logview->show();
+ break;
case SUSPEND2RAM:
logview = new LogViewer ("/var/log/suspend2ram.log");
logview->show();
@@ -2461,6 +2556,9 @@ TQString tdepowersave::getSuspendString (int type) {
case SUSPEND2DISK:
return i18n("Hibernate");
break;
+ case SUSPEND_HYBRID:
+ return i18n("Hybrid Suspend");
+ break;
case SUSPEND2RAM:
return i18n("Sleep");
break;
@@ -2612,6 +2710,10 @@ TQStringList tdepowersave::allowed_sleepingStates(){
suspend.suspend2disk_allowed == -1)){
sleepList.append("suspendToDisk");
}
+ if (suspend.suspend_hybrid && (suspend.suspend_hybrid_allowed ||
+ suspend.suspend_hybrid_allowed == -1)){
+ sleepList.append("suspendHybrid");
+ }
if (suspend.suspend2ram && (suspend.suspend2ram_allowed ||
suspend.suspend2ram_allowed == -1)){
sleepList.append("suspendToRAM");
@@ -2697,6 +2799,18 @@ bool tdepowersave::do_suspendToDisk(){
}
/*!
+ * DCOP Interface funtion to send the hybrid suspend command to powersave.
+ * \return boolean with the result of calling do_suspend_hybrid()
+ * \retval true if successful
+ * \retval false if not supported or powersaved not running
+ */
+bool tdepowersave::do_suspendHybrid(){
+ kdDebugFuncIn(trace);
+ kdDebugFuncOut(trace);
+ return do_suspend_hybrid();
+}
+
+/*!
* DCOP Interface funtion to send the suspend to disk command to powersave.
* \return boolean with the result of calling do_suspend2ram()
* \retval true if successful
diff --git a/src/tdepowersave.h b/src/tdepowersave.h
index bb46fc0..931fbe5 100644
--- a/src/tdepowersave.h
+++ b/src/tdepowersave.h
@@ -188,6 +188,9 @@ private:
/*! contains the ID of the menuentry for suspend-to-disk */
int SUSPEND2DISK_MENU_ID;
//! a menu entry ID
+ /*! contains the ID of the menuentry for hybrid suspend */
+ int SUSPEND_HYBRID_MENU_ID;
+ //! a menu entry ID
/*! contains the ID of the menuentry for suspend-to-ram */
int SUSPEND2RAM_MENU_ID;
//! a menu entry ID
@@ -322,6 +325,8 @@ private slots:
bool do_suspend2disk();
//! send command for suspend_to_RAM to the TDE hardware library
bool do_suspend2ram();
+ //! send command for hybrid suspend to the TDE hardware library
+ bool do_suspend_hybrid();
//! show warning dialog or call autosuspend if signal \ref inactivity::inactivityTimeExpired() recieved
void do_autosuspendWarn();
@@ -432,6 +437,8 @@ k_dcop:
bool do_setCPUFreqPolicy( TQString );
//! dcop function to send 'suspend to disk' command to powersaved
bool do_suspendToDisk();
+ //! dcop function to send 'hybrid suspend' command to powersaved
+ bool do_suspendHybrid();
//! dcop function to send 'suspend to RAM' command to powersaved
bool do_suspendToRAM();
//! dcop function to send 'freeze' command to powersaved