backlight config tab, module, slider and core in. somehow doesnt work

with hal atm even tho i think i sent the right dbus req. hmmm. get
response.. of 0 for getting bl. for xrandr it works.



SVN revision: 60242
devs/princeamd/enlightenment-0.17-elive
Carsten Haitzler 12 years ago
parent c6d8fa89c9
commit 26a35cdf01
  1. 3
      configure.ac
  2. 22
      data/themes/default.edc
  3. 3
      data/themes/images/Makefile.am
  4. BIN
      data/themes/images/bulb.png
  5. 2
      src/bin/Makefile.am
  6. 68
      src/bin/e_actions.c
  7. 373
      src/bin/e_backlight.c
  8. 36
      src/bin/e_backlight.h
  9. 4
      src/bin/e_config.c
  10. 6
      src/bin/e_config.h
  11. 1
      src/bin/e_includes.h
  12. 10
      src/bin/e_main.c
  13. 1
      src/bin/e_widget_slider.c
  14. 3
      src/modules/Makefile.am
  15. 7
      src/modules/backlight/.cvsignore
  16. 28
      src/modules/backlight/Makefile.am
  17. BIN
      src/modules/backlight/e-module-backlight.edj
  18. 283
      src/modules/backlight/e_mod_main.c
  19. 10
      src/modules/backlight/e_mod_main.h
  20. 6
      src/modules/backlight/module.desktop.in
  21. 71
      src/modules/conf_display/e_int_config_dpms.c

@ -711,6 +711,7 @@ AC_E_OPTIONAL_MODULE([everything], true)
AC_E_OPTIONAL_MODULE([systray], true)
AC_E_OPTIONAL_MODULE([comp], true)
AC_E_OPTIONAL_MODULE([shot], true)
AC_E_OPTIONAL_MODULE([backlight], true)
SUSPEND=""
HIBERNATE=""
@ -856,6 +857,8 @@ src/modules/comp/Makefile
src/modules/comp/module.desktop
src/modules/shot/Makefile
src/modules/shot/module.desktop
src/modules/backlight/Makefile
src/modules/backlight/module.desktop
src/preload/Makefile
data/Makefile
data/images/Makefile

