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

Proposed by Charles Kerr
Status: Merged
Approved by: Alejandro J. Cura
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
Ricardo Salveti (community) code review Approve
Alejandro J. Cura (community) Approve
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.
Revision history for this message
Alejandro J. Cura (alecu) wrote :

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

review: Approve
Revision history for this message
Ricardo Salveti (rsalveti) wrote :

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

review: Approve (code review)
Revision history for this message
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
=== modified file 'data/com.canonical.powerd.xml'
--- data/com.canonical.powerd.xml 2014-09-30 20:52:33 +0000
+++ data/com.canonical.powerd.xml 2015-05-20 19:42:06 +0000
@@ -3,6 +3,10 @@
3 <interface name="com.canonical.powerd">3 <interface name="com.canonical.powerd">
4 <!-- Properties -->4 <!-- Properties -->
55
6 <property name="brightness" type="i" access="readwrite">
7 </property>
8
9
6 <!-- Functions -->10 <!-- Functions -->
7 <method name="requestSysState">11 <method name="requestSysState">
8 <arg type="s" name="name" direction="in" />12 <arg type="s" name="name" direction="in" />
913
=== modified file 'src/backlight.c'
--- src/backlight.c 2015-01-15 23:01:52 +0000
+++ src/backlight.c 2015-05-20 19:42:06 +0000
@@ -120,8 +120,10 @@
120 /* Now set the final value (only care about error here as if120 /* Now set the final value (only care about error here as if
121 * the last set works, we're good) */121 * the last set works, we're good) */
122 ret = set_brightness_hal(brightness);122 ret = set_brightness_hal(brightness);
123 if (!ret)123 if (!ret) {
124 current_brightness = brightness;124 current_brightness = brightness;
125 powerd_update_bus_brightness();
126 }
125 else127 else
126 powerd_error("light_dev: failed to set brightness to %i", brightness);128 powerd_error("light_dev: failed to set brightness to %i", brightness);
127129
128130
=== modified file 'src/powerd-internal.h'
--- src/powerd-internal.h 2014-09-30 20:52:33 +0000
+++ src/powerd-internal.h 2015-05-20 19:42:06 +0000
@@ -114,6 +114,7 @@
114const gchar * state_to_string(int state);114const gchar * state_to_string(int state);
115void powerd_sys_state_signal_emit(enum SysPowerStates state);115void powerd_sys_state_signal_emit(enum SysPowerStates state);
116void powerd_wakeup_signal_emit(void);116void powerd_wakeup_signal_emit(void);
117void powerd_update_bus_brightness(void);
117void clear_sys_state_by_owner(const char *owner);118void clear_sys_state_by_owner(const char *owner);
118gboolean powerd_suspend_active(void);119gboolean powerd_suspend_active(void);
119120
120121
=== modified file 'src/powerd-object.c'
--- src/powerd-object.c 2015-05-07 20:14:20 +0000
+++ src/powerd-object.c 2015-05-20 19:42:06 +0000
@@ -192,6 +192,26 @@
192 return TRUE;192 return TRUE;
193}193}
194194
195/* update our brightness from the bus property */
196static void
197notify_brightness(ComCanonicalPowerd *skel,
198 GParamSpec *pspec G_GNUC_UNUSED,
199 gpointer user_data G_GNUC_UNUSED)
200{
201 powerd_set_user_brightness(
202 com_canonical_powerd_get_brightness(skel));
203}
204
205/* update the bus property from our brightness */
206void
207powerd_update_bus_brightness(void)
208{
209 if ((powerd_source != NULL) && (powerd_source->priv->skel != NULL)) {
210 com_canonical_powerd_set_brightness(
211 powerd_source->priv->skel,
212 powerd_get_brightness());
213 }
214}
195215
196void216void
197powerd_bus_acquired_cb (GDBusConnection *connection,217powerd_bus_acquired_cb (GDBusConnection *connection,
@@ -248,6 +268,10 @@
248 g_signal_connect(oskel, "handle-clear-wakeup",268 g_signal_connect(oskel, "handle-clear-wakeup",
249 G_CALLBACK(handle_clear_wakeup), powerd_source);269 G_CALLBACK(handle_clear_wakeup), powerd_source);
250270
271 powerd_update_bus_brightness();
272 g_signal_connect(oskel, "notify::brightness",
273 G_CALLBACK(notify_brightness), powerd_source);
274
251 powerd_dbus_init_complete();275 powerd_dbus_init_complete();
252}276}
253277

Subscribers

People subscribed via source and target branches