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>
pull/1/head
Michele Calgaro 8 years ago
parent 676fba0b9f
commit a3caab905b

@ -7,7 +7,7 @@ ActionOnPowerButton=SHUTDOWN
ActionOnPowerButtonValue= ActionOnPowerButtonValue=
ActionOnSleepButton=SUSPEND2RAM ActionOnSleepButton=SUSPEND2RAM
ActionOnS2DiskButton=SUSPEND2DISK ActionOnS2DiskButton=SUSPEND2DISK
buttonsAllowedActions=SHUTDOWN,LOGOUT_DIALOG,SUSPEND2DISK,SUSPEND2RAM,FREEZE buttonsAllowedActions=LOGOUT_DIALOG,FREEZE,SUSPEND2RAM,SUSPEND2DISK,SUSPEND_HYBRID,SHUTDOWN
AutoSuspendCountdown=true AutoSuspendCountdown=true
AutoSuspendCountdownTimeOut=30 AutoSuspendCountdownTimeOut=30
Autostart=true Autostart=true
@ -32,7 +32,7 @@ batteryLowActionValue=1
batteryCritical=2 batteryCritical=2
batteryCriticalAction=SHUTDOWN batteryCriticalAction=SHUTDOWN
batteryCriticalActionValue= 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] [default-scheme]
specSsSettings=false specSsSettings=false