@ -11882,10 +11882,30 @@ collections {
}
/////////////////////////////////////////////////////////////////////////////
/*** MOD: BACKLIGHT ***/
group { name: "e/modules/backlight/main";
images {
image: "bulb.png" COMP;
}
min: 16 16;
max: 128 128;
parts {
part {
name: "base";
description {
state: "default" 0.0;
aspect: 1.0 1.0;
aspect_preference: BOTH;
image.normal: "bulb.png";
}
}
}
}
/////////////////////////////////////////////////////////////////////////////
#define CLOCK_SECONDS 1
/*** MOD: CLOCK ***/
group { name: "e/modules/clock/digital";
min: 56 16;
max: 512 128;

@ -453,4 +453,5 @@ flip_pmb.png \
flip_pmt.png \
flip_shad.png \
flip_t.png \
flip_colon.png
flip_colon.png \
bulb.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

@ -37,6 +37,7 @@ e_acpi.h \
e_actions.h \
e_alert.h \
e_atoms.h \
e_backlight.h \
e_bg.h \
e_bindings.h \
e_border.h \
@ -184,6 +185,7 @@ e_acpi.c \
e_actions.c \
e_alert.c \
e_atoms.c \
e_backlight.c \
e_bg.c \
e_bindings.c \
e_border.c \

@ -1237,14 +1237,13 @@ _e_actions_zone_get(E_Object *obj)
{
if (obj)
{
if (obj->type == E_MANAGER_TYPE)
return e_util_zone_current_get((E_Manager *)obj);
else if (obj->type == E_CONTAINER_TYPE)
return e_util_zone_current_get(((E_Container *)obj)->manager);
else if (obj->type == E_ZONE_TYPE)
return e_util_zone_current_get(((E_Zone *)obj)->container->manager);
else
return e_util_zone_current_get(e_manager_current_get());
if (obj->type == (int)E_MANAGER_TYPE) return e_util_zone_current_get((E_Manager *)obj);
else if (obj->type == (int)E_CONTAINER_TYPE) return e_util_zone_current_get(((E_Container *)obj)->manager);
else if (obj->type == (int)E_ZONE_TYPE) return (E_Zone *)obj;
else if (obj->type == (int)E_BORDER_TYPE) return ((E_Border *)obj)->zone;
else if (obj->type == (int)E_SHELF_TYPE) return ((E_Shelf *)obj)->zone;
else if (obj->type == (int)E_POPUP_TYPE) return ((E_Popup *)obj)->zone;
else if (obj->type == (int)E_WIN_TYPE) return ((E_Win *)obj)->border->zone;
}
return e_util_zone_current_get(e_manager_current_get());
}
@ -2635,12 +2634,30 @@ ACT_FN_END_MOUSE(delayed_action, )
ACT_FN_GO_ACPI(dim_screen, __UNUSED__)
{
printf("Dim Screen\n");
E_Zone *zone = _e_actions_zone_get(obj);
e_backlight_mode_set(zone, E_BACKLIGHT_MODE_DIM);
}
ACT_FN_GO_ACPI(undim_screen, __UNUSED__)
{
printf("Undim Screen\n");
E_Zone *zone = _e_actions_zone_get(obj);
e_backlight_mode_set(zone, E_BACKLIGHT_MODE_NORMAL);
}
ACT_FN_GO_ACPI(backlight_set, )
{
E_Zone *zone = _e_actions_zone_get(obj);
double v = atof(params);
e_backlight_mode_set(zone, E_BACKLIGHT_MODE_NORMAL);
e_backlight_level_set(zone, v, -1.0);
}
ACT_FN_GO_ACPI(backlight_adjust, )
{
E_Zone *zone = _e_actions_zone_get(obj);
double v = atof(params);
e_backlight_mode_set(zone, E_BACKLIGHT_MODE_NORMAL);
e_backlight_level_set(zone, e_backlight_level_get(zone) + v, -1.0);
}
/* local subsystem globals */
@ -2933,6 +2950,29 @@ e_actions_init(void)
"screen_send_by", NULL,
"syntax: N-offset, example: -2", 1);
ACT_GO_ACPI(dim_screen);
e_action_predef_name_set(N_("Screen"), N_("Dim"), "dim_screen",
NULL, NULL, 0);
ACT_GO_ACPI(undim_screen);
e_action_predef_name_set(N_("Screen"), N_("Undim"), "undim_screen",
NULL, NULL, 0);
ACT_GO_ACPI(backlight_set);
e_action_predef_name_set(N_("Screen"), N_("Backlight Set"), "backlight_set",
NULL, "syntax: brightness(0.0 - 1.0), example: 0.5", 1);
e_action_predef_name_set(N_("Screen"), N_("Backlight Min"), "backlight_set",
"0.0", NULL, 0);
e_action_predef_name_set(N_("Screen"), N_("Backlight Mid"), "backlight_set",
"0.5", NULL, 0);
e_action_predef_name_set(N_("Screen"), N_("Backlight Max"), "backlight_set",
"1.0", NULL, 0);
ACT_GO_ACPI(backlight_adjust);
e_action_predef_name_set(N_("Screen"), N_("Backlight Adjust"), "backlight_adjust",
NULL, "syntax: brightness(-1.0 - 1.0), example: -0.2", 1);
e_action_predef_name_set(N_("Screen"), N_("Backlight Up"), "backlight_adjust",
"0.1", NULL, 0);
e_action_predef_name_set(N_("Screen"), N_("Backlight Down"), "backlight_adjust",
"-0.1", NULL, 0);
/* window_move_to_center */
ACT_GO(window_move_to_center);
e_action_predef_name_set(N_("Window : Actions"), N_("Move To Center"),
@ -3077,14 +3117,6 @@ e_actions_init(void)
ACT_END_KEY(delayed_action);
ACT_END_MOUSE(delayed_action);
ACT_GO_ACPI(dim_screen);
e_action_predef_name_set(N_("Acpi"), N_("Dim Screen"), "dim_screen",
NULL, NULL, 0);
ACT_GO_ACPI(undim_screen);
e_action_predef_name_set(N_("Acpi"), N_("Undim Screen"), "undim_screen",
NULL, NULL, 0);
return 1;
}

