Hei,
Also, many userspace applications can work with that. Mplayer (and
other mediaplayers) for example regularly sends events to keep
xscreensaver disabled, thus keeping everything like it should be while
watching a movie without manually disabling the behaviour. This, like
all the things raster mentioned, would be desirable to keep with the
dim feature.
Here is the answer. Enclosed is the second version the patch
implementing the backlight dimming. Contrary to the first version, it is
based on the screensaver extension but the dimming will only work when
the screensaver is activated.
Cheers Mathieu
author : Mathieu Taillefumier (mathieu.taillefum...@free.fr)
Add automatic backlight dimming based on the screensaver extension.
e_backlight.c | 137 +++++++++++++++++++++++++++++++++++++++++++++++++---------
e_config.c | 1
e_config.h | 1
3 files changed, 119 insertions(+), 20 deletions(-)
Index: src/bin/e_config.c
===================================================================
--- src/bin/e_config.c (revision 60455)
+++ src/bin/e_config.c (working copy)
@@ -908,6 +908,7 @@
E_CONFIG_VAL(D, T, backlight.normal, DOUBLE);
E_CONFIG_VAL(D, T, backlight.dim, DOUBLE);
+ E_CONFIG_VAL(D, T, backlight.sleep, DOUBLE);
E_CONFIG_VAL(D, T, backlight.transition, DOUBLE);
e_config_load();
Index: src/bin/e_config.h
===================================================================
--- src/bin/e_config.h (revision 60455)
+++ src/bin/e_config.h (working copy)
@@ -348,6 +348,7 @@
double normal;
double dim;
double transition;
+ double sleep;
} backlight;
};
Index: src/bin/e_backlight.c
===================================================================
--- src/bin/e_backlight.c (revision 60455)
+++ src/bin/e_backlight.c (working copy)
@@ -16,6 +16,8 @@
static Ecore_Event_Handler *bl_sys_exit_handler = NULL;
static Ecore_Exe *bl_sys_set_exe = NULL;
static Eina_Bool bl_sys_pending_set = EINA_FALSE;
+static Ecore_Event_Handler *_bl_dimming_event_activity_check = NULL;
+static int _bl_log_dom = -1;
static void _e_backlight_update(E_Zone *zone);
static void _e_backlight_set(E_Zone *zone, double val);
@@ -26,10 +28,42 @@
static void _bl_sys_level_get(void);
static Eina_Bool _e_bl_cb_exit(void *data __UNUSED__, int type __UNUSED__,
void *event);
static void _bl_sys_level_set(double val);
+static Eina_Bool _bl_poll_activity_check(void *data __UNUSED__, int type
__UNUSED__, void *event);
+
+#ifdef ERR
+# undef ERR
+#endif /* ifdef ERR */
+#define ERR(...) EINA_LOG_DOM_ERR(_bl_log_dom, __VA_ARGS__)
+#ifdef DBG
+# undef DBG
+#endif /* ifdef DBG */
+#define DBG(...) EINA_LOG_DOM_DBG(_bl_log_dom, __VA_ARGS__)
+#ifdef INF
+# undef INF
+#endif /* ifdef INF */
+#define INF(...) EINA_LOG_DOM_INFO(_bl_log_dom, __VA_ARGS__)
+#ifdef WRN
+# undef WRN
+#endif /* ifdef WRN */
+#define WRN(...) EINA_LOG_DOM_WARN(_bl_log_dom, __VA_ARGS__)
+#ifdef CRIT
+# undef CRIT
+#endif /* ifdef CRIT */
+#define CRIT(...) EINA_LOG_DOM_CRIT(_bl_log_dom, __VA_ARGS__)
EINTERN int
e_backlight_init(void)
{
+ if(_bl_log_dom < 0)
+ {
+ _bl_log_dom = eina_log_domain_register("E17 Backlight", EINA_COLOR_BLUE);
+ if(_bl_log_dom < 0)
+ {
+ EINA_LOG_ERR("Enable to create a log domain for the backlight
extension");
+ return 0;
+ }
+ }
+
e_backlight_update();
e_backlight_level_set(NULL, 0.0, 0.0);
e_backlight_level_set(NULL, e_config->backlight.normal, 1.0);
@@ -47,6 +80,10 @@
bl_sys_exit_handler = NULL;
bl_sys_set_exe = NULL;
bl_sys_pending_set = EINA_FALSE;
+
+ ecore_event_handler_del(_bl_dimming_event_activity_check);
+ eina_log_domain_unregister(_bl_log_dom);
+ _bl_log_dom = -1;
return 1;
}
@@ -68,6 +105,11 @@
}
}
}
+
+ _bl_dimming_event_activity_check =
ecore_event_handler_add(ECORE_X_EVENT_SCREENSAVER_NOTIFY,
_bl_poll_activity_check, NULL);
+
+ if(!_bl_dimming_event_activity_check)
+ ERR("Backlight event Handler failure");
}
EAPI void
@@ -114,17 +156,27 @@
// zone == NULL == everything
if (bl_mode == mode) return;
bl_mode = mode;
- if (bl_mode == E_BACKLIGHT_MODE_NORMAL)
+ switch (bl_mode)
+ {
+ case E_BACKLIGHT_MODE_NORMAL:
e_backlight_level_set(zone, bl_val, -1.0);
- else if (bl_mode == E_BACKLIGHT_MODE_OFF)
+ break;
+ case E_BACKLIGHT_MODE_OFF:
e_backlight_level_set(zone, 0.0, -1.0);
- else if (bl_mode == E_BACKLIGHT_MODE_DIM)
- e_backlight_level_set(zone, 0.0, -1.0);
- else if (bl_mode == E_BACKLIGHT_MODE_DIM)
+ break;
+ case E_BACKLIGHT_MODE_MIN:
+ e_backlight_level_set(zone, e_config->backlight.sleep, -1.0);
+ break;
+ case E_BACKLIGHT_MODE_DIM:
e_backlight_level_set(zone, e_config->backlight.dim, -1.0);
- else if (bl_mode == E_BACKLIGHT_MODE_MAX)
+ break;
+ case E_BACKLIGHT_MODE_MAX:
e_backlight_level_set(zone, 1.0, -1.0);
+ break;
+ default:
+ break;
}
+}
EAPI E_Backlight_Mode
e_backlight_mode_get(E_Zone *zone __UNUSED__)
@@ -145,7 +197,7 @@
root = zone->container->manager->root;
// try randr
- out = ecore_x_randr_window_outputs_get(root, &num);
+ out = ecore_x_randr_outputs_get(root, &num);
if ((out) && (num > 0))
x_bl = ecore_x_randr_output_backlight_level_get(root, out[0]);
if (out) free(out);
@@ -168,26 +220,23 @@
static void
_e_backlight_set(E_Zone *zone, double val)
{
- if (sysmode == MODE_RANDR)
- {
Ecore_X_Window root;
- Ecore_X_Randr_Output *out;
- int num = 0;
+ switch(sysmode)
+ {
+ case MODE_RANDR:
root = zone->container->manager->root;
- out = ecore_x_randr_window_outputs_get(root, &num);
- if ((out) && (num > 0))
- {
- ecore_x_randr_output_backlight_level_set(root, out[0], val);
- }
- if (out) free(out);
- }
- else if (sysmode == MODE_SYS)
- {
+ ecore_x_randr_screen_backlight_level_set(root, val);
+ break;
+ case MODE_SYS:
if (bl_sysval)
{
_bl_sys_level_set(val);
}
+ break;
+ default:
+ WRN("No backlight properties for this screen");
+ break;
}
}
@@ -348,3 +397,51 @@
e_prefix_lib_get(), (int)(val * 1000.0));
bl_sys_set_exe = ecore_exe_run(buf, NULL);
}
+
+static Eina_Bool _bl_poll_activity_check(void *data __UNUSED__, int type
__UNUSED__, void *event)
+{
+ Eina_List *list;
+ Eina_List *iter;
+ Eina_List *m, *c, *z;
+ E_Manager *man;
+ E_Container *con;
+ E_Zone *zone;
+ Ecore_X_Event_Screensaver_Notify *e = event;
+ E_Backlight_Mode tmp_mode = bl_mode;
+ double tmp_value = 1.0;
+
+ if (!e->on)
+ {
+ tmp_mode = E_BACKLIGHT_MODE_DIM;
+ tmp_value = e_config->backlight.dim;
+ }
+
+ switch (tmp_mode)
+ {
+ case E_BACKLIGHT_MODE_NORMAL:
+ tmp_value = e_config->backlight.dim;
+ tmp_mode = E_BACKLIGHT_MODE_DIM;
+ break;
+ case E_BACKLIGHT_MODE_DIM:
+ default:
+ tmp_value = e_config->backlight.normal;
+ tmp_mode = E_BACKLIGHT_MODE_NORMAL;
+ break;
+ }
+
+ if (tmp_mode != bl_mode)
+ {
+ EINA_LIST_FOREACH(e_manager_list(), m, man)
+ {
+ EINA_LIST_FOREACH(man->containers, c, con)
+ {
+ EINA_LIST_FOREACH(con->zones, z, zone)
+ {
+ _e_backlight_set(zone, tmp_value);
+ }
+ }
+ }
+ bl_mode = tmp_mode;
+ }
+ return EINA_TRUE;
+}
------------------------------------------------------------------------------
EditLive Enterprise is the world's most technically advanced content
authoring tool. Experience the power of Track Changes, Inline Image
Editing and ensure content is compliant with Accessibility Checking.
http://p.sf.net/sfu/ephox-dev2dev
_______________________________________________
enlightenment-devel mailing list
enlightenment-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel