Merge lp:~3v1n0/unity-settings-daemon/keep-cached-kbd-backlight-updated into lp:unity-settings-daemon

Proposed by Marco Trevisan (Treviño) on 2016-05-13
Status: Merged
Approved by: Sebastien Bacher on 2016-06-15
Approved revision: 4136
Merged at revision: 4136
Proposed branch: lp:~3v1n0/unity-settings-daemon/keep-cached-kbd-backlight-updated
Merge into: lp:unity-settings-daemon
Prerequisite: lp:~seb128/unity-settings-daemon/better-keyboard-backlight
Diff against target: 83 lines (+28/-3)
1 file modified
plugins/power/gsd-power-manager.c (+28/-3)
To merge this branch: bzr merge lp:~3v1n0/unity-settings-daemon/keep-cached-kbd-backlight-updated
Reviewer Review Type Date Requested Status
Sebastien Bacher 2016-05-13 Approve on 2016-06-15
Review via email: mp+294662@code.launchpad.net

Commit message

PowerManager: connect to keyboard BrightnessChanged signal to update the cached current value properly

To post a comment you must log in.
4135. By Marco Trevisan (Treviño) on 2016-05-13

PowerManager: return proper value on Toggle method call

4136. By Marco Trevisan (Treviño) on 2016-05-30

GsdPowerManager: implement "Toggle" as upstream

Sebastien Bacher (seb128) wrote :

thanks

review: Approve
Sebastien Bacher (seb128) wrote :

seems like that created bug #1592816, the upower_kbd_toggle return type changed and we need changes from https://git.gnome.org/browse/gnome-settings-daemon/commit/?id=5614e2c7a275a092e1fcf43450d7f0c5730c14bd

"- ret = upower_kbd_toggle (manager, &error);
+ value = upower_kbd_toggle (manager, &error);
+ ret = (value >= 0);"

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'plugins/power/gsd-power-manager.c'
2--- plugins/power/gsd-power-manager.c 2016-05-30 19:19:47 +0000
3+++ plugins/power/gsd-power-manager.c 2016-05-30 19:19:47 +0000
4@@ -1956,11 +1956,12 @@
5 return TRUE;
6 }
7
8-static gboolean
9+static int
10 upower_kbd_toggle (GsdPowerManager *manager,
11 GError **error)
12 {
13 gboolean ret;
14+ int value = -1;
15
16 if (manager->priv->kbd_brightness_old >= 0) {
17 g_debug ("keyboard toggle off");
18@@ -1970,6 +1971,7 @@
19 if (ret) {
20 /* succeeded, set to -1 since now no old value */
21 manager->priv->kbd_brightness_old = -1;
22+ value = 0;
23 }
24 } else {
25 g_debug ("keyboard toggle on");
26@@ -1979,10 +1981,14 @@
27 if (!ret) {
28 /* failed, reset back to -1 */
29 manager->priv->kbd_brightness_old = -1;
30+ } else {
31+ value = 0;
32 }
33 }
34
35- return ret;
36+ if (ret)
37+ return value;
38+ return -1;
39 }
40
41 static gboolean
42@@ -2842,6 +2848,20 @@
43 }
44
45 static void
46+upower_kbd_signal_cb (GDBusProxy *proxy,
47+ const gchar *sender_name,
48+ const gchar *signal_name,
49+ GVariant *parameters,
50+ gpointer user_data)
51+{
52+ GsdPowerManager *manager = GSD_POWER_MANAGER (user_data);
53+
54+ if (g_strcmp0 (signal_name, "BrightnessChanged") == 0) {
55+ g_variant_get (parameters, "(i)", &manager->priv->kbd_brightness_now);
56+ }
57+}
58+
59+static void
60 power_keyboard_proxy_ready_cb (GObject *source_object,
61 GAsyncResult *res,
62 gpointer user_data)
63@@ -2859,6 +2879,9 @@
64 goto out;
65 }
66
67+ g_signal_connect (manager->priv->upower_kdb_proxy, "g-signal",
68+ G_CALLBACK (upower_kbd_signal_cb), manager);
69+
70 k_now = g_dbus_proxy_call_sync (manager->priv->upower_kdb_proxy,
71 "GetBrightness",
72 NULL,
73@@ -3550,7 +3573,9 @@
74 ret = upower_kbd_set_brightness (manager, value, &error);
75
76 } else if (g_strcmp0 (method_name, "Toggle") == 0) {
77- ret = upower_kbd_toggle (manager, &error);
78+ value = upower_kbd_toggle (manager, &error);
79+ ret = (value >= 0);
80+
81 } else {
82 g_assert_not_reached ();
83 }

Subscribers

People subscribed via source and target branches