[gnome-settings-daemon] power: Switch off backlight before suspend
- From: Bastien Nocera <hadess src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-settings-daemon] power: Switch off backlight before suspend
- Date: Mon, 14 Jan 2013 12:04:23 +0000 (UTC)
commit 168d3ee1a08be38051e0cc054659ad7946b1c14d
Author: Bastien Nocera <hadess hadess net>
Date: Mon Jan 14 11:10:26 2013 +0100
power: Switch off backlight before suspend
When suspending, switch off the backlight and turn it back on when
resuming.
Note that we need to capture the current backlight before DPMS Off,
otherwise xbacklight will return zero.
Note that this only has an effect on machines where the lowest backlight
level turns the screen off, such as MacBooks.
https://bugzilla.gnome.org/show_bug.cgi?id=691702
plugins/power/gsd-power-manager.c | 23 +++++++++++++++++++++++
1 files changed, 23 insertions(+), 0 deletions(-)
---
diff --git a/plugins/power/gsd-power-manager.c b/plugins/power/gsd-power-manager.c
index 5637cdc..7295df5 100644
--- a/plugins/power/gsd-power-manager.c
+++ b/plugins/power/gsd-power-manager.c
@@ -183,6 +183,7 @@ struct GsdPowerManagerPrivate
guint low_percentage;
guint low_time;
gint pre_dim_brightness; /* level, not percentage */
+ gint pre_dpms_brightness;
UpDevice *device_composite;
NotifyNotification *notification_discharging;
NotifyNotification *notification_low;
@@ -224,6 +225,11 @@ static void do_power_action_type (GsdPowerManager *manager, GsdPowerActionT
static void do_lid_closed_action (GsdPowerManager *manager);
static void uninhibit_lid_switch (GsdPowerManager *manager);
static gboolean external_monitor_is_connected (GnomeRRScreen *screen);
+static gint backlight_set_abs (GsdPowerManager *manager,
+ guint value,
+ gboolean emit_changed,
+ GError **error);
+static gint backlight_get_abs (GsdPowerManager *manager, GError **error);
G_DEFINE_TYPE (GsdPowerManager, gsd_power_manager, G_TYPE_OBJECT)
@@ -3883,6 +3889,18 @@ screen_lock_done_cb (gpointer data)
static void
handle_suspend_actions (GsdPowerManager *manager)
{
+ GnomeRRDpmsMode mode;
+
+ /* Save the backlight, as DPMS isn't on yet, so we can capture it */
+ if (!gnome_rr_screen_get_dpms_mode (manager->priv->x11_screen, &mode, NULL) ||
+ mode != GNOME_RR_DPMS_ON) {
+ manager->priv->pre_dpms_brightness = -1;
+ } else {
+ manager->priv->pre_dpms_brightness = backlight_get_abs (manager, NULL);
+ }
+ if (manager->priv->pre_dpms_brightness != -1)
+ backlight_set_abs (manager, backlight_get_min (manager), FALSE, NULL);
+
lock_screensaver (manager, screen_lock_done_cb);
}
@@ -3907,6 +3925,11 @@ handle_resume_actions (GsdPowerManager *manager)
g_error_free (error);
}
+ if (manager->priv->pre_dpms_brightness != -1) {
+ backlight_set_abs (manager, manager->priv->pre_dpms_brightness, FALSE, &error);
+ manager->priv->pre_dpms_brightness = -1;
+ }
+
/* set up the delay again */
inhibit_suspend (manager);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]