as I have no devices which contain a controllable backlight, someone else will have to test/fix this
SVN revision: 67487
static int sysmode = MODE_NONE;
static Ecore_Animator *bl_anim = NULL;
+static Ecore_Event_Handler *_e_backlight_handler_config_mode = NULL;
+static Ecore_Event_Handler *_e_backlight_handler_border_fullscreen = NULL;
+static Ecore_Event_Handler *_e_backlight_handler_border_unfullscreen = NULL;
+static Ecore_Event_Handler *_e_backlight_handler_border_remove = NULL;
+static Ecore_Event_Handler *_e_backlight_handler_border_iconify = NULL;
+static Ecore_Event_Handler *_e_backlight_handler_border_uniconify = NULL;
+static Ecore_Event_Handler *_e_backlight_handler_border_desk_set = NULL;
+static Ecore_Event_Handler *_e_backlight_handler_desk_show = NULL;
+
+static Ecore_Timer *_e_backlight_timer = NULL;
+
static void _e_backlight_update(E_Zone *zone);
static void _e_backlight_set(E_Zone *zone, double val);
static Eina_Bool _bl_anim(void *data, double pos);
static Eina_Bool bl_avail = EINA_FALSE;
+static Eina_Bool _e_backlight_handler(void *d, int type, void *ev);
+static Eina_Bool _e_backlight_timer_cb(void *d);
#ifdef HAVE_EEZE
static const char *bl_sysval = NULL;
static Ecore_Event_Handler *bl_sys_exit_handler = NULL;
// bl_avail = ecore_x_randr_output_backlight_available();
bl_avail = EINA_TRUE;
+ _e_backlight_handler_config_mode = ecore_event_handler_add
+ (E_EVENT_CONFIG_MODE_CHANGED, _e_backlight_handler, NULL);
+
+ _e_backlight_handler_border_fullscreen = ecore_event_handler_add
+ (E_EVENT_BORDER_FULLSCREEN, _e_backlight_handler, NULL);
+
+ _e_backlight_handler_border_unfullscreen = ecore_event_handler_add
+ (E_EVENT_BORDER_UNFULLSCREEN, _e_backlight_handler, NULL);
+
+ _e_backlight_handler_border_remove = ecore_event_handler_add
+ (E_EVENT_BORDER_REMOVE, _e_backlight_handler, NULL);
+
+ _e_backlight_handler_border_iconify = ecore_event_handler_add
+ (E_EVENT_BORDER_ICONIFY, _e_backlight_handler, NULL);
+
+ _e_backlight_handler_border_uniconify = ecore_event_handler_add
+ (E_EVENT_BORDER_UNICONIFY, _e_backlight_handler, NULL);
+
+ _e_backlight_handler_border_desk_set = ecore_event_handler_add
+ (E_EVENT_BORDER_DESK_SET, _e_backlight_handler, NULL);
+
+ _e_backlight_handler_desk_show = ecore_event_handler_add
+ (E_EVENT_DESK_SHOW, _e_backlight_handler, NULL);
+
// if (bl_avail == EINA_TRUE)
{
e_backlight_update();
bl_sys_pending_set = EINA_FALSE;
eeze_shutdown();
#endif
+ if (_e_backlight_handler_config_mode)
+ {
+ ecore_event_handler_del(_e_backlight_handler_config_mode);
+ _e_backlight_handler_config_mode = NULL;
+ }
+
+ if (_e_backlight_handler_border_fullscreen)
+ {
+ ecore_event_handler_del(_e_backlight_handler_border_fullscreen);
+ _e_backlight_handler_border_fullscreen = NULL;
+ }
+
+ if (_e_backlight_handler_border_unfullscreen)
+ {
+ ecore_event_handler_del(_e_backlight_handler_border_unfullscreen);
+ _e_backlight_handler_border_unfullscreen = NULL;
+ }
+
+ if (_e_backlight_handler_border_remove)
+ {
+ ecore_event_handler_del(_e_backlight_handler_border_remove);
+ _e_backlight_handler_border_remove = NULL;
+ }
+
+ if (_e_backlight_handler_border_iconify)
+ {
+ ecore_event_handler_del(_e_backlight_handler_border_iconify);
+ _e_backlight_handler_border_iconify = NULL;
+ }
+
+ if (_e_backlight_handler_border_uniconify)
+ {
+ ecore_event_handler_del(_e_backlight_handler_border_uniconify);
+ _e_backlight_handler_border_uniconify = NULL;
+ }
+
+ if (_e_backlight_handler_border_desk_set)
+ {
+ ecore_event_handler_del(_e_backlight_handler_border_desk_set);
+ _e_backlight_handler_border_desk_set = NULL;
+ }
+
+ if (_e_backlight_handler_desk_show)
+ {
+ ecore_event_handler_del(_e_backlight_handler_desk_show);
+ _e_backlight_handler_desk_show = NULL;
+ }
return 1;
}
E_Container *con;
E_Zone *zone;
- if (bl_avail == EINA_TRUE)
+ if (bl_avail == EINA_FALSE) return;
+
+ EINA_LIST_FOREACH(e_manager_list(), m, man)
{
- EINA_LIST_FOREACH(e_manager_list(), m, man)
+ EINA_LIST_FOREACH(man->containers, c, con)
{
- EINA_LIST_FOREACH(man->containers, c, con)
+ EINA_LIST_FOREACH(con->zones, z, zone)
{
- EINA_LIST_FOREACH(con->zones, z, zone)
- {
- _e_backlight_update(zone);
- }
+ _e_backlight_update(zone);
}
}
}
+
+ /* idle dimming disabled: clear timer */
+ if (!e_config->backlight.idle_dim)
+ {
+ if (_e_backlight_timer)
+ ecore_timer_del(_e_backlight_timer);
+ _e_backlight_timer = NULL;
+ return;
+ }
+ /* dimming enabled, timer active: update interval and reset */
+ if (_e_backlight_timer)
+ {
+ if (e_config->backlight.timer != ecore_timer_interval_get(_e_backlight_timer))
+ ecore_timer_interval_set(_e_backlight_timer, e_config->backlight.timer);
+ ecore_timer_reset(_e_backlight_timer);
+ return;
+ }
+ /* dimming enabled, timer inactive: */
+
+ /* timer is 0 seconds: return */
+ if (!e_config->backlight.timer) return;
+ /* current mode is dimmed: undim */
+ if (bl_mode == E_BACKLIGHT_MODE_DIM)
+ e_backlight_mode_set(NULL, E_BACKLIGHT_MODE_NORMAL);
+ _e_backlight_timer = ecore_timer_add(e_config->backlight.timer, _e_backlight_timer_cb, NULL);
}
EAPI void
/* local subsystem functions */
+static Eina_Bool
+_e_backlight_handler(void *d __UNUSED__, int type __UNUSED__, void *ev __UNUSED__)
+{
+ e_backlight_update();
+ return ECORE_CALLBACK_PASS_ON;
+}
+
+static Eina_Bool
+_e_backlight_timer_cb(void *d __UNUSED__)
+{
+ e_backlight_mode_set(NULL, E_BACKLIGHT_MODE_DIM);
+ _e_backlight_timer = NULL;
+ return EINA_FALSE;
+}
+
static void
_e_backlight_update(E_Zone *zone)
{
E_CONFIG_VAL(D, T, backlight.normal, DOUBLE);
E_CONFIG_VAL(D, T, backlight.dim, DOUBLE);
E_CONFIG_VAL(D, T, backlight.transition, DOUBLE);
+ E_CONFIG_VAL(D, T, backlight.idle_dim, UCHAR);
+ E_CONFIG_VAL(D, T, backlight.timer, DOUBLE);
E_CONFIG_VAL(D, T, deskenv.load_xrdb, UCHAR);
E_CONFIG_VAL(D, T, deskenv.load_xmodmap, UCHAR);
COPYVAL(backlight.normal);
COPYVAL(backlight.dim);
COPYVAL(backlight.transition);
+ COPYVAL(backlight.idle_dim);
+ COPYVAL(backlight.timer);
IFCFGEND;
IFCFG(0x0145);
/* increment this whenever a new set of config values are added but the users
* config doesn't need to be wiped - simply new values need to be put in
*/
-#define E_CONFIG_FILE_GENERATION 0x0147
+#define E_CONFIG_FILE_GENERATION 0x0148
#define E_CONFIG_FILE_VERSION ((E_CONFIG_FILE_EPOCH << 16) | E_CONFIG_FILE_GENERATION)
struct _E_Config
double normal; // GUI
double dim; // GUI
double transition; // GUI
+ unsigned char idle_dim; // GUI
+ double timer; // GUI
} backlight;
struct {
static void _cb_standby_slider_change(void *data, Evas_Object *obj);
static void _cb_suspend_slider_change(void *data, Evas_Object *obj);
static void _cb_off_slider_change(void *data, Evas_Object *obj);
+static void _cb_backlight_slider_change(void *data, Evas_Object *obj);
static int _e_int_config_dpms_available(void);
static int _e_int_config_dpms_capable(void);
Evas_Object *standby_slider;
Evas_Object *suspend_slider;
Evas_Object *off_slider;
+ Evas_Object *backlight_slider;
int enable_dpms;
int enable_standby;
int enable_suspend;
int enable_off;
+ int enable_idle_dim;
/*
* The following timeouts are represented as minutes
double backlight_normal;
double backlight_dim;
+ double backlight_timeout;
double backlight_transition;
};
cfdata->backlight_normal = e_config->backlight.normal * 100.0;
cfdata->backlight_dim = e_config->backlight.dim * 100.0;
cfdata->backlight_transition = e_config->backlight.transition;
+ cfdata->enable_idle_dim = e_config->backlight.idle_dim;
+ cfdata->backlight_timeout = e_config->backlight.timer;
}
static void
e_config->backlight.normal = cfdata->backlight_normal / 100.0;
e_config->backlight.dim = cfdata->backlight_dim / 100.0;
e_config->backlight.transition = cfdata->backlight_transition;
+ e_config->backlight.timer = cfdata->backlight_timeout;
e_backlight_mode_set(NULL, E_BACKLIGHT_MODE_NORMAL);
e_backlight_level_set(NULL, e_config->backlight.normal, -1.0);
(e_config->dpms_off_timeout / 60 != cfdata->off_timeout) ||
(e_config->backlight.normal * 100.0 != cfdata->backlight_normal) ||
(e_config->backlight.dim * 100.0 != cfdata->backlight_dim) ||
- (e_config->backlight.transition != cfdata->backlight_transition);
+ (e_config->backlight.transition != cfdata->backlight_transition) ||
+ (e_config->backlight.timer != cfdata->backlight_timeout);
}
static int
&(cfdata->backlight_dim), NULL, 100);
e_widget_list_object_append(o, ob, 1, 1, 0.5);
+ ob = e_widget_check_add(evas, _("Idle Fade Time"), &(cfdata->enable_off));
+ e_widget_list_object_append(o, ob, 1, 1, 0.5);
+ e_widget_disabled_set(ob, cfdata->enable_idle_dim); // set state from saved config
+ ob = e_widget_slider_add(evas, 1, 0, _("%1.0f minutes"), 0.5, 90.0, 1.0, 0,
+ &(cfdata->backlight_timeout), NULL, 100);
+ e_widget_on_change_hook_set(ob, _cb_backlight_slider_change, cfdata);
+ cfdata->backlight_slider = ob;
+ e_widget_disabled_set(ob, cfdata->enable_idle_dim); // set state from saved config
+ e_widget_list_object_append(o, ob, 1, 1, 0.5);
+
ob = e_widget_label_add(evas, _("Fade Time"));
e_widget_list_object_append(o, ob, 1, 1, 0.5);
ob = e_widget_slider_add(evas, 1, 0, _("%1.1f sec"), 0.0, 5.0, 0.1, 0,
}
static void
+_cb_backlight_slider_change(void *data, Evas_Object *obj __UNUSED__)
+{
+ E_Config_Dialog_Data *cfdata = data;
+
+ /* off-slider */
+ if (cfdata->backlight_timeout < cfdata->suspend_timeout)
+ {
+ cfdata->suspend_timeout = cfdata->backlight_timeout;
+ if (cfdata->suspend_slider)
+ e_widget_slider_value_double_set(cfdata->suspend_slider,
+ cfdata->suspend_timeout);
+
+ if (cfdata->suspend_timeout < cfdata->backlight_timeout)
+ {
+ cfdata->backlight_timeout = cfdata->suspend_timeout;
+ if (cfdata->backlight_slider)
+ e_widget_slider_value_double_set(cfdata->backlight_slider,
+ cfdata->backlight_timeout);
+ }
+ }
+ e_backlight_update();
+}
+
+static void
_cb_off_slider_change(void *data, Evas_Object *obj __UNUSED__)
{
E_Config_Dialog_Data *cfdata = data;
/* off-slider */
if (cfdata->off_timeout < cfdata->suspend_timeout)
{
- cfdata->suspend_timeout = cfdata->off_timeout;
- if (cfdata->suspend_slider)
- e_widget_slider_value_double_set(cfdata->suspend_slider,
- cfdata->suspend_timeout);
-
- if (cfdata->suspend_timeout < cfdata->standby_timeout)
- {
- cfdata->standby_timeout = cfdata->suspend_timeout;
- if (cfdata->standby_slider)
- e_widget_slider_value_double_set(cfdata->standby_slider,
- cfdata->standby_timeout);
- }
+ cfdata->suspend_timeout = cfdata->off_timeout;
+ if (cfdata->suspend_slider)
+ e_widget_slider_value_double_set(cfdata->suspend_slider,
+ cfdata->suspend_timeout);
+
+ if (cfdata->suspend_timeout < cfdata->standby_timeout)
+ {
+ cfdata->standby_timeout = cfdata->suspend_timeout;
+ if (cfdata->standby_slider)
+ e_widget_slider_value_double_set(cfdata->standby_slider,
+ cfdata->standby_timeout);
+ }
}
}