do not abuse _init(), provide _update() method instead.

SVN revision: 54794
devs/princeamd/enlightenment-0.17-elive
Gustavo Sverzut Barbieri 12 years ago
parent d374b7ccb8
commit c5642870c3
  1. 176
      src/bin/e_dpms.c
  2. 3
      src/bin/e_dpms.h
  3. 2
      src/bin/e_main.c
  4. 182
      src/bin/e_screensaver.c
  5. 3
      src/bin/e_screensaver.h

@ -9,88 +9,176 @@ static Ecore_Event_Handler *_e_dpms_handler_border_uniconify = NULL;
static Ecore_Event_Handler *_e_dpms_handler_border_desk_set = NULL;
static Ecore_Event_Handler *_e_dpms_handler_desk_show = NULL;
static unsigned int _e_dpms_timeout_standby = 0;
static unsigned int _e_dpms_timeout_suspend = 0;
static unsigned int _e_dpms_timeout_off = 0;
static int _e_dpms_enabled = EINA_FALSE;
EAPI void
e_dpms_update(void)
{
unsigned int standby = 0, suspend = 0, off = 0;
int enabled;
Eina_Bool changed = EINA_FALSE;
enabled = ((e_config->dpms_enable) && (!e_config->mode.presentation) &&
(!e_util_fullscreen_curreny_any()));
if (_e_dpms_enabled != enabled)
{
_e_dpms_enabled = enabled;
ecore_x_dpms_enabled_set(enabled);
}
if (!enabled) return;
if (e_config->dpms_standby_enable)
{
standby = e_config->dpms_standby_timeout;
if (_e_dpms_timeout_standby != standby)
{
_e_dpms_timeout_standby = standby;
changed = EINA_TRUE;
}
}
if (e_config->dpms_suspend_enable)
{
suspend = e_config->dpms_suspend_timeout;
if (_e_dpms_timeout_suspend != suspend)
{
_e_dpms_timeout_suspend = suspend;
changed = EINA_TRUE;
}
}
if (e_config->dpms_off_enable)
{
off = e_config->dpms_off_timeout;
if (_e_dpms_timeout_off != off)
{
_e_dpms_timeout_off = off;
changed = EINA_TRUE;
}
}
if (changed) ecore_x_dpms_timeouts_set(standby, suspend, off);
}
static Eina_Bool
_e_dpms_handler_config_mode_cb(void *data __UNUSED__, int type __UNUSED__, void *event __UNUSED__)
{
e_dpms_init();
e_dpms_update();
return ECORE_CALLBACK_PASS_ON;
}
static Eina_Bool
_e_dpms_handler_border_fullscreen_check_cb(void *data __UNUSED__, int type __UNUSED__, void *event __UNUSED__)
{
e_dpms_init();
e_dpms_update();
return ECORE_CALLBACK_PASS_ON;
}
static Eina_Bool
_e_dpms_handler_border_desk_set_cb(void *data __UNUSED__, int type __UNUSED__, void *event __UNUSED__)
{
e_dpms_init();
e_dpms_update();
return ECORE_CALLBACK_PASS_ON;
}
static Eina_Bool
_e_dpms_handler_desk_show_cb(void *data __UNUSED__, int type __UNUSED__, void *event __UNUSED__)
{
e_dpms_init();
e_dpms_update();
return ECORE_CALLBACK_PASS_ON;
}
EAPI int
e_dpms_init(void)
{
int standby = 0, suspend = 0, off = 0;
int enabled;
enabled = ((e_config->dpms_enable) && (!e_config->mode.presentation) &&
(!e_util_fullscreen_curreny_any()));
_e_dpms_handler_config_mode = ecore_event_handler_add
(E_EVENT_CONFIG_MODE_CHANGED, _e_dpms_handler_config_mode_cb, NULL);
if (!_e_dpms_handler_config_mode)
_e_dpms_handler_config_mode = ecore_event_handler_add
(E_EVENT_CONFIG_MODE_CHANGED, _e_dpms_handler_config_mode_cb, NULL);
_e_dpms_handler_border_fullscreen = ecore_event_handler_add
(E_EVENT_BORDER_FULLSCREEN, _e_dpms_handler_border_fullscreen_check_cb, NULL);
if (!_e_dpms_handler_border_fullscreen)
_e_dpms_handler_border_fullscreen = ecore_event_handler_add
(E_EVENT_BORDER_FULLSCREEN, _e_dpms_handler_border_fullscreen_check_cb, NULL);
_e_dpms_handler_border_unfullscreen = ecore_event_handler_add
(E_EVENT_BORDER_UNFULLSCREEN, _e_dpms_handler_border_fullscreen_check_cb, NULL);
if (!_e_dpms_handler_border_unfullscreen)
_e_dpms_handler_border_unfullscreen = ecore_event_handler_add
(E_EVENT_BORDER_UNFULLSCREEN, _e_dpms_handler_border_fullscreen_check_cb, NULL);
_e_dpms_handler_border_remove = ecore_event_handler_add
(E_EVENT_BORDER_REMOVE, _e_dpms_handler_border_fullscreen_check_cb, NULL);
if (!_e_dpms_handler_border_remove)
_e_dpms_handler_border_remove = ecore_event_handler_add
(E_EVENT_BORDER_REMOVE, _e_dpms_handler_border_fullscreen_check_cb, NULL);
_e_dpms_handler_border_iconify = ecore_event_handler_add
(E_EVENT_BORDER_ICONIFY, _e_dpms_handler_border_fullscreen_check_cb, NULL);
if (!_e_dpms_handler_border_iconify)
_e_dpms_handler_border_iconify = ecore_event_handler_add
(E_EVENT_BORDER_ICONIFY, _e_dpms_handler_border_fullscreen_check_cb, NULL);
_e_dpms_handler_border_uniconify = ecore_event_handler_add
(E_EVENT_BORDER_UNICONIFY, _e_dpms_handler_border_fullscreen_check_cb, NULL);
if (!_e_dpms_handler_border_uniconify)
_e_dpms_handler_border_uniconify = ecore_event_handler_add
(E_EVENT_BORDER_UNICONIFY, _e_dpms_handler_border_fullscreen_check_cb, NULL);
_e_dpms_handler_border_desk_set = ecore_event_handler_add
(E_EVENT_BORDER_DESK_SET, _e_dpms_handler_border_desk_set_cb, NULL);
if (!_e_dpms_handler_border_desk_set)
_e_dpms_handler_border_desk_set = ecore_event_handler_add
(E_EVENT_BORDER_DESK_SET, _e_dpms_handler_border_desk_set_cb, NULL);
_e_dpms_handler_desk_show = ecore_event_handler_add
(E_EVENT_DESK_SHOW, _e_dpms_handler_desk_show_cb, NULL);
if (!_e_dpms_handler_desk_show)
_e_dpms_handler_desk_show = ecore_event_handler_add
(E_EVENT_DESK_SHOW, _e_dpms_handler_desk_show_cb, NULL);
_e_dpms_enabled = ecore_x_dpms_enabled_get();
ecore_x_dpms_timeouts_get
(&_e_dpms_timeout_standby, &_e_dpms_timeout_suspend, &_e_dpms_timeout_off);
ecore_x_dpms_enabled_set(enabled);
if (!enabled) return 1;
e_dpms_update();
if (e_config->dpms_standby_enable)
standby = e_config->dpms_standby_timeout;
if (e_config->dpms_suspend_enable)
suspend = e_config->dpms_suspend_timeout;
if (e_config->dpms_off_enable)
off = e_config->dpms_off_timeout;
return 1;
}
ecore_x_dpms_timeouts_set(standby, suspend, off);
EAPI int
e_dpms_shutdown(void)
{
if (_e_dpms_handler_config_mode)
{
ecore_event_handler_del(_e_dpms_handler_config_mode);
_e_dpms_handler_config_mode = NULL;
}
if (_e_dpms_handler_border_fullscreen)
{
ecore_event_handler_del(_e_dpms_handler_border_fullscreen);
_e_dpms_handler_border_fullscreen = NULL;
}
if (_e_dpms_handler_border_unfullscreen)
{
ecore_event_handler_del(_e_dpms_handler_border_unfullscreen);
_e_dpms_handler_border_unfullscreen = NULL;
}
if (_e_dpms_handler_border_remove)
{
ecore_event_handler_del(_e_dpms_handler_border_remove);
_e_dpms_handler_border_remove = NULL;
}
if (_e_dpms_handler_border_iconify)
{
ecore_event_handler_del(_e_dpms_handler_border_iconify);
_e_dpms_handler_border_iconify = NULL;
}
if (_e_dpms_handler_border_uniconify)
{
ecore_event_handler_del(_e_dpms_handler_border_uniconify);
_e_dpms_handler_border_uniconify = NULL;
}
if (_e_dpms_handler_border_desk_set)
{
ecore_event_handler_del(_e_dpms_handler_border_desk_set);
_e_dpms_handler_border_desk_set = NULL;
}
if (_e_dpms_handler_desk_show)
{
ecore_event_handler_del(_e_dpms_handler_desk_show);
_e_dpms_handler_desk_show = NULL;
}
return 1;
}

