summaryrefslogtreecommitdiff
path: root/xfce-extra/xfce4-power-manager/files/xfce4-power-manager-1.3.0-restore_brightness_level_after_sleep.patch
blob: 7687ae4eb3c9b37cd6e188604b80987efc701dbd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
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