[gnome-settings-daemon/benzea/night-light-570] night-light: Move disable-until-tomorrow check to after active check




commit 4d69de072272772b3874227d4248269f34984d9d
Author: Benjamin Berg <bberg redhat com>
Date:   Mon Nov 23 13:33:09 2020 +0100

    night-light: Move disable-until-tomorrow check to after active check
    
    When DUT is active (i.e. night light is effectively off), we should
    still report the correct active state depending on whether we have
    detected night-time or not.
    
    So always run the code to update the active state, and instead only skip
    the color temperature calculation that happens later.
    
    Closes: #570

 plugins/color/gsd-night-light.c | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)
---
diff --git a/plugins/color/gsd-night-light.c b/plugins/color/gsd-night-light.c
index 635f1608..733fdacf 100644
--- a/plugins/color/gsd-night-light.c
+++ b/plugins/color/gsd-night-light.c
@@ -322,11 +322,6 @@ night_light_recheck (GsdNightLight *self)
                         self->disabled_until_tmw = FALSE;
                         g_clear_pointer(&self->disabled_until_tmw_dt, g_date_time_unref);
                         g_object_notify (G_OBJECT (self), "disabled-until-tmw");
-                } else {
-                        g_debug ("night light still day-disabled, resetting");
-                        gsd_night_light_set_temperature (self,
-                                                         GSD_COLOR_TEMPERATURE_DEFAULT);
-                        return;
                 }
         }
 
@@ -372,10 +367,16 @@ night_light_recheck (GsdNightLight *self)
         } else {
                 temp_smeared = temperature;
         }
-        g_debug ("night light mode on, using temperature of %uK (aiming for %uK)",
-                 temp_smeared, temperature);
         gsd_night_light_set_active (self, TRUE);
-        gsd_night_light_set_temperature (self, temp_smeared);
+
+        if (self->disabled_until_tmw) {
+                g_debug ("night light still day-disabled");
+                gsd_night_light_set_temperature (self, GSD_COLOR_TEMPERATURE_DEFAULT);
+        } else {
+                g_debug ("night light mode on, using temperature of %uK (aiming for %uK)",
+                         temp_smeared, temperature);
+                gsd_night_light_set_temperature (self, temp_smeared);
+        }
 }
 
 static gboolean


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]