@ -0,0 +1,373 @@
#include "e.h"
#include <E_DBus.h>
#include <E_Hal.h>
// FIXME: backlight should be tied per zone but this implementation is just
// a signleton right now as thats 99% of use cases. but api supports
// doing more. for now make it work in the singleton
// FIXME: backlight should have config values for:
// 1. normal mode (eg on login/ start of e)
// 2. dim level (eg 0.5)
// 3. anim slide time (eg 0.5)
// FIXME: tried using hal backlight stuff... doesn't work
//#define HAL_BL 1
#define MODE_RANDR 0
#define MODE_HAL 1
static double bl_val = 1.0;
static double bl_animval = 1.0;
static E_Backlight_Mode bl_mode = E_BACKLIGHT_MODE_NORMAL;
static int sysmode = MODE_RANDR;
static Ecore_Animator *bl_anim = NULL;
#ifdef HAL_BL
static E_DBus_Connection *_hal_conn = NULL;
static const char *_hal_bl_dev = NULL;
static const char *_hal_bl_iface = NULL;
static int _hal_nlevels = 1;
#endif
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);
EINTERN int
e_backlight_init(void)
{
e_backlight_update();
e_backlight_level_set(NULL, 0.0, 0.0);
e_backlight_level_set(NULL, e_config->backlight.normal, 1.0);
return 1;
}
EINTERN int
e_backlight_shutdown(void)
{
#ifdef HAL_BL
if (_hal_conn)
{
e_dbus_connection_close(_hal_conn);
_hal_conn = NULL;
e_hal_shutdown();
e_dbus_shutdown();
if (_hal_bl_dev)
{
eina_stringshare_del(_hal_bl_dev);
_hal_bl_dev = NULL;
}
if (_hal_bl_iface)
{
eina_stringshare_del(_hal_bl_iface);
_hal_bl_iface = NULL;
}
}
#endif
if (bl_anim) ecore_animator_del(bl_anim);
bl_anim = NULL;
return 1;
}
EAPI void
e_backlight_update(void)
{
Eina_List *m, *c, *z;
E_Manager *man;
E_Container *con;
E_Zone *zone;
EINA_LIST_FOREACH(e_manager_list(), m, man)
{
EINA_LIST_FOREACH(man->containers, c, con)
{
EINA_LIST_FOREACH(con->zones, z, zone)
{
_e_backlight_update(zone);
}
}
}
}
EAPI void
e_backlight_level_set(E_Zone *zone, double val, double tim)
{
double bl_now;
// zone == NULL == everything
// set backlight associated with zone to val over period of tim
// if tim == 0.0 - then do it instantnly, if time == -1 use some default
// transition time
if (!zone) e_backlight_update();
else _e_backlight_update(zone);
if (val == bl_val) return;
if (!zone) zone = e_util_zone_current_get(e_manager_current_get());
bl_now = bl_val;
bl_val = val;
if (bl_mode != E_BACKLIGHT_MODE_NORMAL) return;
if (tim < 0.0) tim = e_config->backlight.transition;
// FIXME: save bl level for normal
if (tim == 0.0)
{
if (bl_anim)
{
ecore_animator_del(bl_anim);
bl_anim = NULL;
}
_e_backlight_set(zone, val);
return;
}
if (bl_anim) ecore_animator_del(bl_anim);
bl_anim = ecore_animator_timeline_add(tim, _bl_anim, zone);
bl_animval = bl_now;
}
EAPI double
e_backlight_level_get(E_Zone *zone)
{
// zone == NULL == everything
if (!zone) e_backlight_update();
else _e_backlight_update(zone);
return bl_val;
}
EAPI void
e_backlight_mode_set(E_Zone *zone, E_Backlight_Mode mode)
{
// zone == NULL == everything
if (bl_mode == mode) return;
bl_mode = mode;
if (bl_mode == E_BACKLIGHT_MODE_NORMAL)
e_backlight_level_set(zone, bl_val, -1.0);
else if (bl_mode == 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)
e_backlight_level_set(zone, e_config->backlight.dim, -1.0);
else if (bl_mode == E_BACKLIGHT_MODE_MAX)
e_backlight_level_set(zone, 1.0, -1.0);
}
EAPI E_Backlight_Mode
e_backlight_mode_get(E_Zone *zone __UNUSED__)
{
// zone == NULL == everything
return bl_mode;
}
/* local subsystem functions */
#ifdef HAL_BL
void
_e_backlight_hal_val_reply(void *data __UNUSED__,
DBusMessage *reply,
DBusError *error)
{
dbus_uint32_t val;
if (dbus_error_is_set(error))
{
printf("Error: %s - %s\n", error->name, error->message);
return;
}
dbus_message_get_args(reply, error, DBUS_TYPE_UINT32,
&val, DBUS_TYPE_INVALID);
printf("Received: %i\n", val);
}
static void
_e_backlight_hal_val_get(void)
{
DBusMessage *msg;
if (!_hal_bl_dev) return;
msg = dbus_message_new_method_call
("org.freedesktop.Hal",
_hal_bl_dev,
_hal_bl_iface,
"GetBrightness"
);
e_dbus_message_send(_hal_conn, msg, _e_backlight_hal_val_reply, -1, NULL);
dbus_message_unref(msg);
}
static void
_e_backlight_hal_val_set(double val)
{
DBusMessage *msg;
dbus_uint32_t ival = 0;
if (!_hal_bl_dev) return;
msg = dbus_message_new_method_call
("org.freedesktop.Hal",
_hal_bl_dev,
_hal_bl_iface,
"SetBrightness"
);
ival = val * (_hal_nlevels - 1);
printf("hal set %i\n", ival);
dbus_message_append_args(msg, DBUS_TYPE_UINT32, &ival, DBUS_TYPE_INVALID);
dbus_message_set_no_reply(msg, EINA_TRUE);
e_dbus_message_send(_hal_conn, msg, NULL, -1, NULL);
dbus_message_unref(msg);
}
static void
_e_backlight_prop(void *data __UNUSED__,
void *reply_data,
DBusError *error)
{
E_Hal_Properties *ret = reply_data;
int err;
int nlevels;
const Eina_List *sl;
if (!ret) goto error;
if (dbus_error_is_set(error))
{
dbus_error_free(error);
goto error;
}
nlevels = e_hal_property_bool_get(ret, "laptop_panel.num_levels", &err);
if (err) goto error;
_hal_nlevels = nlevels;
printf("nlevels: %i\n", nlevels);
sl = e_hal_property_strlist_get(ret, "info.interfaces", &err);
if (err) goto error;
if (sl)
{
if (_hal_bl_iface) eina_stringshare_del(_hal_bl_iface);
_hal_bl_iface = eina_stringshare_add(sl->data);
printf("%s\n", _hal_bl_iface);
}
_e_backlight_hal_val_get();
return;
error:
if (_hal_bl_dev)
{
eina_stringshare_del(_hal_bl_dev);
_hal_bl_dev = NULL;
}
if (_hal_bl_iface)
{
eina_stringshare_del(_hal_bl_iface);
_hal_bl_iface = NULL;
}
}
static void
_e_backlight_panel_found(void *user_data __UNUSED__,
void *reply_data,
DBusError *error)
{
E_Hal_Manager_Find_Device_By_Capability_Return *ret = reply_data;
Eina_List *l;
char *device;
if (!ret || !ret->strings) return;
if (dbus_error_is_set(error))
{
dbus_error_free(error);
return;
}
if (!_hal_bl_dev)
{
EINA_LIST_FOREACH(ret->strings, l, device)
{
printf("BL+: %s\n", device);
if (!_hal_bl_dev) _hal_bl_dev = eina_stringshare_add(device);
}
}
if (_hal_bl_dev)
{
e_hal_device_get_all_properties(_hal_conn, _hal_bl_dev,
_e_backlight_prop, NULL);
}
}
#endif
static void
_e_backlight_update(E_Zone *zone)
{
double x_bl = -1.0;
Ecore_X_Window root;
Ecore_X_Randr_Output *out;
int num = 0;
root = zone->container->manager->root;
// try randr
out = ecore_x_randr_window_outputs_get(root, &num);
if ((out) && (num > 0))
x_bl = ecore_x_randr_output_backlight_level_get(root, out[0]);
if (out) free(out);
if (x_bl >= 0.0)
{
bl_val = x_bl;
sysmode = MODE_RANDR;
}
else
{
#ifdef HAL_BL
sysmode = MODE_HAL;
if (!_hal_conn)
{
e_dbus_init();
e_hal_init();
_hal_conn = e_dbus_bus_get(DBUS_BUS_SYSTEM);
}
if (_hal_conn)
{
if (!_hal_bl_dev)
e_hal_manager_find_device_by_capability
(_hal_conn, "laptop_panel",
_e_backlight_panel_found, NULL);
}
#endif
}
}
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;
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_HAL)
{
#ifdef HAL_BL
_e_backlight_hal_val_set(val);
#endif
}
}
static Eina_Bool
_bl_anim(void *data, double pos)
{
E_Zone *zone = data;
double v;
// FIXME: if zone is deleted while anim going... bad things.
pos = ecore_animator_pos_map(pos, ECORE_POS_MAP_DECELERATE, 0.0, 0.0);
v = (bl_animval * (1.0 - pos)) + (bl_val *pos);
_e_backlight_set(zone, v);
if (pos >= 1.0)
{
bl_anim = NULL;
return EINA_FALSE;
}
return EINA_TRUE;
}

