summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCarsten Haitzler (Rasterman) <raster@rasterman.com>2020-05-30 17:41:03 +0100
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>2020-05-30 21:56:29 +0100
commiteb61b825e43d7ad719925607d1812a507dab42fe (patch)
tree347096248a182b7eb860d60f9c2aa55b7563a128 /src
parenta5fa9b6fe7130782395c8288c6524a95b6740fd5 (diff)
suspend/hibernate - add a small delay before doing the deed
allow any pending frames to pop out of the pipeline before we sleep
Diffstat (limited to 'src')
-rw-r--r--src/bin/e_sys.c94
1 files changed, 58 insertions, 36 deletions
diff --git a/src/bin/e_sys.c b/src/bin/e_sys.c
index b6066d38f..9664a3677 100644
--- a/src/bin/e_sys.c
+++ b/src/bin/e_sys.c
@@ -988,6 +988,53 @@ _e_sys_cb_acpi_event(void *data EINA_UNUSED, int type EINA_UNUSED, void *event)
988 return ECORE_CALLBACK_PASS_ON; 988 return ECORE_CALLBACK_PASS_ON;
989} 989}
990 990
991static Ecore_Timer *_e_sys_suspend_delay_timer = NULL;
992static Eina_Bool
993_e_sys_suspend_delay(void *data EINA_UNUSED)
994{
995 _e_sys_suspend_delay_timer = NULL;
996 _e_sys_begin_time = ecore_time_get();
997 if (e_config->suspend_connected_standby == 0)
998 {
999 if (systemd_works) _e_sys_systemd_suspend();
1000 else
1001 {
1002 _e_sys_susp_hib_check();
1003 e_system_send("power-suspend", NULL);
1004 }
1005 }
1006 else
1007 {
1008 if (_e_sys_acpi_handler)
1009 ecore_event_handler_del(_e_sys_acpi_handler);
1010 _e_sys_acpi_handler =
1011 ecore_event_handler_add(E_EVENT_ACPI,
1012 _e_sys_cb_acpi_event,
1013 NULL);
1014 e_powersave_mode_force(E_POWERSAVE_MODE_FREEZE);
1015 // XXX: need some system way of forcing the system into a very low
1016 // power level with as many devices suspended as possible. below is
1017 // a simple "freeze the cpu/kernel" which is not what we want actually
1018 // sleep 2 && echo freeze | sudo tee /sys/power/state
1019 }
1020 return EINA_FALSE;
1021}
1022
1023static Ecore_Timer *_e_sys_hibernate_delay_timer = NULL;
1024static Eina_Bool
1025_e_sys_hibernate_delay(void *data EINA_UNUSED)
1026{
1027 _e_sys_hibernate_delay_timer = NULL;
1028 _e_sys_begin_time = ecore_time_get();
1029 if (systemd_works) _e_sys_systemd_hibernate();
1030 else
1031 {
1032 _e_sys_susp_hib_check();
1033 e_system_send("power-hibernate", NULL);
1034 }
1035 return EINA_FALSE;
1036}
1037
991static int 1038static int
992_e_sys_action_do(E_Sys_Action a, char *param EINA_UNUSED, Eina_Bool raw) 1039_e_sys_action_do(E_Sys_Action a, char *param EINA_UNUSED, Eina_Bool raw)
993{ 1040{
@@ -1107,34 +1154,12 @@ _e_sys_action_do(E_Sys_Action a, char *param EINA_UNUSED, Eina_Bool raw)
1107 if (e_config->desklock_on_suspend) 1154 if (e_config->desklock_on_suspend)
1108 // XXX: this desklock - ensure its instant 1155 // XXX: this desklock - ensure its instant
1109 e_desklock_show(EINA_TRUE); 1156 e_desklock_show(EINA_TRUE);
1110 _e_sys_begin_time = ecore_time_get(); 1157 if (_e_sys_suspend_delay_timer)
1111 if (e_config->suspend_connected_standby == 0) 1158 ecore_timer_del(_e_sys_suspend_delay_timer);
1112 { 1159 if (e_config->suspend_connected_standby == 0) ret = 1;
1113 if (systemd_works) 1160 // XXX: make timer shorter if desklock is instant
1114 _e_sys_systemd_suspend(); 1161 _e_sys_suspend_delay_timer =
1115 else 1162 ecore_timer_add(0.5, _e_sys_suspend_delay, NULL);
1116 {
1117 _e_sys_susp_hib_check();
1118 e_system_send("power-suspend", NULL);
1119 }
1120 ret = 1;
1121 }
1122 else
1123 {
1124 if (_e_sys_acpi_handler)
1125 ecore_event_handler_del(_e_sys_acpi_handler);
1126 _e_sys_acpi_handler =
1127 ecore_event_handler_add(E_EVENT_ACPI,
1128 _e_sys_cb_acpi_event,
1129 NULL);
1130 e_powersave_mode_force(E_POWERSAVE_MODE_FREEZE);
1131 // XXX: need some system way of forcing the system
1132 // into a very lowe power level with as many
1133 // devices suspended as possible. below is a simple
1134 // "freeze the cpu/kernel" which is not what we
1135 // want actually
1136 // sleep 2 && echo freeze | sudo tee /sys/power/state
1137 }
1138 } 1163 }
1139 else 1164 else
1140 { 1165 {
@@ -1159,15 +1184,12 @@ _e_sys_action_do(E_Sys_Action a, char *param EINA_UNUSED, Eina_Bool raw)
1159 if (e_config->desklock_on_suspend) 1184 if (e_config->desklock_on_suspend)
1160 // XXX: this desklock - ensure its instant 1185 // XXX: this desklock - ensure its instant
1161 e_desklock_show(EINA_TRUE); 1186 e_desklock_show(EINA_TRUE);
1162 _e_sys_begin_time = ecore_time_get(); 1187 if (_e_sys_hibernate_delay_timer)
1163 if (systemd_works) 1188 ecore_timer_del(_e_sys_hibernate_delay_timer);
1164 _e_sys_systemd_hibernate();
1165 else
1166 {
1167 _e_sys_susp_hib_check();
1168 e_system_send("power-hibernate", NULL);
1169 }
1170 ret = 1; 1189 ret = 1;
1190 // XXX: make timer shorter if desklock is instant
1191 _e_sys_hibernate_delay_timer =
1192 ecore_timer_add(0.5, _e_sys_hibernate_delay, NULL);
1171 } 1193 }
1172 else 1194 else
1173 { 1195 {