summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Nocera <hadess@hadess.net>2018-03-02 18:49:53 +0100
committerBastien Nocera <hadess@hadess.net>2018-03-02 19:07:56 +0100
commitfe56aab220a73a39ea10fd7f076265d0098f7ef3 (patch)
treee69351a7bb8d8fdde42ef6438473751e5e617f4f
parent935f1e984341a35ed0cbb5b1fad64a065186c301 (diff)
downloadgnome-settings-daemon-fe56aab220a73a39ea10fd7f076265d0098f7ef3.tar.gz
power: When the the sleep timeout is too short, don't throw errors
When running the test suite, we set a short sleep callback that shorter than the minimum amount of time we want to able to dim the screen, so that the warning shows up before dimming. But this short sleep timeout leads to a '0' sleep warning timeout, which is an invalid value. Use 1 msec instead of 0 msec as the timeout to avoid the warning. power-plugin-DEBUG: setting up sleep callback 5s power-plugin-DEBUG: setting up sleep warning callback 0s GnomeDesktop-CRITICAL **: gnome_idle_monitor_add_idle_watch: assertion 'interval_msec > 0' failed https://bugzilla.gnome.org/show_bug.cgi?id=794000
-rw-r--r--plugins/power/gsd-power-manager.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/plugins/power/gsd-power-manager.c b/plugins/power/gsd-power-manager.c
index 11a7aa84..6b2126cf 100644
--- a/plugins/power/gsd-power-manager.c
+++ b/plugins/power/gsd-power-manager.c
@@ -1781,17 +1781,19 @@ idle_configure (GsdPowerManager *manager)
if (action_type == GSD_POWER_ACTION_LOGOUT ||
action_type == GSD_POWER_ACTION_SUSPEND ||
action_type == GSD_POWER_ACTION_HIBERNATE) {
- guint timeout_sleep_warning;
+ guint timeout_sleep_warning_msec;
manager->priv->sleep_action_type = action_type;
- timeout_sleep_warning = timeout_sleep * IDLE_DELAY_TO_IDLE_DIM_MULTIPLIER;
- if (timeout_sleep_warning < MINIMUM_IDLE_DIM_DELAY)
- timeout_sleep_warning = 0;
+ timeout_sleep_warning_msec = timeout_sleep * IDLE_DELAY_TO_IDLE_DIM_MULTIPLIER * 1000;
+ if (timeout_sleep_warning_msec * 1000 < MINIMUM_IDLE_DIM_DELAY) {
+ /* 0 is not a valid idle timeout */
+ timeout_sleep_warning_msec = 1;
+ }
- g_debug ("setting up sleep warning callback %is", timeout_sleep_warning);
+ g_debug ("setting up sleep warning callback %i msec", timeout_sleep_warning_msec);
manager->priv->idle_sleep_warning_id = gnome_idle_monitor_add_idle_watch (manager->priv->idle_monitor,
- timeout_sleep_warning * 1000,
+ timeout_sleep_warning_msec,
idle_triggered_idle_cb, manager, NULL);
}
}