@ -0,0 +1,36 @@
#ifdef E_TYPEDEFS
//typedef struct _E_Screen E_Screen;
typedef enum _E_Backlight_Mode
{
E_BACKLIGHT_MODE_NORMAL = 0,
E_BACKLIGHT_MODE_OFF = 1,
E_BACKLIGHT_MODE_MIN = 2,
E_BACKLIGHT_MODE_DIM = 3,
E_BACKLIGHT_MODE_MAX = 4
// for the future. right now not working as we'd need an optical
// sensor support framework
// E_BACKLIGHT_MODE_AUTO = 5
} E_Backlight_Mode;
#else
#ifndef E_BACKLIGHT_H
#define E_BACKLIGHT_H
//struct _E_Screen
//{
// int screen, escreen;
// int x, y, w, h;
//};
EINTERN int e_backlight_init(void);
EINTERN int e_backlight_shutdown(void);
EAPI void e_backlight_update(void);
EAPI void e_backlight_level_set(E_Zone *zone, double val, double tim);
EAPI double e_backlight_level_get(E_Zone *zone);
EAPI void e_backlight_mode_set(E_Zone *zone, E_Backlight_Mode mode);
EAPI E_Backlight_Mode e_backlight_mode_get(E_Zone *zone);
#endif
#endif

