aboutsummaryrefslogtreecommitdiffstats
path: root/src/bin/e_powersave.c
diff options
context:
space:
mode:
authorCarsten Haitzler (Rasterman) <raster@rasterman.com>2017-10-18 13:33:47 +0900
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>2017-10-18 13:33:47 +0900
commit0fada409175333e4ebeee30cab2ccd4ff457445f (patch)
tree36a14e4caf8b086d30569bf2f82201144f62ea0f /src/bin/e_powersave.c
parentbattery modules - actually set ac power flag based on ac presence (diff)
downloadenlightenment-0fada409175333e4ebeee30cab2ccd4ff457445f.tar.gz
smart suspend - honor suspend on ac or not flag as it should
so if you closed the lid ANd didn't have external screens ANd had ac plugged in ... e would suspend even if youdidn't have "suspend on ac" checked in blanking dialog. respect this and handle it properly. @fix side note... i've notced acpid no longer reporting lid events on one of my systems. this is very sucky. you now have to open /dev/input/event2 (this may vary from device to device) to get lid events... it's an input device. this means elput needs to start doing this as we cant get power button or lid events anymore .... and we may have to do this for x11 too.
Diffstat (limited to 'src/bin/e_powersave.c')
-rw-r--r--src/bin/e_powersave.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/bin/e_powersave.c b/src/bin/e_powersave.c
index 55021b38d..baac18a3e 100644
--- a/src/bin/e_powersave.c
+++ b/src/bin/e_powersave.c
@@ -33,6 +33,8 @@ static E_Powersave_Mode powersave_mode_force = E_POWERSAVE_MODE_NONE;
static double defer_time = 5.0;
static Eina_Bool powersave_force = EINA_FALSE;
static Eina_List *powersave_sleepers = NULL;
+static Eina_Bool powersave_deferred_suspend = EINA_FALSE;
+static Eina_Bool powersave_deferred_hibernate = EINA_FALSE;
/* externally accessible functions */
EINTERN int
@@ -198,6 +200,25 @@ e_powersave_sleeper_sleep(E_Powersave_Sleeper *sleeper, int poll_interval)
}
}
+E_API void
+e_powersave_defer_suspend(void)
+{
+ powersave_deferred_suspend = EINA_TRUE;
+}
+
+E_API void
+e_powersave_defer_hibernate(void)
+{
+ powersave_deferred_hibernate = EINA_TRUE;
+}
+
+E_API void
+e_powersave_defer_cancel(void)
+{
+ powersave_deferred_suspend = EINA_FALSE;
+ powersave_deferred_hibernate = EINA_FALSE;
+}
+
/* local subsystem functions */
static void
@@ -288,7 +309,21 @@ _e_powersave_mode_eval(void)
static void
_e_powersave_event_update_free(void *data EINA_UNUSED, void *event)
{
+ E_Powersave_Mode mode;
+
+ if (powersave_force) mode = powersave_mode_force;
+ else mode = powersave_mode;
free(event);
+
+ if (mode > E_POWERSAVE_MODE_LOW)
+ {
+ if (powersave_deferred_hibernate)
+ e_sys_action_do(E_SYS_HIBERNATE, NULL);
+ else if (powersave_deferred_suspend)
+ e_sys_action_do(E_SYS_SUSPEND, NULL);
+ }
+ powersave_deferred_hibernate = EINA_FALSE;
+ powersave_deferred_suspend = EINA_FALSE;
}
static void