| http://bugzilla.xfce.org/show_bug.cgi?id=10535 |
| |
| From 4c14d83794b94ac18519806314464599d5e905f6 Mon Sep 17 00:00:00 2001 |
| From: Eric Koegel <eric.koegel@gmail.com> |
| Date: Sat, 31 May 2014 20:09:56 +0300 |
| Subject: Restore screen power after sleep |
| |
| With this patch xfpm will cache the brightness level before going |
| to sleep and set it back to that level after resuming from sleep. |
| |
| diff --git a/common/xfpm-brightness.c b/common/xfpm-brightness.c |
| index e18c617..e49338e 100644 |
| --- a/common/xfpm-brightness.c |
| +++ b/common/xfpm-brightness.c |
| @@ -382,7 +382,7 @@ xfpm_brightness_helper_get_level (XfpmBrightness *brg, gint32 *level) |
| } |
| |
| static gboolean |
| -xfpm_brightness_helper_set_level (XfpmBrightness *brg, gint level) |
| +xfpm_brightness_helper_set_level (XfpmBrightness *brg, gint32 level) |
| { |
| gboolean ret; |
| GError *error = NULL; |
| diff --git a/src/xfpm-power.c b/src/xfpm-power.c |
| index 9d98fab..b42210b 100644 |
| --- a/src/xfpm-power.c |
| +++ b/src/xfpm-power.c |
| @@ -60,6 +60,7 @@ |
| #include "egg-idletime.h" |
| #include "xfpm-systemd.h" |
| #include "xfpm-suspend.h" |
| +#include "xfpm-brightness.h" |
| |
| |
| static void xfpm_power_finalize (GObject *object); |
| @@ -312,6 +313,8 @@ xfpm_power_sleep (XfpmPower *power, const gchar *sleep_time, gboolean force) |
| #ifdef WITH_NETWORK_MANAGER |
| gboolean network_manager_sleep; |
| #endif |
| + XfpmBrightness *brightness; |
| + gint32 brightness_level; |
| |
| if ( power->priv->inhibited && force == FALSE) |
| { |
| @@ -344,6 +347,10 @@ xfpm_power_sleep (XfpmPower *power, const gchar *sleep_time, gboolean force) |
| #endif |
| |
| g_signal_emit (G_OBJECT (power), signals [SLEEPING], 0); |
| + /* Get the current brightness level so we can use it after we suspend */ |
| + brightness = xfpm_brightness_new(); |
| + xfpm_brightness_setup (brightness); |
| + xfpm_brightness_get_level (brightness, &brightness_level); |
| |
| #ifdef WITH_NETWORK_MANAGER |
| g_object_get (G_OBJECT (power->priv->conf), |
| @@ -429,6 +436,11 @@ xfpm_power_sleep (XfpmPower *power, const gchar *sleep_time, gboolean force) |
| } |
| |
| g_signal_emit (G_OBJECT (power), signals [WAKING_UP], 0); |
| + /* Check/update any changes while we slept */ |
| + xfpm_power_get_properties (power); |
| + /* Restore the brightness level from before we suspended */ |
| + xfpm_brightness_set_level (brightness, brightness_level); |
| + |
| #ifdef WITH_NETWORK_MANAGER |
| if ( network_manager_sleep ) |
| { |
| -- |
| cgit v0.10.1 |
| |