7687ae4eb3c9b37cd6e188604b80987efc701dbd
[gentoo.git] /
1 http://bugzilla.xfce.org/show_bug.cgi?id=10535
2
3 From 4c14d83794b94ac18519806314464599d5e905f6 Mon Sep 17 00:00:00 2001
4 From: Eric Koegel <eric.koegel@gmail.com>
5 Date: Sat, 31 May 2014 20:09:56 +0300
6 Subject: Restore screen power after sleep
7
8 With this patch xfpm will cache the brightness level before going
9 to sleep and set it back to that level after resuming from sleep.
10
11 diff --git a/common/xfpm-brightness.c b/common/xfpm-brightness.c
12 index e18c617..e49338e 100644
13 --- a/common/xfpm-brightness.c
14 +++ b/common/xfpm-brightness.c
15 @@ -382,7 +382,7 @@ xfpm_brightness_helper_get_level (XfpmBrightness *brg, gint32 *level)
16  }
17  
18  static gboolean
19 -xfpm_brightness_helper_set_level (XfpmBrightness *brg, gint level)
20 +xfpm_brightness_helper_set_level (XfpmBrightness *brg, gint32 level)
21  {
22      gboolean ret;
23      GError *error = NULL;
24 diff --git a/src/xfpm-power.c b/src/xfpm-power.c
25 index 9d98fab..b42210b 100644
26 --- a/src/xfpm-power.c
27 +++ b/src/xfpm-power.c
28 @@ -60,6 +60,7 @@
29  #include "egg-idletime.h"
30  #include "xfpm-systemd.h"
31  #include "xfpm-suspend.h"
32 +#include "xfpm-brightness.h"
33  
34  
35  static void xfpm_power_finalize     (GObject *object);
36 @@ -312,6 +313,8 @@ xfpm_power_sleep (XfpmPower *power, const gchar *sleep_time, gboolean force)
37  #ifdef WITH_NETWORK_MANAGER
38      gboolean network_manager_sleep;
39  #endif
40 +    XfpmBrightness *brightness;
41 +    gint32 brightness_level;
42  
43      if ( power->priv->inhibited && force == FALSE)
44      {
45 @@ -344,6 +347,10 @@ xfpm_power_sleep (XfpmPower *power, const gchar *sleep_time, gboolean force)
46  #endif
47  
48      g_signal_emit (G_OBJECT (power), signals [SLEEPING], 0);
49 +    /* Get the current brightness level so we can use it after we suspend */
50 +    brightness = xfpm_brightness_new();
51 +    xfpm_brightness_setup (brightness);
52 +    xfpm_brightness_get_level (brightness, &brightness_level);
53  
54  #ifdef WITH_NETWORK_MANAGER
55      g_object_get (G_OBJECT (power->priv->conf),
56 @@ -429,6 +436,11 @@ xfpm_power_sleep (XfpmPower *power, const gchar *sleep_time, gboolean force)
57      }
58  
59      g_signal_emit (G_OBJECT (power), signals [WAKING_UP], 0);
60 +    /* Check/update any changes while we slept */
61 +    xfpm_power_get_properties (power);
62 +    /* Restore the brightness level from before we suspended */
63 +    xfpm_brightness_set_level (brightness, brightness_level);
64 +
65  #ifdef WITH_NETWORK_MANAGER
66      if ( network_manager_sleep )
67      {
68 -- 
69 cgit v0.10.1
70