2011-06-12 08:05:22 -07:00
|
|
|
#include "e.h"
|
|
|
|
|
2020-02-01 03:01:22 -08:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
const char *dev;
|
|
|
|
const char *output;
|
|
|
|
const char *edid;
|
2020-02-07 02:24:59 -08:00
|
|
|
double val, expected_val;
|
2020-02-01 03:01:22 -08:00
|
|
|
double from_val, to_val;
|
|
|
|
Ecore_Animator *anim;
|
2020-02-07 02:24:59 -08:00
|
|
|
Ecore_Timer *retry_timer;
|
|
|
|
int retries;
|
2020-02-01 03:01:22 -08:00
|
|
|
} Backlight_Device;
|
2011-06-12 08:05:22 -07:00
|
|
|
|
2020-02-01 03:01:22 -08:00
|
|
|
E_API int E_EVENT_BACKLIGHT_CHANGE = -1;
|
2011-06-12 08:05:22 -07:00
|
|
|
|
2012-09-16 03:43:17 -07:00
|
|
|
static Eina_List *bl_devs = NULL;
|
2020-02-01 03:01:22 -08:00
|
|
|
static Eina_List *handlers = NULL;
|
|
|
|
static Ecore_Job *zone_change_job = NULL;
|
|
|
|
static Eina_List *_devices = NULL;
|
|
|
|
static int _devices_pending_ops = 0;
|
|
|
|
static Eina_Bool _devices_zones_update = EINA_FALSE;
|
2011-10-29 11:45:43 -07:00
|
|
|
|
2020-02-07 02:24:59 -08:00
|
|
|
static void _backlight_devices_device_set(Backlight_Device *bd, double val);
|
|
|
|
static void _backlight_devices_device_update(Backlight_Device *bd);
|
|
|
|
|
|
|
|
static Eina_Bool
|
|
|
|
_backlight_retry_timer_cb(void *data)
|
|
|
|
{
|
|
|
|
Backlight_Device *bd = data;
|
2020-02-07 11:56:01 -08:00
|
|
|
|
2020-02-07 02:24:59 -08:00
|
|
|
bd->retry_timer = NULL;
|
|
|
|
_backlight_devices_device_set(bd, bd->expected_val);
|
|
|
|
_backlight_devices_device_update(bd);
|
|
|
|
return EINA_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_backlight_mismatch_retry(Backlight_Device *bd)
|
|
|
|
{
|
|
|
|
if (// if want 1.0 or normal or dim
|
|
|
|
((fabs(bd->expected_val - 1.0) < DBL_EPSILON) ||
|
|
|
|
(fabs(bd->expected_val - e_config->backlight.normal) < DBL_EPSILON) ||
|
|
|
|
(fabs(bd->expected_val - e_config->backlight.dim) < DBL_EPSILON)) &&
|
|
|
|
// and the delta between expected and val >= 0.05
|
|
|
|
(fabs(bd->expected_val - bd->val) >= 0.05) &&
|
|
|
|
// and we retried < 20 times
|
2020-06-10 03:46:41 -07:00
|
|
|
(bd->retries < 10))
|
2020-02-07 02:24:59 -08:00
|
|
|
{ // try again
|
2020-02-09 05:59:12 -08:00
|
|
|
printf("RETRY backlight set as %1.2f != %1.2f (expected) try=%i\n",
|
|
|
|
bd->val, bd->expected_val, bd->retries);
|
2020-02-07 02:24:59 -08:00
|
|
|
bd->retries++;
|
|
|
|
if (bd->retry_timer) ecore_timer_del(bd->retry_timer);
|
2020-02-07 11:56:01 -08:00
|
|
|
bd->retry_timer = ecore_timer_add(0.1, _backlight_retry_timer_cb, bd);
|
2020-02-07 02:24:59 -08:00
|
|
|
} // or give up
|
|
|
|
else bd->retries = 0;
|
|
|
|
}
|
|
|
|
|
2020-02-01 03:01:22 -08:00
|
|
|
static void
|
|
|
|
_backlight_system_get_cb(void *data, const char *params)
|
|
|
|
{
|
|
|
|
char dev[1024];
|
|
|
|
int val = 0;
|
|
|
|
double fval;
|
|
|
|
Backlight_Device *bd = data;
|
|
|
|
|
|
|
|
if (!params) return;
|
|
|
|
if (sscanf(params, "%1023s %i", dev, &val) != 2) return;
|
|
|
|
if (!!strcmp(bd->dev, dev)) return;
|
|
|
|
e_system_handler_del("bklight-val", _backlight_system_get_cb, bd);
|
|
|
|
fval = (double)val / 1000.0;
|
|
|
|
if (fabs(fval - bd->val) >= DBL_EPSILON)
|
|
|
|
{
|
|
|
|
bd->val = fval;
|
|
|
|
ecore_event_add(E_EVENT_BACKLIGHT_CHANGE, NULL, NULL, NULL);
|
2020-02-07 02:24:59 -08:00
|
|
|
_backlight_mismatch_retry(bd);
|
2020-02-01 03:01:22 -08:00
|
|
|
}
|
|
|
|
}
|
2011-06-12 08:05:22 -07:00
|
|
|
|
2020-02-06 05:53:27 -08:00
|
|
|
static void
|
|
|
|
_backlight_system_ddc_get_cb(void *data, const char *params)
|
|
|
|
{
|
|
|
|
char edid[257];
|
|
|
|
int id = -1, val = -1;
|
|
|
|
double fval;
|
|
|
|
Backlight_Device *bd = data;
|
|
|
|
|
|
|
|
if (!params) return;
|
|
|
|
if (sscanf(params, "%256s %i %i", edid, &id, &val) != 3) return;
|
2020-02-07 11:56:01 -08:00
|
|
|
if (!bd->edid) return;
|
2020-02-06 05:53:27 -08:00
|
|
|
if (!!strncmp(bd->edid, edid, strlen(edid))) return;
|
|
|
|
e_system_handler_del("ddc-val-get", _backlight_system_ddc_get_cb, bd);
|
2020-02-10 00:09:47 -08:00
|
|
|
if (val < 0) fval = -1.0;
|
|
|
|
else fval = (double)val / 100.0;
|
2020-02-09 05:59:12 -08:00
|
|
|
if ((fabs(fval - bd->val) >= DBL_EPSILON) || (val == -1))
|
2020-02-06 05:53:27 -08:00
|
|
|
{
|
|
|
|
bd->val = fval;
|
|
|
|
ecore_event_add(E_EVENT_BACKLIGHT_CHANGE, NULL, NULL, NULL);
|
2020-02-07 02:24:59 -08:00
|
|
|
_backlight_mismatch_retry(bd);
|
2020-02-06 05:53:27 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-02-01 03:01:22 -08:00
|
|
|
static void
|
|
|
|
_backlight_devices_clear(void)
|
|
|
|
{
|
2020-02-06 05:53:27 -08:00
|
|
|
const char *s;
|
2020-02-01 03:01:22 -08:00
|
|
|
Backlight_Device *bd;
|
2011-06-12 08:05:22 -07:00
|
|
|
|
2020-02-06 05:53:27 -08:00
|
|
|
EINA_LIST_FREE(bl_devs, s)
|
|
|
|
eina_stringshare_del(s);
|
2020-02-01 03:01:22 -08:00
|
|
|
EINA_LIST_FREE(_devices, bd)
|
|
|
|
{
|
|
|
|
eina_stringshare_del(bd->dev);
|
|
|
|
eina_stringshare_del(bd->output);
|
|
|
|
eina_stringshare_del(bd->edid);
|
|
|
|
if (bd->anim) ecore_animator_del(bd->anim);
|
2020-02-07 02:24:59 -08:00
|
|
|
if (bd->retry_timer) ecore_timer_del(bd->retry_timer);
|
2020-02-01 03:01:22 -08:00
|
|
|
e_system_handler_del("bklight-val", _backlight_system_get_cb, bd);
|
2020-02-06 05:53:27 -08:00
|
|
|
e_system_handler_del("ddc-val-get", _backlight_system_ddc_get_cb, bd);
|
2020-02-01 03:01:22 -08:00
|
|
|
free(bd);
|
|
|
|
}
|
|
|
|
}
|
2012-11-13 09:36:51 -08:00
|
|
|
|
2020-02-01 03:01:22 -08:00
|
|
|
static Backlight_Device *
|
|
|
|
_backlight_devices_zone_device_find(E_Zone *zone)
|
2011-06-12 08:05:22 -07:00
|
|
|
{
|
2020-02-01 03:01:22 -08:00
|
|
|
Eina_List *l;
|
|
|
|
Backlight_Device *bd;
|
|
|
|
char *tmp, *sep;
|
2020-06-10 03:46:41 -07:00
|
|
|
const char *out, *edid, *id;
|
2020-02-01 03:01:22 -08:00
|
|
|
|
2020-06-10 03:46:41 -07:00
|
|
|
id = zone->randr2_id;
|
2020-06-10 05:34:21 -07:00
|
|
|
if (!id) id = "/";
|
2020-06-14 06:00:48 -07:00
|
|
|
tmp = strdup(id);
|
2020-02-01 03:01:22 -08:00
|
|
|
if (!tmp) return NULL;
|
|
|
|
sep = strchr(tmp, '/');
|
|
|
|
if (!sep)
|
|
|
|
{
|
|
|
|
free(tmp);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
*sep = '\0';
|
|
|
|
out = tmp;
|
|
|
|
edid = sep + 1;
|
|
|
|
EINA_LIST_FOREACH(_devices, l, bd)
|
|
|
|
{
|
|
|
|
if ((bd->output) && (!strcmp(out, bd->output)))
|
|
|
|
{
|
|
|
|
if ((edid[0] && (!strcmp(edid, bd->edid))) || (!edid[0]))
|
2020-04-18 16:06:08 -07:00
|
|
|
{
|
|
|
|
free(tmp);
|
|
|
|
return bd;
|
|
|
|
}
|
2020-02-01 03:01:22 -08:00
|
|
|
}
|
|
|
|
}
|
2020-04-18 16:06:08 -07:00
|
|
|
free(tmp);
|
2020-02-01 03:01:22 -08:00
|
|
|
return NULL;
|
|
|
|
}
|
2011-12-02 20:24:02 -08:00
|
|
|
|
2014-03-11 04:24:41 -07:00
|
|
|
#ifndef HAVE_WAYLAND_ONLY
|
2020-02-01 03:01:22 -08:00
|
|
|
static const char *
|
|
|
|
_backlight_devices_randr_out_edid_str_get(Ecore_X_Window root, Ecore_X_Randr_Output *out)
|
|
|
|
{
|
|
|
|
const char *str = NULL;
|
|
|
|
unsigned long edid_len = 0;
|
|
|
|
unsigned char *edid = ecore_x_randr_output_edid_get(root, *out, &edid_len);
|
|
|
|
if (edid)
|
|
|
|
{
|
|
|
|
char *edid_str = malloc((edid_len * 2) + 1);
|
2012-11-13 09:36:51 -08:00
|
|
|
|
2020-02-01 03:01:22 -08:00
|
|
|
if (edid_str)
|
|
|
|
{
|
|
|
|
const char *hexch = "0123456789abcdef";
|
|
|
|
char *dc = edid_str;
|
|
|
|
unsigned long i;
|
2012-11-13 09:36:51 -08:00
|
|
|
|
2020-02-01 03:01:22 -08:00
|
|
|
for (i = 0; i < edid_len; i++)
|
|
|
|
{
|
|
|
|
dc[0] = hexch[(edid[i] >> 4) & 0xf];
|
|
|
|
dc[1] = hexch[(edid[i] ) & 0xf];
|
|
|
|
dc += 2;
|
|
|
|
}
|
|
|
|
*dc = 0;
|
|
|
|
str = eina_stringshare_add(edid_str);
|
|
|
|
free(edid_str);
|
|
|
|
}
|
|
|
|
free(edid);
|
|
|
|
}
|
|
|
|
return str;
|
2011-06-12 08:05:22 -07:00
|
|
|
}
|
|
|
|
|
2020-02-01 03:01:22 -08:00
|
|
|
static Ecore_X_Randr_Output
|
|
|
|
_backlight_devices_randr_output_get(Ecore_X_Window root, const char *output, const char *edid)
|
2011-06-12 08:05:22 -07:00
|
|
|
{
|
2020-02-01 03:01:22 -08:00
|
|
|
Ecore_X_Randr_Output *out;
|
|
|
|
int i, num = 0;
|
2012-01-24 02:01:28 -08:00
|
|
|
|
2020-02-01 03:01:22 -08:00
|
|
|
out = ecore_x_randr_window_outputs_get(root, &num);
|
|
|
|
if ((out) && (num > 0))
|
|
|
|
{
|
|
|
|
for (i = 0; i < num; i++)
|
|
|
|
{
|
|
|
|
char *name = ecore_x_randr_output_name_get(root, out[i], NULL);
|
|
|
|
if (!name) continue;
|
|
|
|
const char *edid_str = _backlight_devices_randr_out_edid_str_get(root, &(out[i]));
|
|
|
|
if (edid_str)
|
|
|
|
{
|
|
|
|
if ((!strcmp(output, name)) && (!strcmp(edid, edid_str)))
|
|
|
|
{
|
|
|
|
eina_stringshare_del(edid_str);
|
|
|
|
free(name);
|
|
|
|
return out[i];
|
|
|
|
}
|
|
|
|
eina_stringshare_del(edid_str);
|
|
|
|
}
|
|
|
|
free(name);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
2011-06-12 08:05:22 -07:00
|
|
|
}
|
2020-02-01 03:01:22 -08:00
|
|
|
#endif
|
2011-06-12 08:05:22 -07:00
|
|
|
|
2020-02-01 03:01:22 -08:00
|
|
|
static void
|
|
|
|
_backlight_devices_device_set(Backlight_Device *bd, double val)
|
2011-08-14 07:35:41 -07:00
|
|
|
{
|
2020-06-10 03:46:41 -07:00
|
|
|
if (fabs(bd->expected_val - val) > DBL_EPSILON) bd->retries = 0;
|
2020-02-07 02:24:59 -08:00
|
|
|
bd->val = bd->expected_val = val;
|
2020-02-01 03:01:22 -08:00
|
|
|
#ifndef HAVE_WAYLAND_ONLY
|
|
|
|
if (!strcmp(bd->dev, "randr"))
|
|
|
|
{
|
|
|
|
if ((e_comp) && (e_comp->comp_type == E_PIXMAP_TYPE_X) && (e_comp->root))
|
|
|
|
{
|
|
|
|
Ecore_X_Randr_Output o = _backlight_devices_randr_output_get(e_comp->root, bd->output, bd->edid);
|
|
|
|
if (o)
|
|
|
|
{
|
|
|
|
ecore_x_randr_output_backlight_level_set(e_comp->root, o, bd->val);
|
|
|
|
ecore_event_add(E_EVENT_BACKLIGHT_CHANGE, NULL, NULL, NULL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
#endif
|
|
|
|
if (!strncmp(bd->dev, "ddc:", 4))
|
|
|
|
{
|
2020-02-06 05:53:27 -08:00
|
|
|
e_system_send("ddc-val-set", "%s %i %i", bd->dev + 4, 0x10, (int)(bd->val * 100.0)); // backlight val in e_system_ddc.c
|
|
|
|
ecore_event_add(E_EVENT_BACKLIGHT_CHANGE, NULL, NULL, NULL);
|
2020-02-01 03:01:22 -08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
e_system_send("bklight-set", "%s %i", bd->dev, (int)(bd->val * 1000.0));
|
|
|
|
ecore_event_add(E_EVENT_BACKLIGHT_CHANGE, NULL, NULL, NULL);
|
|
|
|
}
|
2011-08-14 07:35:41 -07:00
|
|
|
}
|
|
|
|
|
2020-02-01 03:01:22 -08:00
|
|
|
static E_Zone *
|
|
|
|
_backlight_devices_device_zone_get(Backlight_Device *bd)
|
2011-06-12 08:05:22 -07:00
|
|
|
{
|
2020-02-01 03:01:22 -08:00
|
|
|
char buf[1024];
|
|
|
|
Eina_List *l;
|
|
|
|
E_Zone *zone;
|
2012-01-24 02:01:28 -08:00
|
|
|
|
2020-02-01 03:01:22 -08:00
|
|
|
snprintf(buf, sizeof(buf), "%s/%s", bd->output? bd->output: "", bd->edid ? bd->edid : "");
|
|
|
|
EINA_LIST_FOREACH(e_comp->zones, l, zone)
|
|
|
|
{
|
2020-06-10 05:34:21 -07:00
|
|
|
const char *id = zone->randr2_id;
|
|
|
|
fprintf(stderr, "look at %p %s\n", zone, id);
|
|
|
|
if (!id)
|
|
|
|
{
|
|
|
|
const char *id2 = bd->edid;
|
|
|
|
if (!id2) id2 = "";
|
|
|
|
id = "";
|
|
|
|
fprintf(stderr, "cmp1 [%s] == [%s]\n", id, id2);
|
|
|
|
if (!strcmp(id, id2)) return zone;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
fprintf(stderr, "cmp2 [%s] == [%s]\n", id, buf);
|
|
|
|
if (!strcmp(id, buf)) return zone;
|
|
|
|
}
|
2020-02-01 03:01:22 -08:00
|
|
|
}
|
|
|
|
return NULL;
|
2011-06-12 08:05:22 -07:00
|
|
|
}
|
|
|
|
|
2020-02-01 03:01:22 -08:00
|
|
|
static void
|
|
|
|
_backlight_devices_device_update(Backlight_Device *bd)
|
2011-06-12 08:05:22 -07:00
|
|
|
{
|
2020-02-01 03:01:22 -08:00
|
|
|
if (!bd->dev) return;
|
|
|
|
#ifndef HAVE_WAYLAND_ONLY
|
|
|
|
if (!strcmp(bd->dev, "randr"))
|
2013-09-20 09:18:36 -07:00
|
|
|
{
|
2020-02-01 03:01:22 -08:00
|
|
|
if ((e_comp) && (e_comp->comp_type == E_PIXMAP_TYPE_X) && (e_comp->root))
|
|
|
|
{
|
|
|
|
Ecore_X_Randr_Output o = _backlight_devices_randr_output_get(e_comp->root, bd->output, bd->edid);
|
|
|
|
if (o)
|
|
|
|
{
|
|
|
|
double x_bl = ecore_x_randr_output_backlight_level_get(e_comp->root, o);
|
|
|
|
if ((x_bl >= 0.0) && (fabs(x_bl - bd->val) >= DBL_EPSILON))
|
|
|
|
{
|
|
|
|
bd->val = x_bl;
|
|
|
|
E_Zone *zone = _backlight_devices_device_zone_get(bd);
|
|
|
|
if (zone) zone->bl = bd->val;
|
|
|
|
ecore_event_add(E_EVENT_BACKLIGHT_CHANGE, NULL, NULL, NULL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2013-09-20 09:18:36 -07:00
|
|
|
}
|
2013-01-07 06:28:26 -08:00
|
|
|
else
|
2020-02-01 03:01:22 -08:00
|
|
|
#endif
|
|
|
|
if (!strncmp(bd->dev, "ddc:", 4))
|
|
|
|
{
|
2020-02-07 11:56:01 -08:00
|
|
|
e_system_handler_del("ddc-val-get", _backlight_system_ddc_get_cb, bd);
|
2020-02-06 05:53:27 -08:00
|
|
|
e_system_handler_add("ddc-val-get", _backlight_system_ddc_get_cb, bd);
|
|
|
|
e_system_send("ddc-val-get", "%s %i", bd->dev + 4, 0x10); // backlight val in e_system_ddc.c
|
2020-02-01 03:01:22 -08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-02-07 11:56:01 -08:00
|
|
|
e_system_handler_del("bklight-val", _backlight_system_get_cb, bd);
|
2020-02-01 03:01:22 -08:00
|
|
|
e_system_handler_add("bklight-val", _backlight_system_get_cb, bd);
|
|
|
|
e_system_send("bklight-get", "%s", bd->dev);
|
|
|
|
}
|
|
|
|
}
|
2013-09-20 09:18:36 -07:00
|
|
|
|
2020-02-01 03:01:22 -08:00
|
|
|
static void
|
|
|
|
_backlight_devices_update(void)
|
|
|
|
{
|
|
|
|
Eina_List *l;
|
|
|
|
Backlight_Device *bd;
|
|
|
|
|
|
|
|
EINA_LIST_FOREACH(_devices, l, bd)
|
|
|
|
_backlight_devices_device_update(bd);
|
2011-06-12 08:05:22 -07:00
|
|
|
}
|
|
|
|
|
2020-02-01 03:01:22 -08:00
|
|
|
static void
|
|
|
|
_backlight_devices_pending_done(void)
|
2011-06-12 08:05:22 -07:00
|
|
|
{
|
2020-02-01 03:01:22 -08:00
|
|
|
_devices_pending_ops--;
|
|
|
|
if (_devices_pending_ops > 0) return;
|
2020-02-07 02:49:15 -08:00
|
|
|
e_backlight_level_set(NULL, e_config->backlight.normal, -1.0);
|
2020-02-01 03:01:22 -08:00
|
|
|
_backlight_devices_update();
|
2011-06-12 08:05:22 -07:00
|
|
|
}
|
|
|
|
|
2020-02-01 03:01:22 -08:00
|
|
|
static E_Randr2_Screen *
|
|
|
|
_backlight_devices_screen_lid_get(void)
|
2011-06-12 08:05:22 -07:00
|
|
|
{
|
2020-02-01 03:01:22 -08:00
|
|
|
Eina_List *l;
|
|
|
|
E_Randr2_Screen *sc;
|
|
|
|
|
|
|
|
if (!e_randr2) return NULL;
|
|
|
|
EINA_LIST_FOREACH(e_randr2->screens, l, sc)
|
2012-12-08 22:27:42 -08:00
|
|
|
{
|
2020-02-01 03:01:22 -08:00
|
|
|
if (sc->info.is_lid) return sc;
|
2012-12-08 22:27:42 -08:00
|
|
|
}
|
2020-02-01 03:01:22 -08:00
|
|
|
return NULL;
|
2011-06-12 08:05:22 -07:00
|
|
|
}
|
|
|
|
|
2020-02-06 05:53:27 -08:00
|
|
|
static E_Randr2_Screen *
|
|
|
|
_backlight_devices_screen_edid_get(const char *edid)
|
|
|
|
{
|
|
|
|
Eina_List *l;
|
|
|
|
E_Randr2_Screen *sc;
|
2020-06-10 03:46:41 -07:00
|
|
|
const char *id;
|
2020-02-06 05:53:27 -08:00
|
|
|
|
|
|
|
if (!e_randr2) return NULL;
|
|
|
|
EINA_LIST_FOREACH(e_randr2->screens, l, sc)
|
|
|
|
{
|
2020-06-10 03:46:41 -07:00
|
|
|
id = sc->info.edid;
|
2020-06-10 05:34:21 -07:00
|
|
|
if (!id) id = "";
|
2020-06-10 03:46:41 -07:00
|
|
|
if (!strncmp(id, edid, strlen(edid))) return sc;
|
2020-02-06 05:53:27 -08:00
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2020-02-01 03:01:22 -08:00
|
|
|
static Backlight_Device *
|
|
|
|
_backlight_devices_edid_find(const char *edid)
|
2011-06-12 08:05:22 -07:00
|
|
|
{
|
2020-02-01 03:01:22 -08:00
|
|
|
Eina_List *l;
|
|
|
|
Backlight_Device *bd;
|
|
|
|
|
|
|
|
EINA_LIST_FOREACH(_devices, l, bd)
|
|
|
|
{
|
|
|
|
if ((bd->edid) && (edid) && (!strcmp(edid, bd->edid)))
|
|
|
|
return bd;
|
|
|
|
}
|
|
|
|
return NULL;
|
2011-06-12 08:05:22 -07:00
|
|
|
}
|
|
|
|
|
2020-02-01 03:01:22 -08:00
|
|
|
static void
|
|
|
|
_backlight_devices_lid_register(const char *dev, Eina_Bool force)
|
2012-09-16 03:43:17 -07:00
|
|
|
{
|
2020-02-01 03:01:22 -08:00
|
|
|
E_Randr2_Screen *sc = _backlight_devices_screen_lid_get();
|
2020-06-10 03:46:41 -07:00
|
|
|
Backlight_Device *bd = NULL;
|
|
|
|
const char *id;
|
|
|
|
|
2020-02-01 03:01:22 -08:00
|
|
|
if (!sc) return;
|
2020-06-10 03:46:41 -07:00
|
|
|
id = sc->info.edid;
|
2020-06-10 05:34:21 -07:00
|
|
|
if (!id) id = "";
|
2020-06-10 03:46:41 -07:00
|
|
|
bd = _backlight_devices_edid_find(id);
|
2020-02-01 03:01:22 -08:00
|
|
|
if (!bd)
|
|
|
|
{
|
2020-04-20 17:35:57 -07:00
|
|
|
E_Zone *zone;
|
|
|
|
|
2020-02-01 03:01:22 -08:00
|
|
|
bd = calloc(1, sizeof(Backlight_Device));
|
|
|
|
if (!bd) return;
|
2020-06-10 03:46:41 -07:00
|
|
|
bd->edid = eina_stringshare_add(id);
|
2020-02-01 03:01:22 -08:00
|
|
|
bd->output = eina_stringshare_add(sc->info.name);
|
|
|
|
_devices = eina_list_append(_devices, bd);
|
2020-04-20 17:35:57 -07:00
|
|
|
zone = _backlight_devices_device_zone_get(bd);
|
|
|
|
if (zone)
|
|
|
|
{
|
|
|
|
double bl = zone->bl;
|
|
|
|
|
|
|
|
zone->bl = 0.0;
|
|
|
|
e_backlight_level_set(zone, bl, -1.0);
|
|
|
|
}
|
2020-02-01 03:01:22 -08:00
|
|
|
}
|
|
|
|
if (bd->dev)
|
|
|
|
{
|
|
|
|
if (!strcmp(bd->dev, "randr")) return; // randr devices win
|
|
|
|
if (!strncmp(bd->dev, "ddc:", 4)) return; // ddc devices also beat these "sys" devices
|
|
|
|
}
|
|
|
|
// if bl device has a device assigned and we're not forcing a change
|
|
|
|
// then skip assigning this device to the backlight device
|
|
|
|
if ((bd->dev) && (!force)) return;
|
|
|
|
eina_stringshare_replace(&(bd->dev), dev);
|
2012-09-16 03:43:17 -07:00
|
|
|
}
|
|
|
|
|
2020-02-06 05:53:27 -08:00
|
|
|
static void
|
|
|
|
_backlight_devices_edid_register(const char *dev, const char *edid)
|
|
|
|
{
|
|
|
|
E_Randr2_Screen *sc = _backlight_devices_screen_edid_get(edid);
|
|
|
|
Backlight_Device *bd;
|
|
|
|
if (!sc) return;
|
|
|
|
bd = _backlight_devices_edid_find(sc->info.edid);
|
|
|
|
if (!bd)
|
|
|
|
{
|
2020-04-20 17:35:57 -07:00
|
|
|
E_Zone *zone;
|
2020-06-10 03:46:41 -07:00
|
|
|
const char *id;
|
2020-04-20 17:35:57 -07:00
|
|
|
|
2020-02-06 05:53:27 -08:00
|
|
|
bd = calloc(1, sizeof(Backlight_Device));
|
|
|
|
if (!bd) return;
|
2020-06-10 03:46:41 -07:00
|
|
|
id = sc->info.edid;
|
2020-06-10 05:34:21 -07:00
|
|
|
if (!id) id = "";
|
2020-06-10 03:46:41 -07:00
|
|
|
bd->edid = eina_stringshare_add(id);
|
2020-02-06 05:53:27 -08:00
|
|
|
bd->output = eina_stringshare_add(sc->info.name);
|
|
|
|
_devices = eina_list_append(_devices, bd);
|
2020-04-20 17:35:57 -07:00
|
|
|
zone = _backlight_devices_device_zone_get(bd);
|
|
|
|
if (zone)
|
|
|
|
{
|
|
|
|
double bl = zone->bl;
|
|
|
|
|
|
|
|
zone->bl = 0.0;
|
|
|
|
e_backlight_level_set(zone, bl, -1.0);
|
|
|
|
}
|
2020-02-06 05:53:27 -08:00
|
|
|
}
|
|
|
|
if (bd->dev)
|
|
|
|
{
|
|
|
|
if (!strcmp(bd->dev, "randr")) return; // randr devices win
|
|
|
|
}
|
|
|
|
eina_stringshare_replace(&(bd->dev), dev);
|
|
|
|
}
|
|
|
|
|
2011-06-12 08:05:22 -07:00
|
|
|
static void
|
2020-02-01 03:01:22 -08:00
|
|
|
_backlight_system_list_cb(void *data EINA_UNUSED, const char *params)
|
2011-06-12 08:05:22 -07:00
|
|
|
{
|
2020-02-01 03:01:22 -08:00
|
|
|
// params "dev flag dev flag ..."
|
2020-02-06 05:53:27 -08:00
|
|
|
const char *p = params;
|
2020-02-01 03:01:22 -08:00
|
|
|
char dev[1024], flag, devnum = 0;
|
2011-06-12 08:05:22 -07:00
|
|
|
|
2020-02-01 03:01:22 -08:00
|
|
|
e_system_handler_del("bklight-list", _backlight_system_list_cb, NULL);
|
|
|
|
while ((p) && (*p))
|
|
|
|
{
|
|
|
|
if (sscanf(p, "%1023s", dev) == 1)
|
2012-09-16 03:43:17 -07:00
|
|
|
{
|
2020-02-01 03:01:22 -08:00
|
|
|
p += strlen(dev);
|
|
|
|
if (*p == ' ')
|
2012-09-16 03:43:17 -07:00
|
|
|
{
|
2020-02-01 03:01:22 -08:00
|
|
|
p++;
|
|
|
|
flag = *p;
|
|
|
|
if (flag)
|
compositor rewrite / charlie-foxtrot situation
huge fustercluck commit because there wasn't really a way to separate out the changes. better to just rip it all out at once.
* compositor and window management completely rewritten. this was the goal for E19, but it pretty much required everything existing to be scrapped since it wasn't optimized, streamlined, or sensible. now instead of having the compositor strapped to the window manager like an outboard motor, it's housed more like an automobile engine.
** various comp structs have been merged into other places (eg. E_Comp_Zone is now just part of E_Zone where applicable), leading to a large deduplication of attributes
** awful E_Comp_Win is totally dead, having been replaced with e_comp_object smart objects which work just like normal canvas objects
** protocol-specific window management and compositor functionality is now kept exclusively in backend files
** e_pixmap api provides generic client finding and rendering api
** screen/xinerama screens are now provided directly by compositor on startup and re-set on change
** e_comp_render_update finally replaced with eina_tiler
** wayland compositor no longer creates X windows
** compositor e_layout removed entirely
* e_container is gone. this was made unnecessary in E18, but I kept it to avoid having too much code churn in one release. its sole purpose was to catch some events and handle window stacking, both of which are now just done by the compositor infra
* e_manager is just for screensaver and keybind stuff now, possibly remove later?
* e_border is gone along with a lot of its api. e_client has replaced it, and e_client has been rewritten completely; some parts may be similar, but the design now relies upon having a functional compositor
** window configuration/focus functions are all removed. all windows are now managed solely with evas_object_X functions on the "frame" member of a client, just as any other canvas object can be managed.
*** do NOT set interceptors on a client's comp_object. seriously.
* startup order rewritten: compositor now starts much earlier, other things just use attrs and members of the compositor
* ecore_x_pointer_xy_get usage replaced with ecore_evas_pointer_xy_get
* e_popup is totally gone, existing usage replaced by e_comp_object_util_add where applicable, otherwise just placed normally on the canvas
* deskmirror is (more) broken for now
* illume is totally fucked
* Ecore_X_Window replaced with Ecore_Window in most cases
* edge binding XWindows replaced with regular canvas objects
* some E_Win functionality has changed such that delete callbacks are now correctly called in ALL cases. various dialogs have been updated to not crash as a result
comp files and descriptions:
e_comp.c - overall compositor functions, rendering/update loop, shape cutting
e_comp_x.c - X window management and compositor functionality
e_comp_wl.c - Wayland surface management and compositor functionality
e_comp_canvas.c - general compositor canvas functions and utilities
e_comp_object.c - E_Client->frame member for managing clients as Evas_Objects, utility functions for adding objects to the compositor rendering systems
additional authors: ivan.briano@intel.com
feature: new compositor
removal: e_border, e_container, e_popup
2014-01-14 17:19:12 -08:00
|
|
|
{
|
2020-02-01 03:01:22 -08:00
|
|
|
bl_devs = eina_list_append
|
|
|
|
(bl_devs, eina_stringshare_add(dev));
|
|
|
|
if ((devnum == 0) || (flag == 'p') ||
|
|
|
|
(strstr(dev, "/drm/")) ||
|
|
|
|
(strstr(dev, ".video.")))
|
|
|
|
{
|
|
|
|
_backlight_devices_lid_register(dev, EINA_TRUE);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// XXX: what to do with other bl devices?
|
|
|
|
// for now just assign spare bl devices to screens that do not have one already
|
|
|
|
_backlight_devices_lid_register(dev, EINA_FALSE);
|
|
|
|
}
|
|
|
|
devnum++;
|
|
|
|
// XXX: find bed bl dev for screens not supporting randr
|
|
|
|
// note that this is a vallback and ddc should take precedence
|
2020-05-13 12:03:23 -07:00
|
|
|
// it matched up to a screen over this, but randr should be
|
2020-02-01 03:01:22 -08:00
|
|
|
// the top priority if found
|
compositor rewrite / charlie-foxtrot situation
huge fustercluck commit because there wasn't really a way to separate out the changes. better to just rip it all out at once.
* compositor and window management completely rewritten. this was the goal for E19, but it pretty much required everything existing to be scrapped since it wasn't optimized, streamlined, or sensible. now instead of having the compositor strapped to the window manager like an outboard motor, it's housed more like an automobile engine.
** various comp structs have been merged into other places (eg. E_Comp_Zone is now just part of E_Zone where applicable), leading to a large deduplication of attributes
** awful E_Comp_Win is totally dead, having been replaced with e_comp_object smart objects which work just like normal canvas objects
** protocol-specific window management and compositor functionality is now kept exclusively in backend files
** e_pixmap api provides generic client finding and rendering api
** screen/xinerama screens are now provided directly by compositor on startup and re-set on change
** e_comp_render_update finally replaced with eina_tiler
** wayland compositor no longer creates X windows
** compositor e_layout removed entirely
* e_container is gone. this was made unnecessary in E18, but I kept it to avoid having too much code churn in one release. its sole purpose was to catch some events and handle window stacking, both of which are now just done by the compositor infra
* e_manager is just for screensaver and keybind stuff now, possibly remove later?
* e_border is gone along with a lot of its api. e_client has replaced it, and e_client has been rewritten completely; some parts may be similar, but the design now relies upon having a functional compositor
** window configuration/focus functions are all removed. all windows are now managed solely with evas_object_X functions on the "frame" member of a client, just as any other canvas object can be managed.
*** do NOT set interceptors on a client's comp_object. seriously.
* startup order rewritten: compositor now starts much earlier, other things just use attrs and members of the compositor
* ecore_x_pointer_xy_get usage replaced with ecore_evas_pointer_xy_get
* e_popup is totally gone, existing usage replaced by e_comp_object_util_add where applicable, otherwise just placed normally on the canvas
* deskmirror is (more) broken for now
* illume is totally fucked
* Ecore_X_Window replaced with Ecore_Window in most cases
* edge binding XWindows replaced with regular canvas objects
* some E_Win functionality has changed such that delete callbacks are now correctly called in ALL cases. various dialogs have been updated to not crash as a result
comp files and descriptions:
e_comp.c - overall compositor functions, rendering/update loop, shape cutting
e_comp_x.c - X window management and compositor functionality
e_comp_wl.c - Wayland surface management and compositor functionality
e_comp_canvas.c - general compositor canvas functions and utilities
e_comp_object.c - E_Client->frame member for managing clients as Evas_Objects, utility functions for adding objects to the compositor rendering systems
additional authors: ivan.briano@intel.com
feature: new compositor
removal: e_border, e_container, e_popup
2014-01-14 17:19:12 -08:00
|
|
|
}
|
2020-02-01 03:01:22 -08:00
|
|
|
else break;
|
|
|
|
p++;
|
|
|
|
if (*p != ' ') break;
|
|
|
|
p++;
|
|
|
|
if (*p == '\0') break;
|
2012-09-16 03:43:17 -07:00
|
|
|
}
|
2020-02-01 03:01:22 -08:00
|
|
|
else break;
|
2012-09-16 03:43:17 -07:00
|
|
|
}
|
2020-02-01 03:01:22 -08:00
|
|
|
else break;
|
2012-08-15 02:31:10 -07:00
|
|
|
}
|
2020-02-01 03:01:22 -08:00
|
|
|
_backlight_devices_pending_done();
|
2011-06-12 08:05:22 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2020-02-06 05:53:27 -08:00
|
|
|
_backlight_system_ddc_list_cb(void *data EINA_UNUSED, const char *params)
|
|
|
|
{
|
|
|
|
const char *p = params;
|
|
|
|
char dev[257], buf[343];
|
|
|
|
|
|
|
|
e_system_handler_del("ddc-list", _backlight_system_ddc_list_cb, NULL);
|
|
|
|
while ((p) && (*p))
|
|
|
|
{
|
|
|
|
if (sscanf(p, "%256s", dev) == 1)
|
|
|
|
{
|
|
|
|
p += strlen(dev);
|
|
|
|
snprintf(buf, sizeof(buf), "ddc:%s", dev);
|
|
|
|
bl_devs = eina_list_append
|
|
|
|
(bl_devs, eina_stringshare_add(buf));
|
|
|
|
_backlight_devices_edid_register(buf, dev);
|
|
|
|
if (*p != ' ') break;
|
|
|
|
}
|
|
|
|
else break;
|
|
|
|
}
|
|
|
|
_backlight_devices_pending_done();
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_backlight_devices_probe(Eina_Bool initial)
|
2011-06-12 08:05:22 -07:00
|
|
|
{
|
2020-02-01 03:01:22 -08:00
|
|
|
_backlight_devices_clear();
|
|
|
|
#ifndef HAVE_WAYLAND_ONLY
|
|
|
|
// pass 1: if in x look at all the randr outputs to see if they have some backlight
|
|
|
|
// property to swizzle then make the randr device the kind of device to use -
|
|
|
|
// record this in our devices list
|
|
|
|
if ((e_comp) && (e_comp->comp_type == E_PIXMAP_TYPE_X))
|
2011-06-12 08:05:22 -07:00
|
|
|
{
|
2020-02-01 03:01:22 -08:00
|
|
|
Eina_Bool avail = ecore_x_randr_output_backlight_available();
|
|
|
|
if ((avail) && (e_comp->root))
|
2011-06-12 08:05:22 -07:00
|
|
|
{
|
2020-02-01 03:01:22 -08:00
|
|
|
double x_bl;
|
|
|
|
Ecore_X_Window root = e_comp->root;
|
|
|
|
Ecore_X_Randr_Output *out;
|
|
|
|
int i, num = 0;
|
2020-06-10 05:34:21 -07:00
|
|
|
Eina_Bool found = EINA_FALSE;
|
2020-02-01 03:01:22 -08:00
|
|
|
|
2020-02-06 05:53:27 -08:00
|
|
|
bl_devs = eina_list_append(bl_devs, eina_stringshare_add("randr"));
|
2020-02-01 03:01:22 -08:00
|
|
|
out = ecore_x_randr_window_outputs_get(root, &num);
|
|
|
|
if ((out) && (num > 0))
|
2012-09-16 03:43:17 -07:00
|
|
|
{
|
2014-04-23 03:13:40 -07:00
|
|
|
for (i = 0; i < num; i++)
|
2012-09-16 03:43:17 -07:00
|
|
|
{
|
2020-02-01 03:01:22 -08:00
|
|
|
char *name = ecore_x_randr_output_name_get(root, out[i], NULL);
|
|
|
|
if (!name) continue;
|
|
|
|
x_bl = ecore_x_randr_output_backlight_level_get(root, out[0]);
|
|
|
|
if (x_bl >= 0.0)
|
2012-09-16 03:43:17 -07:00
|
|
|
{
|
2020-02-01 03:01:22 -08:00
|
|
|
Backlight_Device *bd = calloc(1, sizeof(Backlight_Device));
|
|
|
|
if (bd)
|
2014-04-23 03:13:40 -07:00
|
|
|
{
|
2020-02-01 03:01:22 -08:00
|
|
|
const char *edid_str = _backlight_devices_randr_out_edid_str_get(root, &(out[i]));
|
|
|
|
|
|
|
|
if (edid_str)
|
|
|
|
{
|
|
|
|
bd->dev = eina_stringshare_add("randr");
|
|
|
|
bd->output = eina_stringshare_add(name);
|
|
|
|
bd->edid = edid_str;
|
|
|
|
_devices = eina_list_append(_devices, bd);
|
2020-06-10 05:34:21 -07:00
|
|
|
found = EINA_TRUE;
|
2020-02-01 03:01:22 -08:00
|
|
|
}
|
|
|
|
else free(bd);
|
2014-04-23 03:13:40 -07:00
|
|
|
}
|
2012-09-16 03:43:17 -07:00
|
|
|
}
|
2020-02-01 03:01:22 -08:00
|
|
|
free(name);
|
2012-09-16 03:43:17 -07:00
|
|
|
}
|
|
|
|
}
|
2020-02-01 03:01:22 -08:00
|
|
|
free(out);
|
2020-06-10 05:34:21 -07:00
|
|
|
if (found)
|
|
|
|
e_backlight_level_set(NULL, e_config->backlight.normal, -1.0);
|
2011-06-15 07:18:23 -07:00
|
|
|
}
|
2011-06-12 08:05:22 -07:00
|
|
|
}
|
2011-10-29 11:45:43 -07:00
|
|
|
#endif
|
2020-02-01 03:01:22 -08:00
|
|
|
// ask enlightenment_system to list backlight devices. this is async so we have
|
|
|
|
// to respond to the device listing later
|
|
|
|
_devices_pending_ops++;
|
2020-02-07 11:56:01 -08:00
|
|
|
e_system_handler_del("bklight-list", _backlight_system_list_cb, NULL);
|
2020-02-01 03:01:22 -08:00
|
|
|
e_system_handler_add("bklight-list", _backlight_system_list_cb, NULL);
|
2020-02-06 05:53:27 -08:00
|
|
|
if (!initial) e_system_send("bklight-refresh", NULL);
|
2020-02-01 03:01:22 -08:00
|
|
|
e_system_send("bklight-list", NULL);
|
2020-02-06 05:53:27 -08:00
|
|
|
_devices_pending_ops++;
|
2020-02-07 11:56:01 -08:00
|
|
|
e_system_handler_del("ddc-list", _backlight_system_ddc_list_cb, NULL);
|
2020-02-06 05:53:27 -08:00
|
|
|
e_system_handler_add("ddc-list", _backlight_system_ddc_list_cb, NULL);
|
|
|
|
if (!initial) e_system_send("ddc-refresh", NULL);
|
|
|
|
e_system_send("ddc-list", NULL);
|
2020-02-01 03:01:22 -08:00
|
|
|
// XXXX: add ddc to e_syystem and query that too
|
2011-06-12 08:05:22 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static Eina_Bool
|
2020-02-01 03:01:22 -08:00
|
|
|
_bl_anim(void *data, double pos)
|
2011-06-12 08:05:22 -07:00
|
|
|
{
|
2020-02-01 03:01:22 -08:00
|
|
|
Backlight_Device *bd = data;
|
2012-06-20 23:19:43 -07:00
|
|
|
|
2011-06-12 08:05:22 -07:00
|
|
|
// FIXME: if zone is deleted while anim going... bad things.
|
|
|
|
pos = ecore_animator_pos_map(pos, ECORE_POS_MAP_DECELERATE, 0.0, 0.0);
|
2020-02-01 03:01:22 -08:00
|
|
|
bd->val = (bd->from_val * (1.0 - pos)) + (bd->to_val * pos);
|
|
|
|
_backlight_devices_device_set(bd, bd->val);
|
2011-06-12 08:05:22 -07:00
|
|
|
if (pos >= 1.0)
|
|
|
|
{
|
2020-02-01 03:01:22 -08:00
|
|
|
bd->anim = NULL;
|
|
|
|
_backlight_devices_device_update(bd);
|
2011-06-12 08:05:22 -07:00
|
|
|
return EINA_FALSE;
|
|
|
|
}
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
2011-06-15 07:18:23 -07:00
|
|
|
|
2015-09-21 14:19:53 -07:00
|
|
|
static void
|
2020-02-01 03:01:22 -08:00
|
|
|
_cb_job_zone_change(void *data EINA_UNUSED)
|
2015-09-21 14:19:53 -07:00
|
|
|
{
|
2020-02-01 03:01:22 -08:00
|
|
|
zone_change_job = NULL;
|
2020-02-06 05:53:27 -08:00
|
|
|
_backlight_devices_probe(EINA_FALSE);
|
2020-02-01 03:01:22 -08:00
|
|
|
e_backlight_update();
|
2015-09-21 14:19:53 -07:00
|
|
|
}
|
|
|
|
|
2020-02-01 03:01:22 -08:00
|
|
|
static Eina_Bool
|
|
|
|
_cb_handler_zone_change(void *data EINA_UNUSED, int type EINA_UNUSED, void *info EINA_UNUSED)
|
2011-06-15 07:18:23 -07:00
|
|
|
{
|
2020-02-01 03:01:22 -08:00
|
|
|
if (zone_change_job) ecore_job_del(zone_change_job);
|
|
|
|
zone_change_job = ecore_job_add(_cb_job_zone_change, NULL);
|
|
|
|
return EINA_TRUE;
|
2011-06-15 07:18:23 -07:00
|
|
|
}
|
|
|
|
|
2020-02-01 03:01:22 -08:00
|
|
|
EINTERN int
|
|
|
|
e_backlight_init(void)
|
2011-06-15 07:18:23 -07:00
|
|
|
{
|
2020-02-01 03:01:22 -08:00
|
|
|
E_EVENT_BACKLIGHT_CHANGE = ecore_event_type_new();
|
2020-02-06 05:53:27 -08:00
|
|
|
_backlight_devices_probe(EINA_TRUE);
|
2020-02-01 03:01:22 -08:00
|
|
|
#define H(ev, cb) \
|
|
|
|
handlers = eina_list_append(handlers, \
|
|
|
|
ecore_event_handler_add(ev, cb, NULL));
|
|
|
|
H(E_EVENT_ZONE_ADD, _cb_handler_zone_change);
|
|
|
|
H(E_EVENT_ZONE_DEL, _cb_handler_zone_change);
|
|
|
|
H(E_EVENT_ZONE_MOVE_RESIZE, _cb_handler_zone_change);
|
|
|
|
H(E_EVENT_ZONE_STOW, _cb_handler_zone_change);
|
|
|
|
H(E_EVENT_ZONE_UNSTOW, _cb_handler_zone_change);
|
|
|
|
e_backlight_update();
|
|
|
|
if (!getenv("E_RESTART"))
|
2020-02-07 02:49:15 -08:00
|
|
|
e_backlight_level_set(NULL, e_config->backlight.normal, -1.0);
|
2020-02-01 03:01:22 -08:00
|
|
|
return 1;
|
|
|
|
}
|
2011-10-29 11:45:43 -07:00
|
|
|
|
2020-02-01 03:01:22 -08:00
|
|
|
EINTERN int
|
|
|
|
e_backlight_shutdown(void)
|
|
|
|
{
|
|
|
|
Ecore_Event_Handler *h;
|
|
|
|
const char *s;
|
2011-10-29 11:45:43 -07:00
|
|
|
|
2020-02-01 03:01:22 -08:00
|
|
|
if (zone_change_job)
|
2013-01-11 02:51:24 -08:00
|
|
|
{
|
2020-02-01 03:01:22 -08:00
|
|
|
ecore_job_del(zone_change_job);
|
|
|
|
zone_change_job = NULL;
|
2013-01-11 02:51:24 -08:00
|
|
|
}
|
2020-02-01 03:01:22 -08:00
|
|
|
EINA_LIST_FREE(handlers, h)
|
|
|
|
ecore_event_handler_del(h);
|
|
|
|
EINA_LIST_FREE(bl_devs, s)
|
|
|
|
eina_stringshare_del(s);
|
|
|
|
_backlight_devices_clear();
|
|
|
|
return 1;
|
2011-10-28 21:36:32 -07:00
|
|
|
}
|
|
|
|
|
2020-02-01 03:01:22 -08:00
|
|
|
E_API Eina_Bool
|
|
|
|
e_backlight_exists(void)
|
2011-06-15 07:18:23 -07:00
|
|
|
{
|
2020-02-01 03:01:22 -08:00
|
|
|
// XXX: properly check backlight devices
|
|
|
|
return EINA_TRUE;
|
2011-06-15 07:18:23 -07:00
|
|
|
}
|
2013-01-11 02:34:29 -08:00
|
|
|
|
2020-02-01 03:01:22 -08:00
|
|
|
E_API void
|
|
|
|
e_backlight_update(void)
|
2015-04-14 06:20:33 -07:00
|
|
|
{
|
2020-02-01 03:01:22 -08:00
|
|
|
if (_devices_pending_ops > 0) _devices_zones_update = EINA_TRUE;
|
|
|
|
else _backlight_devices_update();
|
|
|
|
}
|
2015-04-14 06:20:33 -07:00
|
|
|
|
2020-02-01 03:01:22 -08:00
|
|
|
E_API void
|
|
|
|
e_backlight_level_set(E_Zone *zone, double val, double tim)
|
|
|
|
{
|
|
|
|
Backlight_Device *bd;
|
|
|
|
double bl_now;
|
2015-04-14 06:20:33 -07:00
|
|
|
|
2020-02-01 03:01:22 -08:00
|
|
|
if (!zone) // zone == NULL == everything
|
2015-04-14 06:20:33 -07:00
|
|
|
{
|
2020-02-01 03:01:22 -08:00
|
|
|
Eina_List *l;
|
2015-04-14 06:20:33 -07:00
|
|
|
|
2020-02-01 03:01:22 -08:00
|
|
|
if (!e_comp) return;
|
|
|
|
EINA_LIST_FOREACH(e_comp->zones, l, zone)
|
|
|
|
e_backlight_level_set(zone, val, tim);
|
2015-04-14 06:20:33 -07:00
|
|
|
return;
|
|
|
|
}
|
2020-04-20 17:35:57 -07:00
|
|
|
bl_now = zone->bl;
|
|
|
|
zone->bl = val;
|
|
|
|
|
2020-02-01 03:01:22 -08:00
|
|
|
bd = _backlight_devices_zone_device_find(zone);
|
|
|
|
if (!bd) return;
|
|
|
|
// 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 ((!e_comp->screen) || (!e_comp->screen->backlight_enabled)) return;
|
|
|
|
if (val < 0.0) val = 0.0;
|
|
|
|
else if (val > 1.0) val = 1.0;
|
2020-04-20 17:35:57 -07:00
|
|
|
if ((fabs(val - bl_now) < DBL_EPSILON) && (!bd->anim)) return;
|
2020-02-01 03:01:22 -08:00
|
|
|
|
|
|
|
if (fabs(tim) < DBL_EPSILON)
|
|
|
|
{
|
|
|
|
_backlight_devices_device_set(bd, val);
|
|
|
|
_backlight_devices_device_update(bd);
|
|
|
|
ecore_event_add(E_EVENT_BACKLIGHT_CHANGE, NULL, NULL, NULL);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (zone->bl_mode == E_BACKLIGHT_MODE_NORMAL) tim = 0.5;
|
|
|
|
else if (tim < 0.0) tim = e_config->backlight.transition;
|
|
|
|
|
2020-06-28 07:06:37 -07:00
|
|
|
if ((bd->anim) && (fabs(bd->to_val - val) < DBL_EPSILON)) return;
|
|
|
|
|
2020-02-07 02:24:59 -08:00
|
|
|
E_FREE_FUNC(bd->retry_timer, ecore_timer_del);
|
2020-02-01 03:01:22 -08:00
|
|
|
E_FREE_FUNC(bd->anim, ecore_animator_del);
|
|
|
|
bd->from_val = bl_now;
|
|
|
|
bd->to_val = val;
|
2020-06-10 05:34:21 -07:00
|
|
|
bd->anim = ecore_animator_timeline_add(tim, _bl_anim, bd);
|
2015-04-14 06:20:33 -07:00
|
|
|
}
|
|
|
|
|
2020-02-01 03:01:22 -08:00
|
|
|
E_API double
|
|
|
|
e_backlight_level_get(E_Zone *zone)
|
2015-04-14 06:20:33 -07:00
|
|
|
{
|
2020-02-01 03:01:22 -08:00
|
|
|
Backlight_Device *bd;
|
|
|
|
|
|
|
|
if (!zone)
|
|
|
|
{
|
|
|
|
zone = e_zone_current_get();
|
|
|
|
if (!zone) return -1.0;
|
|
|
|
}
|
|
|
|
bd = _backlight_devices_zone_device_find(zone);
|
|
|
|
if (!bd) return -1.0;
|
|
|
|
zone->bl = bd->val;
|
|
|
|
return bd->val;
|
|
|
|
}
|
2015-04-14 06:20:33 -07:00
|
|
|
|
2020-02-01 03:01:22 -08:00
|
|
|
E_API void
|
|
|
|
e_backlight_mode_set(E_Zone *zone, E_Backlight_Mode mode)
|
|
|
|
{
|
|
|
|
E_Backlight_Mode pmode;
|
2015-04-14 06:20:33 -07:00
|
|
|
|
2020-02-01 03:01:22 -08:00
|
|
|
if (!zone) // zone == NULL == everything
|
2015-04-14 06:20:33 -07:00
|
|
|
{
|
2020-02-01 03:01:22 -08:00
|
|
|
Eina_List *l;
|
|
|
|
|
|
|
|
if (!e_comp) return;
|
|
|
|
EINA_LIST_FOREACH(e_comp->zones, l, zone)
|
|
|
|
e_backlight_mode_set(zone, mode);
|
2015-04-14 06:20:33 -07:00
|
|
|
return;
|
|
|
|
}
|
2020-02-01 03:01:22 -08:00
|
|
|
if (zone->bl_mode == mode) return;
|
|
|
|
if (eina_streq(ecore_evas_engine_name_get(e_comp->ee), "buffer") ||
|
|
|
|
strstr(ecore_evas_engine_name_get(e_comp->ee), "wayland"))
|
|
|
|
return;
|
|
|
|
pmode = zone->bl_mode;
|
|
|
|
zone->bl_mode = mode;
|
|
|
|
if (zone->bl_mode == E_BACKLIGHT_MODE_NORMAL)
|
2015-04-14 06:20:33 -07:00
|
|
|
{
|
2020-02-01 03:01:22 -08:00
|
|
|
e_backlight_level_set(zone, e_config->backlight.normal, -1.0);
|
2015-04-14 06:20:33 -07:00
|
|
|
}
|
2020-02-01 03:01:22 -08:00
|
|
|
else if (zone->bl_mode == E_BACKLIGHT_MODE_OFF)
|
2015-04-14 06:20:33 -07:00
|
|
|
{
|
2020-02-01 03:01:22 -08:00
|
|
|
e_backlight_level_set(zone, 0.0, -1.0);
|
2015-04-14 06:20:33 -07:00
|
|
|
}
|
2020-02-01 03:01:22 -08:00
|
|
|
else if (zone->bl_mode == E_BACKLIGHT_MODE_DIM)
|
|
|
|
{
|
|
|
|
if ((pmode != E_BACKLIGHT_MODE_NORMAL) ||
|
|
|
|
((pmode == E_BACKLIGHT_MODE_NORMAL) &&
|
|
|
|
(e_config->backlight.normal > e_config->backlight.dim)))
|
|
|
|
e_backlight_level_set(zone, e_config->backlight.dim, -1.0);
|
|
|
|
}
|
|
|
|
else if (zone->bl_mode == E_BACKLIGHT_MODE_MAX)
|
|
|
|
e_backlight_level_set(zone, 1.0, -1.0);
|
|
|
|
}
|
|
|
|
|
|
|
|
E_API E_Backlight_Mode
|
|
|
|
e_backlight_mode_get(E_Zone *zone)
|
|
|
|
{
|
|
|
|
if (!zone)
|
|
|
|
{
|
|
|
|
zone = e_zone_current_get();
|
|
|
|
if (!zone) return E_BACKLIGHT_MODE_NORMAL;
|
|
|
|
}
|
|
|
|
return zone->bl_mode;
|
|
|
|
}
|
|
|
|
|
|
|
|
E_API const Eina_List *
|
|
|
|
e_backlight_devices_get(void)
|
|
|
|
{
|
|
|
|
return bl_devs;
|
2015-04-14 06:20:33 -07:00
|
|
|
}
|