@ -906,6 +906,10 @@ e_config_init(void)
E_CONFIG_LIST(D, T, env_vars, _e_config_env_var_edd);
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_load();
e_config_save_queue();

@ -343,6 +343,12 @@ struct _E_Config
unsigned char null_container_win;
Eina_List *env_vars;
struct {
double normal;
double dim;
double transition;
} backlight;
};
struct _E_Config_Env_Var

@ -138,3 +138,4 @@
#include "e_widget_toolbook.h"
#include "e_acpi.h"
#include "e_env.h"
#include "e_backlight.h"

@ -959,6 +959,16 @@ main(int argc, char **argv)
e_acpi_init();
_e_main_shutdown_push(e_acpi_shutdown);
e_init_status_set(_("Setup Backlight"));
TS("backlight");
/* setup dpms */
if (!e_backlight_init())
{
e_error_message_show(_("Enlightenment cannot configure the backlight."));
_e_main_shutdown(-1);
}
_e_main_shutdown_push(e_backlight_shutdown);
e_init_status_set(_("Setup DPMS"));
TS("dpms");
/* setup dpms */

@ -223,6 +223,7 @@ _e_wid_cb_changed(void *data, Evas_Object *obj __UNUSED__, void *event_info __UN
if (wd->dval) *(wd->dval) = e_slider_value_get(wd->o_slider);
else if (wd->ival) *(wd->ival) = e_slider_value_get(wd->o_slider);
e_widget_change(wd->o_widget);
evas_object_smart_callback_call(wd->o_widget, "changed", NULL);
}
static void

@ -175,3 +175,6 @@ if USE_MODULE_SHOT
SUBDIRS += shot
endif
if USE_MODULE_BACKLIGHT
SUBDIRS += backlight
endif

@ -0,0 +1,7 @@
.deps
.libs
Makefile
Makefile.in
*.lo
module.la
module.desktop

@ -0,0 +1,28 @@
MAINTAINERCLEANFILES = Makefile.in
MODULE = backlight
# data files for the module
filesdir = $(libdir)/enlightenment/modules/$(MODULE)
files_DATA = \
e-module-$(MODULE).edj module.desktop
EXTRA_DIST = $(files_DATA)
# the module .so file
INCLUDES = -I. \
-I$(top_srcdir) \
-I$(top_srcdir)/src/modules/$(MODULE) \
-I$(top_srcdir)/src/bin \
-I$(top_builddir)/src/bin \
-I$(top_srcdir)/src/modules \
@e_cflags@
pkgdir = $(libdir)/enlightenment/modules/$(MODULE)/$(MODULE_ARCH)
pkg_LTLIBRARIES = module.la
module_la_SOURCES = e_mod_main.c \
e_mod_main.h
module_la_LIBADD = @e_libs@ @dlopen_libs@
module_la_LDFLAGS = -module -avoid-version
module_la_DEPENDENCIES = $(top_builddir)/config.h
uninstall:
rm -rf $(DESTDIR)$(libdir)/enlightenment/modules/$(MODULE)

