Merge lp:~charlesk/powerd/lp-1370791-add-brightness-property into lp:powerd

Proposed by Charles Kerr on 2015-05-20
Status: Merged
Approved by: Alejandro J. Cura on 2015-05-21
Approved revision: 166
Merged at revision: 165
Proposed branch: lp:~charlesk/powerd/lp-1370791-add-brightness-property
Merge into: lp:powerd
Diff against target: 83 lines (+32/-1)
4 files modified
data/com.canonical.powerd.xml (+4/-0)
src/backlight.c (+3/-1)
src/powerd-internal.h (+1/-0)
src/powerd-object.c (+24/-0)
To merge this branch: bzr merge lp:~charlesk/powerd/lp-1370791-add-brightness-property
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Approve on 2015-05-20
Ricardo Salveti code review Approve on 2015-05-20
Alejandro J. Cura (community) 2015-05-20 Approve on 2015-05-20
Review via email: mp+259678@code.launchpad.net

Commit message

publish brightness changes on the bus.

Description of the change

Make an org.dbus.freedesktop.Property for brightness so that clients can watch to see when powerd adjusts brightness automatically.

Required for https://bugs.launchpad.net/ubuntu/+source/ubuntu-system-settings/+bug/1370791

To post a comment you must log in.
Alejandro J. Cura (alecu) wrote :

Code looks good. Tested on mako with wily, works great.

review: Approve
Ricardo Salveti (rsalveti) wrote :

Code looks good, just waiting for the silo for proper testing.

review: Approve (code review)
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'data/com.canonical.powerd.xml'
2--- data/com.canonical.powerd.xml 2014-09-30 20:52:33 +0000
3+++ data/com.canonical.powerd.xml 2015-05-20 19:42:06 +0000
4@@ -3,6 +3,10 @@
5 <interface name="com.canonical.powerd">
6 <!-- Properties -->
7
8+ <property name="brightness" type="i" access="readwrite">
9+ </property>
10+
11+
12 <!-- Functions -->
13 <method name="requestSysState">
14 <arg type="s" name="name" direction="in" />
15
16=== modified file 'src/backlight.c'
17--- src/backlight.c 2015-01-15 23:01:52 +0000
18+++ src/backlight.c 2015-05-20 19:42:06 +0000
19@@ -120,8 +120,10 @@
20 /* Now set the final value (only care about error here as if
21 * the last set works, we're good) */
22 ret = set_brightness_hal(brightness);
23- if (!ret)
24+ if (!ret) {
25 current_brightness = brightness;
26+ powerd_update_bus_brightness();
27+ }
28 else
29 powerd_error("light_dev: failed to set brightness to %i", brightness);
30
31
32=== modified file 'src/powerd-internal.h'
33--- src/powerd-internal.h 2014-09-30 20:52:33 +0000
34+++ src/powerd-internal.h 2015-05-20 19:42:06 +0000
35@@ -114,6 +114,7 @@
36 const gchar * state_to_string(int state);
37 void powerd_sys_state_signal_emit(enum SysPowerStates state);
38 void powerd_wakeup_signal_emit(void);
39+void powerd_update_bus_brightness(void);
40 void clear_sys_state_by_owner(const char *owner);
41 gboolean powerd_suspend_active(void);
42
43
44=== modified file 'src/powerd-object.c'
45--- src/powerd-object.c 2015-05-07 20:14:20 +0000
46+++ src/powerd-object.c 2015-05-20 19:42:06 +0000
47@@ -192,6 +192,26 @@
48 return TRUE;
49 }
50
51+/* update our brightness from the bus property */
52+static void
53+notify_brightness(ComCanonicalPowerd *skel,
54+ GParamSpec *pspec G_GNUC_UNUSED,
55+ gpointer user_data G_GNUC_UNUSED)
56+{
57+ powerd_set_user_brightness(
58+ com_canonical_powerd_get_brightness(skel));
59+}
60+
61+/* update the bus property from our brightness */
62+void
63+powerd_update_bus_brightness(void)
64+{
65+ if ((powerd_source != NULL) && (powerd_source->priv->skel != NULL)) {
66+ com_canonical_powerd_set_brightness(
67+ powerd_source->priv->skel,
68+ powerd_get_brightness());
69+ }
70+}
71
72 void
73 powerd_bus_acquired_cb (GDBusConnection *connection,
74@@ -248,6 +268,10 @@
75 g_signal_connect(oskel, "handle-clear-wakeup",
76 G_CALLBACK(handle_clear_wakeup), powerd_source);
77
78+ powerd_update_bus_brightness();
79+ g_signal_connect(oskel, "notify::brightness",
80+ G_CALLBACK(notify_brightness), powerd_source);
81+
82 powerd_dbus_init_complete();
83 }
84

Subscribers

People subscribed via source and target branches