@ -4,6 +4,9 @@
#define E_DPMS_H
EAPI int e_dpms_init(void);
EAPI int e_dpms_shutdown(void);
EAPI void e_dpms_update(void);
#endif
#endif

@ -800,6 +800,7 @@ main(int argc, char **argv)
e_error_message_show(_("Enlightenment cannot configure the X screensaver."));
_e_main_shutdown(-1);
}
_e_main_shutdown_push(e_screensaver_shutdown);
e_init_status_set(_("Setup Desklock"));
TS("desklock");
@ -983,6 +984,7 @@ main(int argc, char **argv)
e_error_message_show(_("Enlightenment cannot configure the DPMS settings."));
_e_main_shutdown(-1);
}
_e_main_shutdown_push(e_dpms_shutdown);
e_init_status_set(_("Setup Powersave modes"));
TS("powersave");

@ -12,10 +12,54 @@ static Ecore_Event_Handler *_e_screensaver_handler_desk_show = NULL;
static E_Dialog *_e_screensaver_ask_presentation_dia = NULL;
static int _e_screensaver_ask_presentation_count = 0;
static int _e_screensaver_timeout = 0;
static int _e_screensaver_interval = 0;
static int _e_screensaver_blanking = 0;
static int _e_screensaver_expose = 0;
EAPI void
e_screensaver_update(void)
{
int timeout = 0, interval = 0, blanking = 0, expose = 0;
int count = (1 + _e_screensaver_ask_presentation_count);
Eina_Bool changed = EINA_FALSE;
if ((e_config->screensaver_enable) && (!e_config->mode.presentation) &&
(!e_util_fullscreen_curreny_any()))
timeout = e_config->screensaver_timeout * count;
interval = e_config->screensaver_interval;
blanking = e_config->screensaver_blanking;
expose = e_config->screensaver_expose;
if (_e_screensaver_timeout != timeout)
{
_e_screensaver_timeout = timeout;
changed = EINA_TRUE;
}
if (_e_screensaver_interval != interval)
{
_e_screensaver_interval = interval;
changed = EINA_TRUE;
}
if (_e_screensaver_blanking != blanking)
{
_e_screensaver_blanking = blanking;
changed = EINA_TRUE;
}
if (_e_screensaver_expose != expose)
{
_e_screensaver_expose = expose;
changed = EINA_TRUE;
}
if (changed) ecore_x_screensaver_set(timeout, interval, blanking, expose);
}
static Eina_Bool
_e_screensaver_handler_config_mode_cb(void *data __UNUSED__, int type __UNUSED__, void *event __UNUSED__)
{
e_screensaver_init();
e_screensaver_update();
return ECORE_CALLBACK_PASS_ON;
}
@ -46,15 +90,8 @@ _e_screensaver_ask_presentation_no(void *data __UNUSED__, E_Dialog *dia)
static void
_e_screensaver_ask_presentation_no_increase(void *data __UNUSED__, E_Dialog *dia)
{
int timeout, interval, blanking, expose;
_e_screensaver_ask_presentation_count++;
timeout = e_config->screensaver_timeout * (1 + _e_screensaver_ask_presentation_count);
interval = e_config->screensaver_interval;
blanking = e_config->screensaver_blanking;
expose = e_config->screensaver_expose;
ecore_x_screensaver_set(timeout, interval, blanking, expose);
e_screensaver_update();
e_object_del(E_OBJECT(dia));
}
@ -149,73 +186,120 @@ _e_screensaver_handler_screensaver_notify_cb(void *data __UNUSED__, int type __U
static Eina_Bool
_e_screensaver_handler_border_fullscreen_check_cb(void *data __UNUSED__, int type __UNUSED__, void *event __UNUSED__)
{
e_screensaver_init();
e_screensaver_update();
return ECORE_CALLBACK_PASS_ON;
}
static Eina_Bool
_e_screensaver_handler_border_desk_set_cb(void *data __UNUSED__, int type __UNUSED__, void *event __UNUSED__)
{
e_screensaver_init();
e_screensaver_update();
return ECORE_CALLBACK_PASS_ON;
}
static Eina_Bool
_e_screensaver_handler_desk_show_cb(void *data __UNUSED__, int type __UNUSED__, void *event __UNUSED__)
{
e_screensaver_init();
e_screensaver_update();
return ECORE_CALLBACK_PASS_ON;
}
EAPI int
e_screensaver_init(void)
{
int timeout=0, interval=0, blanking=0, expose=0;
_e_screensaver_handler_config_mode = ecore_event_handler_add
(E_EVENT_CONFIG_MODE_CHANGED, _e_screensaver_handler_config_mode_cb, NULL);
if (!_e_screensaver_handler_config_mode)
_e_screensaver_handler_config_mode = ecore_event_handler_add
(E_EVENT_CONFIG_MODE_CHANGED, _e_screensaver_handler_config_mode_cb, NULL);
_e_screensaver_handler_screensaver_notify = ecore_event_handler_add
(ECORE_X_EVENT_SCREENSAVER_NOTIFY, _e_screensaver_handler_screensaver_notify_cb, NULL);
if (!_e_screensaver_handler_screensaver_notify)
_e_screensaver_handler_screensaver_notify = ecore_event_handler_add
(ECORE_X_EVENT_SCREENSAVER_NOTIFY, _e_screensaver_handler_screensaver_notify_cb, NULL);
_e_screensaver_handler_border_fullscreen = ecore_event_handler_add
(E_EVENT_BORDER_FULLSCREEN, _e_screensaver_handler_border_fullscreen_check_cb, NULL);
if (!_e_screensaver_handler_border_fullscreen)
_e_screensaver_handler_border_fullscreen = ecore_event_handler_add
(E_EVENT_BORDER_FULLSCREEN, _e_screensaver_handler_border_fullscreen_check_cb, NULL);
_e_screensaver_handler_border_unfullscreen = ecore_event_handler_add
(E_EVENT_BORDER_UNFULLSCREEN, _e_screensaver_handler_border_fullscreen_check_cb, NULL);
if (!_e_screensaver_handler_border_unfullscreen)
_e_screensaver_handler_border_unfullscreen = ecore_event_handler_add
(E_EVENT_BORDER_UNFULLSCREEN, _e_screensaver_handler_border_fullscreen_check_cb, NULL);
_e_screensaver_handler_border_remove = ecore_event_handler_add
(E_EVENT_BORDER_REMOVE, _e_screensaver_handler_border_fullscreen_check_cb, NULL);
if (!_e_screensaver_handler_border_remove)
_e_screensaver_handler_border_remove = ecore_event_handler_add
(E_EVENT_BORDER_REMOVE, _e_screensaver_handler_border_fullscreen_check_cb, NULL);
_e_screensaver_handler_border_iconify = ecore_event_handler_add
(E_EVENT_BORDER_ICONIFY, _e_screensaver_handler_border_fullscreen_check_cb, NULL);
if (!_e_screensaver_handler_border_iconify)
_e_screensaver_handler_border_iconify = ecore_event_handler_add
(E_EVENT_BORDER_ICONIFY, _e_screensaver_handler_border_fullscreen_check_cb, NULL);
_e_screensaver_handler_border_uniconify = ecore_event_handler_add
(E_EVENT_BORDER_UNICONIFY, _e_screensaver_handler_border_fullscreen_check_cb, NULL);
if (!_e_screensaver_handler_border_uniconify)
_e_screensaver_handler_border_uniconify = ecore_event_handler_add
(E_EVENT_BORDER_UNICONIFY, _e_screensaver_handler_border_fullscreen_check_cb, NULL);
_e_screensaver_handler_border_desk_set = ecore_event_handler_add
(E_EVENT_BORDER_DESK_SET, _e_screensaver_handler_border_desk_set_cb, NULL);
if (!_e_screensaver_handler_border_desk_set)
_e_screensaver_handler_border_desk_set = ecore_event_handler_add
(E_EVENT_BORDER_DESK_SET, _e_screensaver_handler_border_desk_set_cb, NULL);
_e_screensaver_handler_desk_show = ecore_event_handler_add
(E_EVENT_DESK_SHOW, _e_screensaver_handler_desk_show_cb, NULL);
if (!_e_screensaver_handler_desk_show)
_e_screensaver_handler_desk_show = ecore_event_handler_add
(E_EVENT_DESK_SHOW, _e_screensaver_handler_desk_show_cb, NULL);
_e_screensaver_timeout = ecore_x_screensaver_timeout_get();
_e_screensaver_interval = ecore_x_screensaver_interval_get();
_e_screensaver_blanking = ecore_x_screensaver_blank_get();
_e_screensaver_expose = ecore_x_screensaver_expose_get();
e_screensaver_update();
return 1;
}
EAPI int
e_screensaver_shutdown(void)
{
if (_e_screensaver_handler_config_mode)
{
ecore_event_handler_del(_e_screensaver_handler_config_mode);
_e_screensaver_handler_config_mode = NULL;
}
if (_e_screensaver_handler_screensaver_notify)
{
ecore_event_handler_del(_e_screensaver_handler_screensaver_notify);
_e_screensaver_handler_screensaver_notify = NULL;
}
if (_e_screensaver_handler_border_fullscreen)
{
ecore_event_handler_del(_e_screensaver_handler_border_fullscreen);
_e_screensaver_handler_border_fullscreen = NULL;
}
if (_e_screensaver_handler_border_unfullscreen)
{
ecore_event_handler_del(_e_screensaver_handler_border_fullscreen);
_e_screensaver_handler_border_fullscreen = NULL;
}
if (_e_screensaver_handler_border_remove)
{
ecore_event_handler_del(_e_screensaver_handler_border_fullscreen);
_e_screensaver_handler_border_fullscreen = NULL;
}
if (_e_screensaver_handler_border_iconify)
{
ecore_event_handler_del(_e_screensaver_handler_border_fullscreen);
_e_screensaver_handler_border_fullscreen = NULL;
}
if (_e_screensaver_handler_border_uniconify)
{
ecore_event_handler_del(_e_screensaver_handler_border_fullscreen);
_e_screensaver_handler_border_fullscreen = NULL;
}
if (_e_screensaver_handler_border_desk_set)
{
ecore_event_handler_del(_e_screensaver_handler_border_fullscreen);
_e_screensaver_handler_border_fullscreen = NULL;
}
if (_e_screensaver_handler_desk_show)
{
ecore_event_handler_del(_e_screensaver_handler_border_fullscreen);
_e_screensaver_handler_border_fullscreen = NULL;
}
if ((e_config->screensaver_enable) && (!e_config->mode.presentation) &&
(!e_util_fullscreen_curreny_any()))
timeout = e_config->screensaver_timeout;
interval = e_config->screensaver_interval;
blanking = e_config->screensaver_blanking;
expose = e_config->screensaver_expose;
ecore_x_screensaver_set(timeout, interval, blanking, expose);
return 1;
}

@ -4,6 +4,9 @@
#define E_SCREENSAVER_H
EAPI int e_screensaver_init(void);
EAPI int e_screensaver_shutdown(void);
EAPI void e_screensaver_update(void);
#endif
#endif

Loading…
Cancel
Save