@ -0,0 +1,283 @@
#include "e.h"
#include "e_mod_main.h"
/* gadcon requirements */
static E_Gadcon_Client *_gc_init(E_Gadcon *gc, const char *name, const char *id, const char *style);
static void _gc_shutdown(E_Gadcon_Client *gcc);
static void _gc_orient(E_Gadcon_Client *gcc, E_Gadcon_Orient orient);
static char *_gc_label(E_Gadcon_Client_Class *client_class);
static Evas_Object *_gc_icon(E_Gadcon_Client_Class *client_class, Evas *evas);
static const char *_gc_id_new(E_Gadcon_Client_Class *client_class);
/* and actually define the gadcon class that this module provides (just 1) */
static const E_Gadcon_Client_Class _gadcon_class =
{
GADCON_CLIENT_CLASS_VERSION,
"backlight",
{
_gc_init, _gc_shutdown, _gc_orient, _gc_label, _gc_icon, _gc_id_new, NULL, NULL
},
E_GADCON_CLIENT_STYLE_PLAIN
};
/* actual module specifics */
typedef struct _Instance Instance;
struct _Instance
{
E_Gadcon_Client *gcc;
Evas_Object *o_backlight, *o_table, *o_slider;
E_Gadcon_Popup *popup;
E_Menu *menu;
double val;
};
static Eina_List *backlight_instances = NULL;
static E_Module *backlight_module = NULL;
static void
_backlight_settings_cb(void *d1, void *d2 __UNUSED__)
{
Instance *inst = d1;
e_configure_registry_call("screen/power_management",
inst->gcc->gadcon->zone->container, NULL);
e_object_del(E_OBJECT(inst->popup));
inst->popup = NULL;
}
static void
_slider_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
{
Instance *inst = data;
e_backlight_mode_set(inst->gcc->gadcon->zone, E_BACKLIGHT_MODE_NORMAL);
e_backlight_level_set(inst->gcc->gadcon->zone, inst->val, 0.0);
}
static void
_backlight_popup_new(Instance *inst)
{
Evas *evas;
Evas_Object *o;
if (inst->popup) return;
e_backlight_update();
e_backlight_mode_set(inst->gcc->gadcon->zone, E_BACKLIGHT_MODE_NORMAL);
inst->val = e_backlight_level_get(inst->gcc->gadcon->zone);
inst->popup = e_gadcon_popup_new(inst->gcc);
evas = inst->popup->win->evas;
inst->o_table = e_widget_table_add(evas, 0);
o = e_widget_slider_add(evas, 0, 0, NULL, 0.0, 1.0, 0.0, 0, &(inst->val), NULL, 200);
evas_object_smart_callback_add(o, "changed", _slider_cb, inst);
inst->o_slider = o;
e_widget_table_object_align_append(inst->o_table, o,
0, 0, 1, 1, 0, 0, 0, 0, 0.5, 0.5);
o = e_widget_button_add(evas, NULL, "preferences-system",
_backlight_settings_cb, inst, NULL);
e_widget_table_object_align_append(inst->o_table, o,
0, 1, 1, 1, 0, 0, 0, 0, 0.5, 1.0);
e_gadcon_popup_content_set(inst->popup, inst->o_table);
e_gadcon_popup_show(inst->popup);
}
static void
_backlight_popup_free(Instance *inst)
{
if (!inst->popup) return;
if (inst->popup) e_object_del(E_OBJECT(inst->popup));
inst->popup = NULL;
}
static void
_backlight_menu_cb_post(void *data, E_Menu *menu __UNUSED__)
{
Instance *inst = data;
if ((!inst) || (!inst->menu))
return;
if (inst->menu)
{
e_object_del(E_OBJECT(inst->menu));
inst->menu = NULL;
}
}
static void
_backlight_menu_cb_cfg(void *data, E_Menu *menu __UNUSED__, E_Menu_Item *mi __UNUSED__)
{
Instance *inst = data;
E_Container *con;
if (inst->popup)
{
e_object_del(E_OBJECT(inst->popup));
inst->popup = NULL;
}
con = e_container_current_get(e_manager_current_get());
// e_int_config_backlight_module(con, NULL);
}
static void
_backlight_cb_mouse_down(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event)
{
Instance *inst = data;
Evas_Event_Mouse_Down *ev = event;
if (ev->button == 1)
{
if (inst->popup) _backlight_popup_free(inst);
else _backlight_popup_new(inst);
}
else if ((ev->button == 3) && (!inst->menu))
{
E_Zone *zone;
E_Menu *m;
E_Menu_Item *mi;
int x, y;
zone = e_util_zone_current_get(e_manager_current_get());
m = e_menu_new();
mi = e_menu_item_new(m);
e_menu_item_label_set(mi, _("Settings"));
e_util_menu_item_theme_icon_set(mi, "configure");
e_menu_item_callback_set(mi, _backlight_menu_cb_cfg, inst);
m = e_gadcon_client_util_menu_items_append(inst->gcc, m, 0);
e_menu_post_deactivate_callback_set(m, _backlight_menu_cb_post, inst);
inst->menu = m;
e_gadcon_canvas_zone_geometry_get(inst->gcc->gadcon, &x, &y, NULL, NULL);
e_menu_activate_mouse(m, zone, x + ev->output.x, y + ev->output.y,
1, 1, E_MENU_POP_DIRECTION_AUTO, ev->timestamp);
evas_event_feed_mouse_up(inst->gcc->gadcon->evas, ev->button,
EVAS_BUTTON_NONE, ev->timestamp, NULL);
}
}
static E_Gadcon_Client *
_gc_init(E_Gadcon *gc, const char *name, const char *id, const char *style)
{
Evas_Object *o;
E_Gadcon_Client *gcc;
Instance *inst;
inst = E_NEW(Instance, 1);
o = edje_object_add(gc->evas);
e_theme_edje_object_set(o, "base/theme/modules/backlight",
"e/modules/backlight/main");
evas_object_show(o);
gcc = e_gadcon_client_new(gc, name, id, style, o);
gcc->data = inst;
inst->gcc = gcc;
inst->o_backlight = o;
e_backlight_update();
inst->val = e_backlight_level_get(inst->gcc->gadcon->zone);
evas_object_event_callback_add(inst->o_backlight,
EVAS_CALLBACK_MOUSE_DOWN,
_backlight_cb_mouse_down,
inst);
e_gadcon_client_util_menu_attach(gcc);
backlight_instances = eina_list_append(backlight_instances, inst);
return gcc;
}
static void
_gc_shutdown(E_Gadcon_Client *gcc)
{
Instance *inst;
inst = gcc->data;
if (inst->menu)
{
e_object_del(E_OBJECT(inst->menu));
inst->menu = NULL;
}
backlight_instances = eina_list_remove(backlight_instances, inst);
evas_object_del(inst->o_backlight);
_backlight_popup_free(inst);
free(inst);
}
static void
_gc_orient(E_Gadcon_Client *gcc, E_Gadcon_Orient orient __UNUSED__)
{
Instance *inst;
Evas_Coord mw, mh;
inst = gcc->data;
mw = 0, mh = 0;
edje_object_size_min_get(inst->o_backlight, &mw, &mh);
if ((mw < 1) || (mh < 1))
edje_object_size_min_calc(inst->o_backlight, &mw, &mh);
if (mw < 4) mw = 4;
if (mh < 4) mh = 4;
e_gadcon_client_aspect_set(gcc, mw, mh);
e_gadcon_client_min_size_set(gcc, mw, mh);
}
static char *
_gc_label(E_Gadcon_Client_Class *client_class __UNUSED__)
{
return _("Backlight");
}
static Evas_Object *
_gc_icon(E_Gadcon_Client_Class *client_class __UNUSED__, Evas *evas)
{
Evas_Object *o;
char buf[4096];
o = edje_object_add(evas);
snprintf(buf, sizeof(buf), "%s/e-module-backlight.edj",
e_module_dir_get(backlight_module));
edje_object_file_set(o, buf, "icon");
return o;
}
static const char *
_gc_id_new(E_Gadcon_Client_Class *client_class __UNUSED__)
{
return _gadcon_class.name;
}
/* module setup */
EAPI E_Module_Api e_modapi =
{
E_MODULE_API_VERSION,
"Backlight"
};
EAPI void *
e_modapi_init(E_Module *m)
{
backlight_module = m;
e_gadcon_provider_register(&_gadcon_class);
return m;
}
EAPI int
e_modapi_shutdown(E_Module *m __UNUSED__)
{
backlight_module = NULL;
e_gadcon_provider_unregister(&_gadcon_class);
return 1;
}
EAPI int
e_modapi_save(E_Module *m __UNUSED__)
{
return 1;
}

