diff --git a/src/modules/sysinfo/batman/batman.c b/src/modules/sysinfo/batman/batman.c index f44731a60..9cd9e87fd 100644 --- a/src/modules/sysinfo/batman/batman.c +++ b/src/modules/sysinfo/batman/batman.c @@ -351,6 +351,34 @@ _batman_device_update(Instance *inst) _batman_update(inst, full, time_left, have_battery, have_power); } +static Eina_Bool +_screensaver_on(void *data) +{ + Instance *inst = data; + +#if defined(HAVE_EEZE) + _batman_udev_stop(inst); +#elif defined(__OpenBSD__) || defined(__DragonFly__) || defined(__FreeBSD__) || defined(__NetBSD__) + _batman_sysctl_stop(); +#elif defined(upower) + _batman_upower_stop(); +#else + _batman_fallback_stop(); +#endif + + return ECORE_CALLBACK_RENEW; +} + +static Eina_Bool +_screensaver_off(void *data) +{ + Instance *inst = data; + + _batman_config_updated(inst); + + return ECORE_CALLBACK_RENEW; +} + void _batman_config_updated(Instance *inst) { @@ -529,6 +557,7 @@ static void _batman_removed_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_data) { Instance *inst = data; + Ecore_Event_Handler *handler; if (inst->o_main != event_data) return; if (_handler) @@ -537,6 +566,8 @@ _batman_removed_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_data) E_FREE_FUNC(inst->cfg->batman.popup, evas_object_del); if (inst->cfg->batman.configure) E_FREE_FUNC(inst->cfg->batman.configure, evas_object_del); + EINA_LIST_FREE(inst->cfg->batman.handlers, handler) + ecore_event_handler_del(handler); #if defined(HAVE_EEZE) _batman_udev_stop(inst); #elif defined(__OpenBSD__) || defined(__DragonFly__) || defined(__FreeBSD__) || defined(__NetBSD__) @@ -557,11 +588,14 @@ void sysinfo_batman_remove(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_data EINA_UNUSED) { Instance *inst = data; + Ecore_Event_Handler *handler; if (inst->cfg->batman.popup) E_FREE_FUNC(inst->cfg->batman.popup, evas_object_del); if (inst->cfg->batman.configure) E_FREE_FUNC(inst->cfg->batman.configure, evas_object_del); + EINA_LIST_FREE(inst->cfg->batman.handlers, handler) + ecore_event_handler_del(handler); #ifdef HAVE_EEZE _batman_udev_stop(inst); #elif defined(__OpenBSD__) || defined(__DragonFly__) || defined(__FreeBSD__) || defined(__NetBSD__) @@ -608,6 +642,10 @@ _batman_created_cb(void *data, Evas_Object *obj, void *event_data EINA_UNUSED) _powersave_cb_config_update, inst); evas_object_show(inst->cfg->batman.o_gadget); evas_object_smart_callback_del_full(obj, "gadget_created", _batman_created_cb, data); + + E_LIST_HANDLER_APPEND(inst->cfg->batman.handlers, E_EVENT_SCREENSAVER_ON, _screensaver_on, inst); + E_LIST_HANDLER_APPEND(inst->cfg->batman.handlers, E_EVENT_SCREENSAVER_OFF, _screensaver_off, inst); + _batman_config_updated(inst); } @@ -631,6 +669,10 @@ sysinfo_batman_create(Evas_Object *parent, Instance *inst) _handler = ecore_event_handler_add(E_EVENT_POWERSAVE_CONFIG_UPDATE, _powersave_cb_config_update, inst); evas_object_show(inst->cfg->batman.o_gadget); + + E_LIST_HANDLER_APPEND(inst->cfg->batman.handlers, E_EVENT_SCREENSAVER_ON, _screensaver_on, inst); + E_LIST_HANDLER_APPEND(inst->cfg->batman.handlers, E_EVENT_SCREENSAVER_OFF, _screensaver_off, inst); + _batman_config_updated(inst); return inst->cfg->batman.o_gadget; @@ -691,7 +733,7 @@ batman_create(Evas_Object *parent, int *id, E_Gadget_Site_Orient orient EINA_UNU evas_object_smart_callback_add(parent, "gadget_created", _batman_created_cb, inst); evas_object_smart_callback_add(parent, "gadget_removed", _batman_removed_cb, inst); evas_object_event_callback_add(inst->o_main, EVAS_CALLBACK_DEL, sysinfo_batman_remove, inst); - evas_object_show(inst->o_main); + evas_object_show(inst->o_main); if (inst->cfg->id < 0) return inst->o_main; diff --git a/src/modules/sysinfo/cpuclock/cpuclock.c b/src/modules/sysinfo/cpuclock/cpuclock.c index 0047373f8..bf054fbd5 100644 --- a/src/modules/sysinfo/cpuclock/cpuclock.c +++ b/src/modules/sysinfo/cpuclock/cpuclock.c @@ -4,6 +4,8 @@ #include #endif +EINTERN void _cpuclock_poll_interval_update(Instance *inst); + typedef struct _Thread_Config Thread_Config; struct _Thread_Config { @@ -376,6 +378,7 @@ _cpuclock_config_updated(Instance *inst) edje_object_message_send(elm_layout_edje_get(inst->cfg->cpuclock.o_gadget), EDJE_MESSAGE_STRING_SET, 2, governor_msg); free(governor_msg); } + _cpuclock_poll_interval_update(inst); } static void @@ -820,6 +823,11 @@ _cpuclock_cb_frequency_check_main(void *data, Ecore_Thread *th) _cpuclock_status_free(status); if (ecore_thread_check(th)) break; e_powersave_sleeper_sleep(thc->sleeper, thc->interval); + if (e_powersave_mode_get() == E_POWERSAVE_MODE_FREEZE) + usleep((1000000.0 / 800.0) * (double)thc->interval); + else + usleep((1000000.0 / 8.0) * (double)thc->interval); + if (ecore_thread_check(th)) break; } } @@ -875,7 +883,7 @@ _cpuclock_cb_frequency_check_end(void *data, Ecore_Thread *th EINA_UNUSED) E_FREE_FUNC(thc, free); } -void +EINTERN void _cpuclock_poll_interval_update(Instance *inst) { Thread_Config *thc; @@ -900,10 +908,34 @@ _cpuclock_poll_interval_update(Instance *inst) e_config_save_queue(); } +static Eina_Bool +_screensaver_on(void *data) +{ + Instance *inst = data; + + if (inst->cfg->cpuclock.frequency_check_thread) + { + ecore_thread_cancel(inst->cfg->cpuclock.frequency_check_thread); + inst->cfg->cpuclock.frequency_check_thread = NULL; + } + return ECORE_CALLBACK_RENEW; +} + +static Eina_Bool +_screensaver_off(void *data) +{ + Instance *inst = data; + + _cpuclock_config_updated(inst); + + return ECORE_CALLBACK_RENEW; +} + static void _cpuclock_removed_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_data) { Instance *inst = data; + Ecore_Event_Handler *handler; if (inst->o_main != event_data) return; @@ -915,9 +947,10 @@ _cpuclock_removed_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_data) if (inst->cfg->cpuclock.configure) E_FREE_FUNC(inst->cfg->cpuclock.configure, evas_object_del); - if (inst->cfg->cpuclock.handler) + if (inst->cfg->cpuclock.handler) ecore_event_handler_del(inst->cfg->cpuclock.handler); - + EINA_LIST_FREE(inst->cfg->cpuclock.handlers, handler) + ecore_event_handler_del(handler); if (inst->cfg->cpuclock.frequency_check_thread) { ecore_thread_cancel(inst->cfg->cpuclock.frequency_check_thread); @@ -938,6 +971,7 @@ void sysinfo_cpuclock_remove(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_data EINA_UNUSED) { Instance *inst = data; + Ecore_Event_Handler *handler; if (inst->cfg->cpuclock.popup_label) E_FREE_FUNC(inst->cfg->cpuclock.popup, evas_object_del); @@ -949,6 +983,8 @@ sysinfo_cpuclock_remove(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_U if (inst->cfg->cpuclock.handler) ecore_event_handler_del(inst->cfg->cpuclock.handler); + EINA_LIST_FREE(inst->cfg->cpuclock.handlers, handler) + ecore_event_handler_del(handler); if (inst->cfg->cpuclock.frequency_check_thread) { @@ -996,9 +1032,12 @@ _cpuclock_created_cb(void *data, Evas_Object *obj, void *event_data EINA_UNUSED) _cpuclock_mouse_down_cb, inst); evas_object_show(inst->cfg->cpuclock.o_gadget); evas_object_smart_callback_del_full(obj, "gadget_created", _cpuclock_created_cb, data); + + E_LIST_HANDLER_APPEND(inst->cfg->cpuclock.handlers, E_EVENT_SCREENSAVER_ON, _screensaver_on, inst); + E_LIST_HANDLER_APPEND(inst->cfg->cpuclock.handlers, E_EVENT_SCREENSAVER_OFF, _screensaver_off, inst); + inst->cfg->cpuclock.status = _cpuclock_status_new(); _cpuclock_status_check_available(inst->cfg->cpuclock.status); - _cpuclock_poll_interval_update(inst); inst->cfg->cpuclock.handler = ecore_event_handler_add(E_EVENT_POWERSAVE_UPDATE, _cpuclock_event_cb_powersave, inst); _cpuclock_config_updated(inst); @@ -1039,9 +1078,12 @@ sysinfo_cpuclock_create(Evas_Object *parent, Instance *inst) _cpuclock_face_cb_set_frequency, inst); evas_object_event_callback_add(inst->cfg->cpuclock.o_gadget, EVAS_CALLBACK_RESIZE, _cpuclock_resize_cb, inst); evas_object_show(inst->cfg->cpuclock.o_gadget); + + E_LIST_HANDLER_APPEND(inst->cfg->cpuclock.handlers, E_EVENT_SCREENSAVER_ON, _screensaver_on, inst); + E_LIST_HANDLER_APPEND(inst->cfg->cpuclock.handlers, E_EVENT_SCREENSAVER_OFF, _screensaver_off, inst); + inst->cfg->cpuclock.status = _cpuclock_status_new(); _cpuclock_status_check_available(inst->cfg->cpuclock.status); - _cpuclock_poll_interval_update(inst); inst->cfg->cpuclock.handler = ecore_event_handler_add(E_EVENT_POWERSAVE_UPDATE, _cpuclock_event_cb_powersave, inst); _cpuclock_config_updated(inst); diff --git a/src/modules/sysinfo/cpumonitor/cpumonitor.c b/src/modules/sysinfo/cpumonitor/cpumonitor.c index 2220ca40d..18fb4b986 100644 --- a/src/modules/sysinfo/cpumonitor/cpumonitor.c +++ b/src/modules/sysinfo/cpumonitor/cpumonitor.c @@ -7,6 +7,7 @@ struct _Thread_Config int interval; int cores; Instance *inst; + E_Powersave_Sleeper *sleeper; }; static void @@ -169,9 +170,13 @@ _cpumonitor_cb_usage_check_main(void *data, Ecore_Thread *th) #endif ecore_thread_feedback(th, NULL); if (ecore_thread_check(th)) break; - usleep((1000000.0 / 8.0) * (double)thc->interval); + e_powersave_sleeper_sleep(thc->sleeper, thc->interval); + if (e_powersave_mode_get() == E_POWERSAVE_MODE_FREEZE) + usleep((1000000.0 / 800.0) * (double)thc->interval); + else + usleep((1000000.0 / 8.0) * (double)thc->interval); + if (ecore_thread_check(th)) break; } - E_FREE_FUNC(thc, free); } static void @@ -188,6 +193,14 @@ _cpumonitor_cb_usage_check_notify(void *data, _cpumonitor_face_update(inst); } +static void +_cpumonitor_cb_usage_check_end(void *data, Ecore_Thread *th EINA_UNUSED) +{ + Thread_Config *thc = data; + e_powersave_sleeper_free(thc->sleeper); + E_FREE_FUNC(thc, free); +} + Evas_Object * _cpumonitor_add_layout(Instance *inst) { @@ -210,6 +223,35 @@ _cpumonitor_add_layout(Instance *inst) return layout; } +static Eina_Bool +_screensaver_on(void *data) +{ + Instance *inst = data; + CPU_Core *core; + + if (inst->cfg->cpumonitor.usage_check_thread) + { + EINA_LIST_FREE(inst->cfg->cpumonitor.cores, core) + { + evas_object_del(core->layout); + E_FREE_FUNC(core, free); + } + ecore_thread_cancel(inst->cfg->cpumonitor.usage_check_thread); + inst->cfg->cpumonitor.usage_check_thread = NULL; + } + return ECORE_CALLBACK_RENEW; +} + +static Eina_Bool +_screensaver_off(void *data) +{ + Instance *inst = data; + + _cpumonitor_config_updated(inst); + + return ECORE_CALLBACK_RENEW; +} + void _cpumonitor_config_updated(Instance *inst) { @@ -232,6 +274,7 @@ _cpumonitor_config_updated(Instance *inst) { thc->inst = inst; thc->interval = inst->cfg->cpumonitor.poll_interval; + thc->sleeper = e_powersave_sleeper_new(); #if defined(__FreeBSD__) || defined(__DragonFly__) || defined(__OpenBSD__) thc->cores = _cpumonitor_sysctl_getcores(); #else @@ -251,7 +294,8 @@ _cpumonitor_config_updated(Instance *inst) inst->cfg->cpumonitor.usage_check_thread = ecore_thread_feedback_run(_cpumonitor_cb_usage_check_main, _cpumonitor_cb_usage_check_notify, - NULL, NULL, thc, EINA_TRUE); + _cpumonitor_cb_usage_check_end, + _cpumonitor_cb_usage_check_end, thc, EINA_TRUE); } e_config_save_queue(); } @@ -261,6 +305,7 @@ _cpumonitor_removed_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_dat { Instance *inst = data; CPU_Core *core; + Ecore_Event_Handler *handler; if (inst->o_main != event_data) return; @@ -273,6 +318,8 @@ _cpumonitor_removed_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_dat ecore_thread_cancel(inst->cfg->cpumonitor.usage_check_thread); inst->cfg->cpumonitor.usage_check_thread = NULL; } + EINA_LIST_FREE(inst->cfg->cpumonitor.handlers, handler) + ecore_event_handler_del(handler); EINA_LIST_FREE(inst->cfg->cpumonitor.cores, core) { evas_object_del(core->layout); @@ -289,6 +336,7 @@ sysinfo_cpumonitor_remove(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA { Instance *inst = data; CPU_Core *core; + Ecore_Event_Handler *handler; if (inst->cfg->cpumonitor.popup) E_FREE_FUNC(inst->cfg->cpumonitor.popup, evas_object_del); @@ -299,6 +347,8 @@ sysinfo_cpumonitor_remove(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA ecore_thread_cancel(inst->cfg->cpumonitor.usage_check_thread); inst->cfg->cpumonitor.usage_check_thread = NULL; } + EINA_LIST_FREE(inst->cfg->cpumonitor.handlers, handler) + ecore_event_handler_del(handler); EINA_LIST_FREE(inst->cfg->cpumonitor.cores, core) { evas_object_del(core->layout); @@ -340,6 +390,10 @@ _cpumonitor_created_cb(void *data, Evas_Object *obj, void *event_data EINA_UNUSE evas_object_show(inst->cfg->cpumonitor.event); evas_object_smart_callback_del_full(obj, "gadget_created", _cpumonitor_created_cb, data); + + E_LIST_HANDLER_APPEND(inst->cfg->cpumonitor.handlers, E_EVENT_SCREENSAVER_ON, _screensaver_on, inst); + E_LIST_HANDLER_APPEND(inst->cfg->cpumonitor.handlers, E_EVENT_SCREENSAVER_OFF, _screensaver_off, inst); + _cpumonitor_config_updated(inst); } @@ -369,6 +423,9 @@ sysinfo_cpumonitor_create(Evas_Object *parent, Instance *inst) elm_table_pack(inst->cfg->cpumonitor.o_gadget, inst->cfg->cpumonitor.event, 0, 0, 1, 1); evas_object_show(inst->cfg->cpumonitor.event); + E_LIST_HANDLER_APPEND(inst->cfg->cpumonitor.handlers, E_EVENT_SCREENSAVER_ON, _screensaver_on, inst); + E_LIST_HANDLER_APPEND(inst->cfg->cpumonitor.handlers, E_EVENT_SCREENSAVER_OFF, _screensaver_off, inst); + _cpumonitor_config_updated(inst); return inst->cfg->cpumonitor.o_gadget; diff --git a/src/modules/sysinfo/memusage/memusage.c b/src/modules/sysinfo/memusage/memusage.c index c36c10722..d7e09916d 100644 --- a/src/modules/sysinfo/memusage/memusage.c +++ b/src/modules/sysinfo/memusage/memusage.c @@ -15,6 +15,7 @@ struct _Thread_Config unsigned long mem_shared; unsigned long swp_total; unsigned long swp_used; + E_Powersave_Sleeper *sleeper; }; static void @@ -293,8 +294,20 @@ _memusage_cb_usage_check_main(void *data, Ecore_Thread *th) ecore_thread_feedback(th, NULL); if (ecore_thread_check(th)) break; - usleep((1000000.0 / 8.0) * (double)thc->interval); + e_powersave_sleeper_sleep(thc->sleeper, thc->interval); + if (e_powersave_mode_get() == E_POWERSAVE_MODE_FREEZE) + usleep((1000000.0 / 800.0) * (double)thc->interval); + else + usleep((1000000.0 / 8.0) * (double)thc->interval); + if (ecore_thread_check(th)) break; } +} + +static void +_memusage_cb_usage_check_end(void *data, Ecore_Thread *th EINA_UNUSED) +{ + Thread_Config *thc = data; + e_powersave_sleeper_free(thc->sleeper); E_FREE_FUNC(thc, free); } @@ -322,6 +335,29 @@ _memusage_cb_usage_check_notify(void *data, _memusage_face_update(inst); } +static Eina_Bool +_screensaver_on(void *data) +{ + Instance *inst = data; + + if (inst->cfg->memusage.usage_check_thread) + { + ecore_thread_cancel(inst->cfg->memusage.usage_check_thread); + inst->cfg->memusage.usage_check_thread = NULL; + } + return ECORE_CALLBACK_RENEW; +} + +static Eina_Bool +_screensaver_off(void *data) +{ + Instance *inst = data; + + _memusage_config_updated(inst); + + return ECORE_CALLBACK_RENEW; +} + void _memusage_config_updated(Instance *inst) { @@ -336,13 +372,15 @@ _memusage_config_updated(Instance *inst) if (thc) { thc->inst = inst; + thc->sleeper = e_powersave_sleeper_new(); thc->interval = inst->cfg->memusage.poll_interval; thc->mem_percent = 0; thc->swp_percent = 0; inst->cfg->memusage.usage_check_thread = ecore_thread_feedback_run(_memusage_cb_usage_check_main, _memusage_cb_usage_check_notify, - NULL, NULL, thc, EINA_TRUE); + _memusage_cb_usage_check_end, + _memusage_cb_usage_check_end, thc, EINA_TRUE); } e_config_save_queue(); } @@ -351,6 +389,7 @@ static void _memusage_removed_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_data) { Instance *inst = data; + Ecore_Event_Handler *handler; if (inst->o_main != event_data) return; @@ -363,6 +402,8 @@ _memusage_removed_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_data) ecore_thread_cancel(inst->cfg->memusage.usage_check_thread); inst->cfg->memusage.usage_check_thread = NULL; } + EINA_LIST_FREE(inst->cfg->memusage.handlers, handler) + ecore_event_handler_del(handler); evas_object_event_callback_del_full(inst->o_main, EVAS_CALLBACK_DEL, sysinfo_memusage_remove, data); @@ -374,6 +415,7 @@ void sysinfo_memusage_remove(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_data EINA_UNUSED) { Instance *inst = data; + Ecore_Event_Handler *handler; if (inst->cfg->memusage.popup) E_FREE_FUNC(inst->cfg->memusage.popup, evas_object_del); @@ -384,6 +426,8 @@ sysinfo_memusage_remove(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_U ecore_thread_cancel(inst->cfg->memusage.usage_check_thread); inst->cfg->memusage.usage_check_thread = NULL; } + EINA_LIST_FREE(inst->cfg->memusage.handlers, handler) + ecore_event_handler_del(handler); } static void @@ -416,6 +460,10 @@ _memusage_created_cb(void *data, Evas_Object *obj, void *event_data EINA_UNUSED) evas_object_show(inst->cfg->memusage.o_gadget); evas_object_smart_callback_del_full(obj, "gadget_created", _memusage_created_cb, data); + + E_LIST_HANDLER_APPEND(inst->cfg->memusage.handlers, E_EVENT_SCREENSAVER_ON, _screensaver_on, inst); + E_LIST_HANDLER_APPEND(inst->cfg->memusage.handlers, E_EVENT_SCREENSAVER_OFF, _screensaver_off, inst); + _memusage_config_updated(inst); } @@ -435,6 +483,11 @@ sysinfo_memusage_create(Evas_Object *parent, Instance *inst) EVAS_CALLBACK_RESIZE, _memusage_resize_cb, inst); evas_object_show(inst->cfg->memusage.o_gadget); + + + E_LIST_HANDLER_APPEND(inst->cfg->memusage.handlers, E_EVENT_SCREENSAVER_ON, _screensaver_on, inst); + E_LIST_HANDLER_APPEND(inst->cfg->memusage.handlers, E_EVENT_SCREENSAVER_OFF, _screensaver_off, inst); + _memusage_config_updated(inst); return inst->cfg->memusage.o_gadget; diff --git a/src/modules/sysinfo/netstatus/netstatus.c b/src/modules/sysinfo/netstatus/netstatus.c index e16e2b1c3..700b56aa3 100644 --- a/src/modules/sysinfo/netstatus/netstatus.c +++ b/src/modules/sysinfo/netstatus/netstatus.c @@ -8,6 +8,7 @@ struct _Thread_Config Instance *inst; int percent; long current; + E_Powersave_Sleeper *sleeper; }; static void @@ -139,7 +140,12 @@ _netstatus_cb_usage_check_main(void *data, Ecore_Thread *th) #endif ecore_thread_feedback(th, NULL); if (ecore_thread_check(th)) break; - usleep((1000000.0 / 8.0) * (double)thc->interval); + e_powersave_sleeper_sleep(thc->sleeper, thc->interval); + if (e_powersave_mode_get() == E_POWERSAVE_MODE_FREEZE) + usleep((1000000.0 / 800.0) * (double)thc->interval); + else + usleep((1000000.0 / 8.0) * (double)thc->interval); + if (ecore_thread_check(th)) break; } } @@ -161,9 +167,33 @@ static void _netstatus_cb_usage_check_end(void *data, Ecore_Thread *th EINA_UNUSED) { Thread_Config *thc = data; + e_powersave_sleeper_free(thc->sleeper); E_FREE_FUNC(thc, free); } +static Eina_Bool +_screensaver_on(void *data) +{ + Instance *inst = data; + + if (inst->cfg->netstatus.usage_check_thread) + { + ecore_thread_cancel(inst->cfg->netstatus.usage_check_thread); + inst->cfg->netstatus.usage_check_thread = NULL; + } + return ECORE_CALLBACK_RENEW; +} + +static Eina_Bool +_screensaver_off(void *data) +{ + Instance *inst = data; + + _netstatus_config_updated(inst); + + return ECORE_CALLBACK_RENEW; +} + void _netstatus_config_updated(Instance *inst) { @@ -178,6 +208,7 @@ _netstatus_config_updated(Instance *inst) if (thc) { thc->inst = inst; + thc->sleeper = e_powersave_sleeper_new(); thc->interval = inst->cfg->netstatus.poll_interval; inst->cfg->netstatus.usage_check_thread = ecore_thread_feedback_run(_netstatus_cb_usage_check_main, @@ -192,6 +223,7 @@ static void _netstatus_removed_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_data) { Instance *inst = data; + Ecore_Event_Handler *handler; if (inst->o_main != event_data) return; @@ -204,6 +236,8 @@ _netstatus_removed_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_data ecore_thread_cancel(inst->cfg->netstatus.usage_check_thread); inst->cfg->netstatus.usage_check_thread = NULL; } + EINA_LIST_FREE(inst->cfg->netstatus.handlers, handler) + ecore_event_handler_del(handler); E_FREE_FUNC(inst->cfg->netstatus.instring, eina_stringshare_del); E_FREE_FUNC(inst->cfg->netstatus.outstring, eina_stringshare_del); evas_object_event_callback_del_full(inst->o_main, EVAS_CALLBACK_DEL, sysinfo_netstatus_remove, data); @@ -216,6 +250,7 @@ void sysinfo_netstatus_remove(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_data EINA_UNUSED) { Instance *inst = data; + Ecore_Event_Handler *handler; if (inst->cfg->netstatus.popup) E_FREE_FUNC(inst->cfg->netstatus.popup, evas_object_del); @@ -226,6 +261,8 @@ sysinfo_netstatus_remove(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_ ecore_thread_cancel(inst->cfg->netstatus.usage_check_thread); inst->cfg->netstatus.usage_check_thread = NULL; } + EINA_LIST_FREE(inst->cfg->netstatus.handlers, handler) + ecore_event_handler_del(handler); E_FREE_FUNC(inst->cfg->netstatus.instring, eina_stringshare_del); E_FREE_FUNC(inst->cfg->netstatus.outstring, eina_stringshare_del); } @@ -253,6 +290,10 @@ _netstatus_created_cb(void *data, Evas_Object *obj, void *event_data EINA_UNUSED evas_object_event_callback_add(inst->cfg->netstatus.o_gadget, EVAS_CALLBACK_RESIZE, _netstatus_resize_cb, inst); evas_object_show(inst->cfg->netstatus.o_gadget); evas_object_smart_callback_del_full(obj, "gadget_created", _netstatus_created_cb, data); + + E_LIST_HANDLER_APPEND(inst->cfg->netstatus.handlers, E_EVENT_SCREENSAVER_ON, _screensaver_on, inst); + E_LIST_HANDLER_APPEND(inst->cfg->netstatus.handlers, E_EVENT_SCREENSAVER_OFF, _screensaver_off, inst); + _netstatus_config_updated(inst); } @@ -267,6 +308,10 @@ sysinfo_netstatus_create(Evas_Object *parent, Instance *inst) evas_object_event_callback_add(inst->cfg->netstatus.o_gadget, EVAS_CALLBACK_MOUSE_DOWN, _netstatus_mouse_down_cb, inst); evas_object_event_callback_add(inst->cfg->netstatus.o_gadget, EVAS_CALLBACK_RESIZE, _netstatus_resize_cb, inst); evas_object_show(inst->cfg->netstatus.o_gadget); + + E_LIST_HANDLER_APPEND(inst->cfg->netstatus.handlers, E_EVENT_SCREENSAVER_ON, _screensaver_on, inst); + E_LIST_HANDLER_APPEND(inst->cfg->netstatus.handlers, E_EVENT_SCREENSAVER_OFF, _screensaver_off, inst); + _netstatus_config_updated(inst); return inst->cfg->netstatus.o_gadget; diff --git a/src/modules/sysinfo/sysinfo.h b/src/modules/sysinfo/sysinfo.h index ad7c4426a..e3f7a522e 100644 --- a/src/modules/sysinfo/sysinfo.h +++ b/src/modules/sysinfo/sysinfo.h @@ -144,6 +144,7 @@ struct _Config_Item int have_battery; int have_power; int desktop_notifications; + Eina_List *handlers; #ifdef HAVE_EEZE Eeze_Udev_Watch *acwatch; Eeze_Udev_Watch *batwatch; @@ -172,6 +173,7 @@ struct _Config_Item Ecore_Thread *th; Eina_Bool have_temp:1; + Eina_List *handlers; } thermal; struct { @@ -189,6 +191,7 @@ struct _Config_Item Cpu_Status *status; Ecore_Thread *frequency_check_thread; Ecore_Event_Handler *handler; + Eina_List *handlers; } cpuclock; struct { @@ -205,6 +208,7 @@ struct _Config_Item Ecore_Thread *usage_check_thread; Eina_List *cores; + Eina_List *handlers; } cpumonitor; struct { @@ -222,6 +226,7 @@ struct _Config_Item unsigned long swp_total; unsigned long swp_used; Ecore_Thread *usage_check_thread; + Eina_List *handlers; } memusage; struct { @@ -244,6 +249,7 @@ struct _Config_Item Eina_Stringshare *instring; Eina_Stringshare *outstring; Ecore_Thread *usage_check_thread; + Eina_List *handlers; } netstatus; struct { Evas_Object *o_batman; diff --git a/src/modules/sysinfo/thermal/thermal.c b/src/modules/sysinfo/thermal/thermal.c index 467c7d6bf..22b9f33a8 100644 --- a/src/modules/sysinfo/thermal/thermal.c +++ b/src/modules/sysinfo/thermal/thermal.c @@ -102,7 +102,7 @@ _thermal_check_sysctl(void *data, Ecore_Thread *th) usleep((1000000.0 / 800.0) * (double)tth->poll_interval); else usleep((1000000.0 / 8.0) * (double)tth->poll_interval); - if (ecore_thread_check(th)) break; + if (ecore_thread_check(th)) break; } } #endif @@ -119,8 +119,12 @@ _thermal_check_fallback(void *data, Ecore_Thread *th) temp = thermal_fallback_get(tth); if (ptemp != temp) ecore_thread_feedback(th, (void *)((long)temp)); ptemp = temp; - usleep((1000000.0 / 8.0) * (double)tth->poll_interval); - if (ecore_thread_check(th)) break; + e_powersave_sleeper_sleep(tth->sleeper, tth->poll_interval); + if (e_powersave_mode_get() == E_POWERSAVE_MODE_FREEZE) + usleep((1000000.0 / 800.0) * (double)tth->poll_interval); + else + usleep((1000000.0 / 8.0) * (double)tth->poll_interval); + if (ecore_thread_check(th)) break; } } #endif @@ -233,6 +237,29 @@ _thermal_mouse_down_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UN e_gadget_configure(inst->o_main); } } +static Eina_Bool +_screensaver_on(void *data) +{ + Instance *inst = data; + + if (inst->cfg->thermal.th) + { + ecore_thread_cancel(inst->cfg->thermal.th); + inst->cfg->thermal.th = NULL; + } + return ECORE_CALLBACK_RENEW; +} + +static Eina_Bool +_screensaver_off(void *data) +{ + Instance *inst = data; + + _thermal_config_updated(inst); + + return ECORE_CALLBACK_RENEW; +} + void _thermal_config_updated(Instance *inst) @@ -302,6 +329,7 @@ static void _thermal_removed_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_data) { Instance *inst = data; + Ecore_Event_Handler *handler; if (inst->o_main != event_data) return; @@ -311,6 +339,8 @@ _thermal_removed_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_data) E_FREE_FUNC(inst->cfg->thermal.popup, evas_object_del); if (inst->cfg->thermal.configure) E_FREE_FUNC(inst->cfg->thermal.configure, evas_object_del); + EINA_LIST_FREE(inst->cfg->thermal.handlers, handler) + ecore_event_handler_del(handler); _thermal_face_shutdown(inst); evas_object_event_callback_del_full(inst->o_main, EVAS_CALLBACK_DEL, sysinfo_thermal_remove, data); @@ -323,6 +353,7 @@ void sysinfo_thermal_remove(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_data EINA_UNUSED) { Instance *inst = data; + Ecore_Event_Handler *handler; if (inst->cfg->thermal.popup_label) E_FREE_FUNC(inst->cfg->thermal.popup_label, evas_object_del); @@ -330,6 +361,8 @@ sysinfo_thermal_remove(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UN E_FREE_FUNC(inst->cfg->thermal.popup, evas_object_del); if (inst->cfg->thermal.configure) E_FREE_FUNC(inst->cfg->thermal.configure, evas_object_del); + EINA_LIST_FREE(inst->cfg->thermal.handlers, handler) + ecore_event_handler_del(handler); _thermal_face_shutdown(inst); } @@ -361,6 +394,10 @@ _thermal_created_cb(void *data, Evas_Object *obj, void *event_data EINA_UNUSED) evas_object_event_callback_add(inst->cfg->thermal.o_gadget, EVAS_CALLBACK_RESIZE, _thermal_resize_cb, inst); evas_object_show(inst->cfg->thermal.o_gadget); evas_object_smart_callback_del_full(obj, "gadget_created", _thermal_created_cb, data); + + E_LIST_HANDLER_APPEND(inst->cfg->thermal.handlers, E_EVENT_SCREENSAVER_ON, _screensaver_on, inst); + E_LIST_HANDLER_APPEND(inst->cfg->thermal.handlers, E_EVENT_SCREENSAVER_OFF, _screensaver_off, inst); + _thermal_config_updated(inst); } @@ -380,6 +417,10 @@ sysinfo_thermal_create(Evas_Object *parent, Instance *inst) _thermal_mouse_down_cb, inst); evas_object_event_callback_add(inst->cfg->thermal.o_gadget, EVAS_CALLBACK_RESIZE, _thermal_resize_cb, inst); evas_object_show(inst->cfg->thermal.o_gadget); + + E_LIST_HANDLER_APPEND(inst->cfg->thermal.handlers, E_EVENT_SCREENSAVER_ON, _screensaver_on, inst); + E_LIST_HANDLER_APPEND(inst->cfg->thermal.handlers, E_EVENT_SCREENSAVER_OFF, _screensaver_off, inst); + _thermal_config_updated(inst); return inst->cfg->thermal.o_gadget;