@ -88,17 +88,20 @@ ConfigureDialog::ConfigureDialog( TDEConfig *_config, HardwareInfo *_hwinfo, Set
// get the correct available suspend types // get the correct available suspend types
SuspendStates suspend = hwinfo->getSuspendSupport(); 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)) { if( suspend.suspend2ram && (suspend.suspend2ram_allowed || suspend.suspend2ram_allowed == -1)) {
actions.append("Sleep"); actions.append("Sleep");
} }
if ( suspend.suspend2disk && (suspend.suspend2disk_allowed || suspend.suspend2disk_allowed == -1)) { if ( suspend.suspend2disk && (suspend.suspend2disk_allowed || suspend.suspend2disk_allowed == -1)) {
actions.append("Hibernate"); actions.append("Hibernate");
} }
if ( suspend.freeze && (suspend.freeze_allowed || suspend.freeze_allowed == -1)) { if ( suspend.suspend_hybrid && (suspend.suspend_hybrid_allowed || suspend.suspend_hybrid_allowed == -1)) {
actions.append("Freeze"); actions.append("Hybrid Suspend");
}
if ( suspend.standby && (suspend.standby_allowed || suspend.standby_allowed == -1)) {
actions.append("Standby");
} }
setIcons(); setIcons();
@ -1800,6 +1803,9 @@ TQString ConfigureDialog::mapActionToDescription( TQString action ) {
} else if (action.startsWith("SUSPEND2DISK")) { } else if (action.startsWith("SUSPEND2DISK")) {
if (actions.contains("Hibernate")) if (actions.contains("Hibernate"))
ret = i18n("Hibernate"); ret = i18n("Hibernate");
} else if (action.startsWith("SUSPEND_HYBRID")) {
if (actions.contains("Hybrid Suspend"))
ret = i18n("Hybrid Suspend");
} else if (action.startsWith("SUSPEND2RAM")) { } else if (action.startsWith("SUSPEND2RAM")) {
if (actions.contains("Sleep")) if (actions.contains("Sleep"))
ret = i18n("Sleep"); ret = i18n("Sleep");
@ -1842,6 +1848,9 @@ TQString ConfigureDialog::mapDescriptionToAction( TQString description ) {
} else if (description.startsWith("Hibernate") || } else if (description.startsWith("Hibernate") ||
description.startsWith(i18n("Hibernate"))) { description.startsWith(i18n("Hibernate"))) {
ret = "SUSPEND2DISK"; ret = "SUSPEND2DISK";
} else if (description.startsWith("Hybrid Suspend") ||
description.startsWith(i18n("Hybrid Suspend"))) {
ret = "SUSPEND_HYBRID";
} else if (description.startsWith("Sleep") || } else if (description.startsWith("Sleep") ||
description.startsWith(i18n("Sleep"))) { description.startsWith(i18n("Sleep"))) {
ret = "SUSPEND2RAM"; ret = "SUSPEND2RAM";

@ -76,6 +76,8 @@ void countDownDialog::setPixmap( TQString type )
if(type.startsWith("suspend2disk")){ if(type.startsWith("suspend2disk")){
pixmap = TDEGlobal::iconLoader()->loadIcon("suspend_to_disk", TDEIcon::NoGroup, TDEIcon::SizeLarge); 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")) { } else if (type.startsWith("suspend2ram")) {
pixmap = TDEGlobal::iconLoader()->loadIcon("suspend_to_ram", TDEIcon::NoGroup, TDEIcon::SizeLarge); pixmap = TDEGlobal::iconLoader()->loadIcon("suspend_to_ram", TDEIcon::NoGroup, TDEIcon::SizeLarge);
} else if (type.startsWith("freeze")) { } else if (type.startsWith("freeze")) {

@ -234,6 +234,12 @@ Comment[zh_CN]=启动暂挂到磁盘
Comment[zh_TW]=已啟動「暫停寫入到磁碟」 Comment[zh_TW]=已啟動「暫停寫入到磁碟」
default_presentation=0 default_presentation=0
[suspend_hybrid_event]
Name=HybridSuspendEvent
Comment=Hybrid Suspend is started
Comment[it]=Sospensione ibrida avviata
default_presentation=0
[suspend2ram_event] [suspend2ram_event]
Name=SuspendToRamEvent Name=SuspendToRamEvent
Comment=Sleep mode is started Comment=Sleep mode is started
@ -291,6 +297,12 @@ Comment[zh_CN]=已从暂挂到磁盘恢复
Comment[zh_TW]=從「暫停寫入到磁碟」繼續 Comment[zh_TW]=從「暫停寫入到磁碟」繼續
default_presentation=0 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] [resume_from_suspend2ram_event]
Name=ResumeFromSuspendToRamEvent Name=ResumeFromSuspendToRamEvent
Comment=Resumed from Sleep mode Comment=Resumed from Sleep mode

@ -390,6 +390,9 @@ void HardwareInfo::checkSuspend() {
suspend_states.standby = false; suspend_states.standby = false;
suspend_states.standby_can = false; suspend_states.standby_can = false;
suspend_states.standby_allowed = -1; 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(); TDERootSystemDevice* rdevice = m_hwdevices->rootSystemDevice();
TDESystemPowerStateList powerStates = rdevice->powerStates(); TDESystemPowerStateList powerStates = rdevice->powerStates();
@ -399,27 +402,32 @@ void HardwareInfo::checkSuspend() {
if ((*it) == TDESystemPowerState::Active) { if ((*it) == TDESystemPowerState::Active) {
// //
} }
if ((*it) == TDESystemPowerState::Standby) { else if ((*it) == TDESystemPowerState::Standby) {
suspend_states.standby = true; suspend_states.standby = true;
suspend_states.standby_allowed = rdevice->canStandby(); 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 = true;
suspend_states.freeze_allowed = rdevice->canFreeze(); 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 = true;
suspend_states.suspend2ram_allowed = rdevice->canSuspend(); 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 = true;
suspend_states.suspend2disk_allowed = rdevice->canHibernate(); 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; return false;
} }
break; 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: case SUSPEND2RAM:
if (suspend_states.suspend2ram && (suspend_states.suspend2ram_allowed != 0)) { if (suspend_states.suspend2ram && (suspend_states.suspend2ram_allowed != 0)) {
if (rdevice->setPowerState(TDESystemPowerState::Suspend)) { if (rdevice->setPowerState(TDESystemPowerState::Suspend)) {
@ -820,6 +849,7 @@ bool HardwareInfo::suspend( suspend_type suspend ) {
return false; return false;
} }
break; break;
case FREEZE: case FREEZE:
if (suspend_states.freeze && (suspend_states.freeze_allowed != 0)) { if (suspend_states.freeze && (suspend_states.freeze_allowed != 0)) {
if (rdevice->setPowerState(TDESystemPowerState::Freeze)) { if (rdevice->setPowerState(TDESystemPowerState::Freeze)) {
@ -839,6 +869,7 @@ bool HardwareInfo::suspend( suspend_type suspend ) {
return false; return false;
} }
break; break;
case STANDBY: case STANDBY:
if (suspend_states.standby && (suspend_states.standby_allowed != 0)) { if (suspend_states.standby && (suspend_states.standby_allowed != 0)) {
if (rdevice->setPowerState(TDESystemPowerState::Standby)) { if (rdevice->setPowerState(TDESystemPowerState::Standby)) {
@ -858,6 +889,7 @@ bool HardwareInfo::suspend( suspend_type suspend ) {
return false; return false;
} }
break; break;
default: default:
return false; return false;
} }

@ -56,7 +56,8 @@ enum suspend_type {
SUSPEND2DISK, SUSPEND2DISK,
SUSPEND2RAM, SUSPEND2RAM,
FREEZE, FREEZE,
STANDBY STANDBY,
SUSPEND_HYBRID,
}; };
enum cpufreq_type { enum cpufreq_type {
@ -106,6 +107,12 @@ typedef struct SuspendStates {
bool standby_can; bool standby_can;
//! true if the machine support standby and PolicyKit allow to call the interface //! true if the machine support standby and PolicyKit allow to call the interface
int standby_allowed; 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 () { SuspendStates () {
suspend2ram = false; suspend2ram = false;
@ -120,6 +127,9 @@ typedef struct SuspendStates {
standby = false; standby = false;
standby_can = false; standby_can = false;
standby_allowed = -1; standby_allowed = -1;
suspend_hybrid = false;
suspend_hybrid_can = false;
suspend_hybrid_allowed = -1;
} }
} SuspendStates; } SuspendStates;

@ -297,12 +297,14 @@ bool Settings::load_general_settings(){
} }
sleepButtonAction = mapActionToType(tdeconfig->readEntry("ActionOnSleepButton","")); 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; sleepButtonAction = NONE;
} }
s2diskButtonAction = mapActionToType(tdeconfig->readEntry("ActionOnS2DiskButton","")); 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; s2diskButtonAction = NONE;
} }
@ -327,6 +329,8 @@ action Settings::mapActionToType (TQString _action) {
return LOGOUT_DIALOG; return LOGOUT_DIALOG;
} else if (_action.startsWith("SUSPEND2DISK")) { } else if (_action.startsWith("SUSPEND2DISK")) {
return GO_SUSPEND2DISK; return GO_SUSPEND2DISK;
} else if (_action.startsWith("SUSPEND_HYBRID")) {
return GO_SUSPEND_HYBRID;
} else if (_action.startsWith("SUSPEND2RAM")) { } else if (_action.startsWith("SUSPEND2RAM")) {
return GO_SUSPEND2RAM; return GO_SUSPEND2RAM;
} else if (_action.startsWith("FREEZE")) { } else if (_action.startsWith("FREEZE")) {

@ -47,7 +47,8 @@ enum action{
BRIGHTNESS, BRIGHTNESS,
CPUFREQ_POWERSAVE, CPUFREQ_POWERSAVE,
CPUFREQ_DYNAMIC, CPUFREQ_DYNAMIC,
CPUFREQ_PERFORMANCE CPUFREQ_PERFORMANCE,
GO_SUSPEND_HYBRID
}; };
/*! /*!

@ -58,7 +58,9 @@ suspendDialog::~suspendDialog()
void suspendDialog::setPixmap( TQString type ) void suspendDialog::setPixmap( TQString type )
{ {
TQPixmap pixmap = 0; 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); pixmap = TDEGlobal::iconLoader()->loadIcon("suspend_to_disk", TDEIcon::NoGroup, TDEIcon::SizeLarge);
} else if (type.startsWith("suspend2ram")) { } else if (type.startsWith("suspend2ram")) {
pixmap = TDEGlobal::iconLoader()->loadIcon("suspend_to_ram", TDEIcon::NoGroup, TDEIcon::SizeLarge); pixmap = TDEGlobal::iconLoader()->loadIcon("suspend_to_ram", TDEIcon::NoGroup, TDEIcon::SizeLarge);

@ -74,12 +74,12 @@ tdepowersave::tdepowersave( bool force_acpi_check, bool trace_func ) : KSystemTr
config->writeEntry("AlreadyStarted", true); config->writeEntry("AlreadyStarted", true);
// check whether APM, ACPI, PMU, CPUFreq or Suspend2Disk/ram supported, otherwise end up // 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. // and don't start tdepowersave ever again until force_acpi_check == true.
if (!hwinfo->hasACPI() && !hwinfo->hasAPM() && !hwinfo->hasPMU() && if (!hwinfo->hasACPI() && !hwinfo->hasAPM() && !hwinfo->hasPMU() && !hwinfo->supportCPUFreq() &&
!hwinfo->supportCPUFreq() && !suspend.suspend2disk && !suspend.suspend2ram){ !suspend.suspend2disk && !suspend.suspend2ram && !suspend.suspend_hybrid) {
config->writeEntry("Autostart", false); config->writeEntry("Autostart", false);
config->sync(); config->sync();
kdError() << "This machine does not support ACPI, APM, PMU, CPUFreq, Suspend2Disk nor " kdError() << "This machine does not support ACPI, APM, PMU, CPUFreq, Suspend2Disk, "
<< "Suspend2RAM. Please close tdepowersave now." << endl; << "Suspend2RAM nor Hybrid Suspend. Please close tdepowersave now." << endl;
exit(-1); exit(-1);
} }
} }
@ -186,18 +186,16 @@ void tdepowersave::initMenu() {
#endif #endif
SLEEP_SEPARATOR_MENU_ID = this->contextMenu()->insertSeparator(); 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), FREEZE_MENU_ID = this->contextMenu()->insertItem( SmallIconSet("suspend_to_ram", TQIconSet::Automatic),
i18n("Freeze"), this, TQT_SLOT(do_freeze())); i18n("Freeze"), this, TQT_SLOT(do_freeze()));
STANDBY_MENU_ID = this->contextMenu()->insertItem( SmallIconSet("stand_by", TQIconSet::Automatic), STANDBY_MENU_ID = this->contextMenu()->insertItem( SmallIconSet("stand_by", TQIconSet::Automatic),
i18n("Standby"), this, TQT_SLOT(do_standby())); 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 = new TQPopupMenu(this, i18n("Set CPU Frequency Policy").ascii());
speed_menu->insertItem(i18n("Performance"), PERFORMANCE); 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. * \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". * This function need a power management backend in TDE hardware library for "suspend to disk".
* \return boolean with the result of the operation * \return boolean with the result of the operation
* \retval true if successful * \retval true if successful
@ -745,6 +743,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. * \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. * If there is a error while "suspend to RAM" the user get a messagebox.
@ -927,6 +981,11 @@ void tdepowersave::do_autosuspendWarn() {
allowed = true; 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") { else if (settings->autoInactiveAction == "Sleep") {
if( suspend.suspend2ram && (suspend.suspend2ram_allowed || suspend.suspend2ram_allowed == -1)) { if( suspend.suspend2ram && (suspend.suspend2ram_allowed || suspend.suspend2ram_allowed == -1)) {
allowed = true; allowed = true;
@ -953,6 +1012,8 @@ void tdepowersave::do_autosuspendWarn() {
if(settings->autoInactiveAction == "Hibernate") { if(settings->autoInactiveAction == "Hibernate") {
countdown->setPixmap("suspend2disk"); countdown->setPixmap("suspend2disk");
} else if(settings->autoInactiveAction == "Hybrid Suspend") {
countdown->setPixmap("suspend2disk");
} else if (settings->autoInactiveAction == "Sleep") { } else if (settings->autoInactiveAction == "Sleep") {
countdown->setPixmap("suspend2ram"); countdown->setPixmap("suspend2ram");
} else if (settings->autoInactiveAction == "Freeze") { } else if (settings->autoInactiveAction == "Freeze") {
@ -995,8 +1056,6 @@ void tdepowersave::do_autosuspendWarn() {
*/ */
bool tdepowersave::do_autosuspend(bool cancel) { bool tdepowersave::do_autosuspend(bool cancel) {
kdDebugFuncIn(trace); kdDebugFuncIn(trace);
// TODO: check if this is really needed, it get called also on the suspend methodes
autoSuspend->stop(); autoSuspend->stop();
if (!cancel) { if (!cancel) {
@ -1008,6 +1067,8 @@ bool tdepowersave::do_autosuspend(bool cancel) {
if(settings->autoSuspend && !contextMenu()->isItemChecked(AUTOSUSPEND_MENU_ID)) { if(settings->autoSuspend && !contextMenu()->isItemChecked(AUTOSUSPEND_MENU_ID)) {
if(settings->autoInactiveAction == "Hibernate") { if(settings->autoInactiveAction == "Hibernate") {
return do_suspend2disk(); return do_suspend2disk();
} else if(settings->autoInactiveAction == "Hybrid Suspend") {
return do_suspend_hybrid();
} else if (settings->autoInactiveAction == "Sleep") { } else if (settings->autoInactiveAction == "Sleep") {
return do_suspend2ram(); return do_suspend2ram();
} else if (settings->autoInactiveAction == "Freeze") { } else if (settings->autoInactiveAction == "Freeze") {
@ -1456,10 +1517,11 @@ void tdepowersave::update(){
redraw_pixmap = 1; redraw_pixmap = 1;
} }
if (!hwinfo->isOnline()){ 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(FREEZE_MENU_ID, false);
this->contextMenu()->setItemVisible(STANDBY_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(SLEEP_SEPARATOR_MENU_ID, false);
this->contextMenu()->setItemVisible(SCHEME_SEPARATOR_MENU_ID, false); this->contextMenu()->setItemVisible(SCHEME_SEPARATOR_MENU_ID, false);
this->contextMenu()->setItemVisible(SCHEME_MENU_ID, false); this->contextMenu()->setItemVisible(SCHEME_MENU_ID, false);
@ -1479,10 +1541,11 @@ void tdepowersave::update(){
hwinfo->update_info_cpufreq_policy_changed = true; hwinfo->update_info_cpufreq_policy_changed = true;
suspend = hwinfo->getSuspendSupport(); 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(FREEZE_MENU_ID, true);
this->contextMenu()->setItemVisible(STANDBY_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(SLEEP_SEPARATOR_MENU_ID, true);
this->contextMenu()->setItemVisible(SCHEME_SEPARATOR_MENU_ID, true); this->contextMenu()->setItemVisible(SCHEME_SEPARATOR_MENU_ID, true);
this->contextMenu()->setItemVisible(SCHEME_MENU_ID, true); this->contextMenu()->setItemVisible(SCHEME_MENU_ID, true);
@ -1500,6 +1563,16 @@ void tdepowersave::update(){
this->contextMenu()->setItemEnabled(SUSPEND2DISK_MENU_ID, false); 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 || if (suspend.suspend2ram && (suspend.suspend2ram_allowed ||
suspend.suspend2ram_allowed == -1)) { suspend.suspend2ram_allowed == -1)) {
this->contextMenu()->setItemEnabled(SUSPEND2RAM_MENU_ID, true); this->contextMenu()->setItemEnabled(SUSPEND2RAM_MENU_ID, true);
@ -1907,6 +1980,11 @@ void tdepowersave::setAutoSuspend( bool resumed ){
allowed = true; 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") { else if (settings->autoInactiveAction == "Sleep") {
if( suspend.suspend2ram && (suspend.suspend2ram_allowed || suspend.suspend2ram_allowed == -1)) { if( suspend.suspend2ram && (suspend.suspend2ram_allowed || suspend.suspend2ram_allowed == -1)) {
allowed = true; allowed = true;
@ -2148,6 +2226,9 @@ void tdepowersave::handleActionCall ( action action, int value , bool checkAC, b
case GO_SUSPEND2DISK: case GO_SUSPEND2DISK:
TQTimer::singleShot(100, this, TQT_SLOT(do_suspend2disk())); TQTimer::singleShot(100, this, TQT_SLOT(do_suspend2disk()));
break; break;
case GO_SUSPEND_HYBRID:
TQTimer::singleShot(100, this, TQT_SLOT(do_suspend_hybrid()));
break;
case GO_FREEZE: case GO_FREEZE:
TQTimer::singleShot(100, this, TQT_SLOT(do_freeze())); TQTimer::singleShot(100, this, TQT_SLOT(do_freeze()));
break; break;
@ -2269,6 +2350,11 @@ void tdepowersave::notifySuspend( int suspendType ) {
i18n("System is going into %1 now."). i18n("System is going into %1 now.").
arg(i18n("hibernation"))); arg(i18n("hibernation")));
break; 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: case SUSPEND2RAM:
KNotifyClient::event( this->winId(), "suspend2ram_event", KNotifyClient::event( this->winId(), "suspend2ram_event",
i18n("System is going into %1 now."). i18n("System is going into %1 now.").
@ -2334,6 +2420,11 @@ void tdepowersave::handleResumeSignal() {
i18n("System is resumed from %1.").arg( i18n("System is resumed from %1.").arg(
i18n("hibernation"))); i18n("hibernation")));
break; 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: case SUSPEND2RAM:
KNotifyClient::event( this->winId(), "resume_from_suspend2ram_event", KNotifyClient::event( this->winId(), "resume_from_suspend2ram_event",
i18n("System is resumed from %1.").arg( i18n("System is resumed from %1.").arg(
@ -2389,6 +2480,10 @@ void tdepowersave::handleResumeSignal() {
logview = new LogViewer ("/var/log/suspend2disk.log"); logview = new LogViewer ("/var/log/suspend2disk.log");
logview->show(); logview->show();
break; break;
case SUSPEND_HYBRID:
logview = new LogViewer ("/var/log/suspend_hybrid.log");
logview->show();
break;
case SUSPEND2RAM: case SUSPEND2RAM:
logview = new LogViewer ("/var/log/suspend2ram.log"); logview = new LogViewer ("/var/log/suspend2ram.log");
logview->show(); logview->show();
@ -2461,6 +2556,9 @@ TQString tdepowersave::getSuspendString (int type) {
case SUSPEND2DISK: case SUSPEND2DISK:
return i18n("Hibernate"); return i18n("Hibernate");
break; break;
case SUSPEND_HYBRID:
return i18n("Hybrid Suspend");
break;
case SUSPEND2RAM: case SUSPEND2RAM:
return i18n("Sleep"); return i18n("Sleep");
break; break;
@ -2612,6 +2710,10 @@ TQStringList tdepowersave::allowed_sleepingStates(){
suspend.suspend2disk_allowed == -1)){ suspend.suspend2disk_allowed == -1)){
sleepList.append("suspendToDisk"); 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 || if (suspend.suspend2ram && (suspend.suspend2ram_allowed ||
suspend.suspend2ram_allowed == -1)){ suspend.suspend2ram_allowed == -1)){
sleepList.append("suspendToRAM"); sleepList.append("suspendToRAM");
@ -2696,6 +2798,18 @@ bool tdepowersave::do_suspendToDisk(){
return do_suspend2disk(); return do_suspend2disk();
} }
/*!
* 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. * DCOP Interface funtion to send the suspend to disk command to powersave.
* \return boolean with the result of calling do_suspend2ram() * \return boolean with the result of calling do_suspend2ram()

@ -188,6 +188,9 @@ private:
/*! contains the ID of the menuentry for suspend-to-disk */ /*! contains the ID of the menuentry for suspend-to-disk */
int SUSPEND2DISK_MENU_ID; int SUSPEND2DISK_MENU_ID;
//! a menu entry 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 */ /*! contains the ID of the menuentry for suspend-to-ram */
int SUSPEND2RAM_MENU_ID; int SUSPEND2RAM_MENU_ID;
//! a menu entry ID //! a menu entry ID
@ -322,6 +325,8 @@ private slots:
bool do_suspend2disk(); bool do_suspend2disk();
//! send command for suspend_to_RAM to the TDE hardware library //! send command for suspend_to_RAM to the TDE hardware library
bool do_suspend2ram(); 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 //! show warning dialog or call autosuspend if signal \ref inactivity::inactivityTimeExpired() recieved
void do_autosuspendWarn(); void do_autosuspendWarn();
@ -432,6 +437,8 @@ k_dcop:
bool do_setCPUFreqPolicy( TQString ); bool do_setCPUFreqPolicy( TQString );
//! dcop function to send 'suspend to disk' command to powersaved //! dcop function to send 'suspend to disk' command to powersaved
bool do_suspendToDisk(); 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 //! dcop function to send 'suspend to RAM' command to powersaved
bool do_suspendToRAM(); bool do_suspendToRAM();
//! dcop function to send 'freeze' command to powersaved //! dcop function to send 'freeze' command to powersaved

Loading…
Cancel
Save