@ -0,0 +1,10 @@
#ifndef E_MOD_MAIN_H
#define E_MOD_MAIN_H
EAPI extern E_Module_Api e_modapi;
EAPI void *e_modapi_init (E_Module *m);
EAPI int e_modapi_shutdown (E_Module *m);
EAPI int e_modapi_save (E_Module *m);
#endif

@ -0,0 +1,6 @@
[Desktop Entry]
Type=Link
Name=Backlight
Icon=e-module-backlight
X-Enlightenment-ModuleType=utils
Comment=Backlight control slider gadget

@ -36,20 +36,30 @@ struct _E_Config_Dialog_Data
double suspend_timeout;
double off_timeout;
Eina_List *dpms_list;
double backlight_normal;
double backlight_dim;
double backlight_transition;
};
static E_Dialog *dpms_dialog = NULL;
/* always allow as dmps now has backlight too
static void
_cb_dpms_dialog_ok(void *data __UNUSED__, E_Dialog *dia __UNUSED__)
{
e_object_del(E_OBJECT(dpms_dialog));
dpms_dialog = NULL;
}
*/
static int
_e_int_config_dpms_capable(void)
{
return 1;
/* always allow as dmps now has backlight too
* this all needs to merge with screensaver too into a simple screen blank+
* dim+brightness etc. config
if (ecore_x_dpms_capable_get()) return 1;
if (dpms_dialog) e_object_del(E_OBJECT(dpms_dialog));
@ -65,12 +75,15 @@ _e_int_config_dpms_capable(void)
e_dialog_button_focus_num(dpms_dialog, 1);
e_win_centered_set(dpms_dialog->win, 1);
e_dialog_show(dpms_dialog);
*/
return 0;
}
static int
_e_int_config_dpms_available(void)
{
return 1;
/* always allow as dmps now has backlight too
if (ecore_x_dpms_query()) return 1;
if (dpms_dialog) e_object_del(E_OBJECT(dpms_dialog));
@ -87,6 +100,7 @@ _e_int_config_dpms_available(void)
e_win_centered_set(dpms_dialog->win, 1);
e_dialog_show(dpms_dialog);
return 0;
*/
}
E_Config_Dialog *
@ -125,6 +139,9 @@ _fill_data(E_Config_Dialog_Data *cfdata)
cfdata->suspend_timeout = e_config->dpms_suspend_timeout / 60;
cfdata->enable_off = e_config->dpms_off_enable;
cfdata->off_timeout = e_config->dpms_off_timeout / 60;
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;
}
static void
@ -156,8 +173,8 @@ _create_data(E_Config_Dialog *cfd)
static void
_free_data(E_Config_Dialog *cfd __UNUSED__, E_Config_Dialog_Data *cfdata)
{
eina_list_free(cfdata->dpms_list);
E_FREE(cfdata);
eina_list_free(cfdata->dpms_list);
E_FREE(cfdata);
}
static int
@ -171,7 +188,14 @@ _apply_data(E_Config_Dialog *cfd __UNUSED__, E_Config_Dialog_Data *cfdata)
e_config->dpms_standby_timeout = cfdata->standby_timeout * 60;
e_config->dpms_suspend_timeout = cfdata->suspend_timeout * 60;
e_config->dpms_off_timeout = cfdata->off_timeout * 60;
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_backlight_mode_set(NULL, E_BACKLIGHT_MODE_NORMAL);
e_backlight_level_set(NULL, e_config->backlight.normal, -1.0);
e_config_save_queue();
e_dpms_update();
return 1;
@ -187,7 +211,10 @@ _advanced_check_changed(E_Config_Dialog *cfd __UNUSED__, E_Config_Dialog_Data *c
(e_config->dpms_off_enable != cfdata->enable_off) ||
(e_config->dpms_standby_timeout / 60 != cfdata->standby_timeout) ||
(e_config->dpms_suspend_timeout / 60 != cfdata->suspend_timeout) ||
(e_config->dpms_off_timeout / 60 != cfdata->off_timeout);
(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);
}
static int
@ -200,9 +227,12 @@ _advanced_apply_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata)
static Evas_Object *
_advanced_create_widgets(E_Config_Dialog *cfd __UNUSED__, Evas *evas, E_Config_Dialog_Data *cfdata)
{
Evas_Object *o, *of, *ob;
Evas_Object *o, *of, *ob, *otb;
Evas_Object *dpms_check;
otb = e_widget_toolbook_add(evas, (24 * e_scale), (24 * e_scale));
/* dpms */
o = e_widget_list_add(evas, 0, 0);
dpms_check = e_widget_check_add(evas, _("Enable Display Power Management"),
@ -253,7 +283,36 @@ _advanced_create_widgets(E_Config_Dialog *cfd __UNUSED__, Evas *evas, E_Config_D
_list_disabled_state_apply(cfdata->dpms_list, !cfdata->enable_dpms);
e_widget_list_object_append(o, of, 1, 1, 0.5);
return o;
e_widget_toolbook_page_append(otb, NULL, _("DPMS"), o,
1, 0, 1, 0, 0.5, 0.0);
o = e_widget_list_add(evas, 0, 0);
ob = e_widget_label_add(evas, _("Normal Backlight"));
e_widget_list_object_append(o, ob, 1, 1, 0.5);
ob = e_widget_slider_add(evas, 1, 0, _("%3.0f"), 0.0, 100.0, 1.0, 0,
&(cfdata->backlight_normal), NULL, 100);
e_widget_list_object_append(o, ob, 1, 1, 0.5);
ob = e_widget_label_add(evas, _("Dim Backlight"));
e_widget_list_object_append(o, ob, 1, 1, 0.5);
ob = e_widget_slider_add(evas, 1, 0, _("%3.0f"), 0.0, 100.0, 1.0, 0,
&(cfdata->backlight_dim), NULL, 100);
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,
&(cfdata->backlight_transition), NULL, 100);
e_widget_list_object_append(o, ob, 1, 1, 0.5);
e_widget_toolbook_page_append(otb, NULL, _("Backlight"), o,
1, 0, 1, 0, 0.5, 0.0);
e_widget_toolbook_page_show(otb, 0);
return otb;
}
/* general functionality/callbacks */

Loading…
Cancel
Save