From 5d6424e3bca8f7a647b1c745bdc879631f3f6249 Mon Sep 17 00:00:00 2001 From: "Carsten Haitzler (Rasterman)" Date: Tue, 21 Apr 2020 01:35:57 +0100 Subject: [PATCH] backlight - if bl devices not there yet for a zone then fix them later if bl devices added later - sync them up to the desired backlight leave when that happens and ensure we store the desired level...l --- src/bin/e_backlight.c | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/src/bin/e_backlight.c b/src/bin/e_backlight.c index d067cdd9e..1ea9bf0ac 100644 --- a/src/bin/e_backlight.c +++ b/src/bin/e_backlight.c @@ -377,11 +377,21 @@ _backlight_devices_lid_register(const char *dev, Eina_Bool force) bd = _backlight_devices_edid_find(sc->info.edid); if (!bd) { + E_Zone *zone; + bd = calloc(1, sizeof(Backlight_Device)); if (!bd) return; bd->edid = eina_stringshare_add(sc->info.edid); bd->output = eina_stringshare_add(sc->info.name); _devices = eina_list_append(_devices, bd); + 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); + } } if (bd->dev) { @@ -403,11 +413,21 @@ _backlight_devices_edid_register(const char *dev, const char *edid) bd = _backlight_devices_edid_find(sc->info.edid); if (!bd) { + E_Zone *zone; + bd = calloc(1, sizeof(Backlight_Device)); if (!bd) return; bd->edid = eina_stringshare_add(sc->info.edid); bd->output = eina_stringshare_add(sc->info.name); _devices = eina_list_append(_devices, bd); + 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); + } } if (bd->dev) { @@ -658,6 +678,9 @@ e_backlight_level_set(E_Zone *zone, double val, double tim) e_backlight_level_set(zone, val, tim); return; } + bl_now = zone->bl; + zone->bl = val; + bd = _backlight_devices_zone_device_find(zone); if (!bd) return; // set backlight associated with zone to val over period of tim @@ -666,10 +689,7 @@ e_backlight_level_set(E_Zone *zone, double val, double tim) 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; - if ((fabs(val - zone->bl) < DBL_EPSILON) && (!bd->anim)) return; - bl_now = zone->bl; - - zone->bl = val; + if ((fabs(val - bl_now) < DBL_EPSILON) && (!bd->anim)) return; if (fabs(tim) < DBL_EPSILON) {