[gnome-settings-daemon] power: Reset the un-idle when an event occurs again
- From: Bastien Nocera <hadess src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-settings-daemon] power: Reset the un-idle when an event occurs again
- Date: Thu, 31 Jan 2013 16:11:22 +0000 (UTC)
commit c9ffd4c6307c9caf004807ac9cba4afcc3f459e6
Author: Bastien Nocera <hadess hadess net>
Date: Thu Jan 31 17:07:03 2013 +0100
power: Reset the un-idle when an event occurs again
We used to behave like:
1. Receive AC event
2. Unidle with a timeout in 10 seconds to re-idle
3. Receive AC event
4. Timeout set up in 2. was not cancelled
5. Re-idle 10 seconds after 2.
In 4., we should cancel the existing timeout, and schedule
a new one, making sure not to erase the original value.
plugins/power/gsd-power-manager.c | 13 ++++++++++---
1 files changed, 10 insertions(+), 3 deletions(-)
---
diff --git a/plugins/power/gsd-power-manager.c b/plugins/power/gsd-power-manager.c
index 687ee25..935d701 100644
--- a/plugins/power/gsd-power-manager.c
+++ b/plugins/power/gsd-power-manager.c
@@ -2781,8 +2781,14 @@ set_temporary_unidle_on_ac (GsdPowerManager *manager,
idle_set_mode (manager, manager->priv->previous_idle_mode);
}
} else {
- manager->priv->previous_idle_mode = manager->priv->current_idle_mode;
- idle_set_mode (manager, GSD_POWER_IDLE_MODE_NORMAL);
+ /* Don't overwrite the previous idle mode when an unidle is
+ * already on-going */
+ if (manager->priv->temporary_unidle_on_ac_id != 0) {
+ g_source_remove (manager->priv->temporary_unidle_on_ac_id);
+ } else {
+ manager->priv->previous_idle_mode = manager->priv->current_idle_mode;
+ idle_set_mode (manager, GSD_POWER_IDLE_MODE_NORMAL);
+ }
manager->priv->temporary_unidle_on_ac_id = g_timeout_add_seconds (POWER_UP_TIME_ON_AC,
(GSourceFunc) temporary_unidle_done_cb,
manager);
@@ -2797,7 +2803,8 @@ up_client_on_battery_cb (UpClient *client,
idle_configure (manager);
if (manager->priv->current_idle_mode == GSD_POWER_IDLE_MODE_BLANK ||
- manager->priv->current_idle_mode == GSD_POWER_IDLE_MODE_DIM)
+ manager->priv->current_idle_mode == GSD_POWER_IDLE_MODE_DIM ||
+ manager->priv->temporary_unidle_on_ac_id != 0)
set_temporary_unidle_on_ac (manager, TRUE);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]