[gnome-settings-daemon] color: Fix 'night shift'-style natural light settings
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-settings-daemon] color: Fix 'night shift'-style natural light settings
- Date: Wed, 8 Feb 2017 20:45:40 +0000 (UTC)
commit 296560cf93c339466db1eeede6ce21a296166618
Author: Richard Hughes <richard hughsie com>
Date: Wed Feb 8 15:52:10 2017 +0000
color: Fix 'night shift'-style natural light settings
plugins/color/gcm-self-test.c | 3 +++
plugins/color/gsd-natural-light-common.c | 6 +++++-
2 files changed, 8 insertions(+), 1 deletions(-)
---
diff --git a/plugins/color/gcm-self-test.c b/plugins/color/gcm-self-test.c
index 08241ce..a5163a7 100644
--- a/plugins/color/gcm-self-test.c
+++ b/plugins/color/gcm-self-test.c
@@ -123,6 +123,9 @@ gcm_test_frac_day (void)
/* test rollover to next day */
g_assert (gsd_natural_light_frac_day_is_between (23, 20, 6));
g_assert (!gsd_natural_light_frac_day_is_between (12, 20, 6));
+
+ /* test rollover to the previous day */
+ g_assert (gsd_natural_light_frac_day_is_between (5, 16, 8));
}
int
diff --git a/plugins/color/gsd-natural-light-common.c b/plugins/color/gsd-natural-light-common.c
index 10b693d..9150de6 100644
--- a/plugins/color/gsd-natural-light-common.c
+++ b/plugins/color/gsd-natural-light-common.c
@@ -121,6 +121,10 @@ gsd_natural_light_frac_day_is_between (gdouble value, gdouble start, gdouble end
if (end < start)
end += 24;
+ /* wraparound to the previous day */
+ if (value < start && value < end)
+ value += 24;
+
/* test limits */
- return value > start && value < end;
+ return value > start && value <= end;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]