Merge lp:~mfisch/powerd/nobrightness into lp:powerd

Proposed by Matt Fischer
Status: Merged
Approved by: Seth Forshee
Approved revision: 78
Merged at revision: 72
Proposed branch: lp:~mfisch/powerd/nobrightness
Merge into: lp:powerd
Diff against target: 646 lines (+64/-148)
8 files modified
cli/powerd-cli.c (+27/-55)
data/com.canonical.powerd.xml (+2/-4)
src/display-request.c (+13/-38)
src/display.c (+10/-29)
src/powerd-internal.h (+2/-3)
src/powerd-object.c (+3/-3)
src/powerd.cpp (+4/-6)
src/powerd.h (+3/-10)
To merge this branch: bzr merge lp:~mfisch/powerd/nobrightness
Reviewer Review Type Date Requested Status
Seth Forshee (community) Approve
PS Jenkins bot continuous-integration Approve
Review via email: mp+175684@code.launchpad.net

Commit message

Simplify the API by dropping the special brightness setting and instead make it a flag.

Description of the change

Simplify the API by dropping the special brightness setting and instead make it a flag.

To post a comment you must log in.
lp:~mfisch/powerd/nobrightness updated
77. By Matt Fischer

Fixing spacing in a macro

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
lp:~mfisch/powerd/nobrightness updated
78. By Matt Fischer

Fixing typo

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Seth Forshee (sforshee) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'cli/powerd-cli.c'
2--- cli/powerd-cli.c 2013-07-17 18:56:10 +0000
3+++ cli/powerd-cli.c 2013-07-19 20:03:25 +0000
4@@ -39,7 +39,7 @@
5 })
6
7 #define TEST_NUM_SYS_REQUESTS 5
8-#define TEST_NUM_DISP_REQUESTS POWERD_NUM_DISPLAY_STATES * POWERD_NUM_DISPLAY_BRIGHTNESS_STATES
9+#define TEST_NUM_DISP_REQUESTS (POWERD_NUM_DISPLAY_STATES * 2)
10
11 /* Set to TRUE during tests to silence expected errors */
12 static gboolean silent_errors = FALSE;
13@@ -62,7 +62,6 @@
14 struct PublicDispRequest {
15 const gchar *owner;
16 enum powerd_display_state state;
17- enum powerd_display_brightness brightness;
18 guint32 flags;
19 };
20
21@@ -87,7 +86,6 @@
22 {
23 int system_state;
24 int display_state;
25- int display_brightness;
26 guint32 display_flags;
27
28 if (!strcmp(signal_name,"SysPowerStateChange")) {
29@@ -95,10 +93,9 @@
30 printf("Received %s: state=%d\n", signal_name, system_state);
31 }
32 else if (!strcmp(signal_name,"DisplayPowerStateChange")) {
33- g_variant_get(parameters, "(iiu)", &display_state,
34- &display_brightness, &display_flags);
35- printf("Received %s: state=%d brightness=%d flags=%#08x\n",
36- signal_name, display_state, display_brightness, display_flags);
37+ g_variant_get(parameters, "(iu)", &display_state, &display_flags);
38+ printf("Received %s: state=%d flags=%#08x\n",
39+ signal_name, display_state, display_flags);
40 }
41 else {
42 cli_debug("Unknown signal from %s: %s", sender_name, signal_name);
43@@ -161,7 +158,7 @@
44
45 ret = g_dbus_proxy_call_sync(powerd_proxy,
46 "requestDisplayState",
47- g_variant_new("(iiu)", pdr.state, pdr.brightness, pdr.flags),
48+ g_variant_new("(iu)", pdr.state, pdr.flags),
49 G_DBUS_CALL_FLAGS_NONE,
50 -1,
51 NULL,
52@@ -200,8 +197,7 @@
53
54 ret = g_dbus_proxy_call_sync(powerd_proxy,
55 "updateDisplayState",
56- g_variant_new("(siiu)", cookie, pdr.state, pdr.brightness,
57- pdr.flags),
58+ g_variant_new("(siu)", cookie, pdr.state, pdr.flags),
59 G_DBUS_CALL_FLAGS_NONE,
60 -1,
61 NULL,
62@@ -286,12 +282,11 @@
63 g_error_free(error);
64 }
65 else {
66- g_variant_get(ret, "(a(siiu))", &iter);
67+ g_variant_get(ret, "(a(siu))", &iter);
68 while ((item = g_variant_iter_next_value (iter))) {
69 g_variant_get_child(item, 0, "s", &pdr.owner);
70 g_variant_get_child(item, 1, "i", &pdr.state);
71- g_variant_get_child(item, 2, "i", &pdr.brightness);
72- g_variant_get_child(item, 3, "u", &pdr.flags);
73+ g_variant_get_child(item, 2, "u", &pdr.flags);
74 g_array_append_val(retarray, pdr);
75 g_variant_unref(item);
76 }
77@@ -311,8 +306,8 @@
78 } else {
79 for (i = 0; i < requests->len; i++) {
80 pdr = &g_array_index(requests, struct PublicDispRequest, i);
81- printf(" Owner: %s, State: %d, Brightness: %d, Flags: %#08x\n",
82- pdr->owner, pdr->state, pdr->brightness, pdr->flags);
83+ printf(" Owner: %s, State: %d, Flags: %#08x\n",
84+ pdr->owner, pdr->state, pdr->flags);
85 }
86 }
87 }
88@@ -533,7 +528,8 @@
89 runDisplayTests()
90 {
91 int i;
92- int state, brightness;
93+ int state = 0;
94+ gboolean bright = FALSE;
95 powerd_cookie_t cookie, cookies[TEST_NUM_DISP_REQUESTS];
96 GArray *requests = NULL;
97 struct PublicDispRequest pdr = {0,};
98@@ -543,18 +539,17 @@
99 // Hold active state request as long we're running tests
100 requestSysState(POWERD_SYS_STATE_ACTIVE, &main_cookie);
101
102- state = 0;
103- brightness = 0;
104 for (i = 0; i < TEST_NUM_DISP_REQUESTS; i++) {
105 pdr.state = state++;
106- pdr.brightness = brightness++;
107+ pdr.flags = 0;
108+ if (bright) {
109+ pdr.flags |= POWERD_DISPLAY_FLAG_BRIGHT;
110+ }
111 do_test(requestDisplayState(pdr, &cookies[i]) == TRUE);
112 if (state >= POWERD_NUM_DISPLAY_STATES) {
113 state = 0;
114 }
115- if (brightness >= POWERD_NUM_DISPLAY_BRIGHTNESS_STATES) {
116- brightness = 0;
117- }
118+ bright = !bright;
119 }
120
121 // Make sure we have at least NUM_REQUESTS
122@@ -588,17 +583,11 @@
123 do_test(requestDisplayState(pdr, &cookie) == FALSE);
124
125 pdr.state = POWERD_DISPLAY_STATE_ON;
126- pdr.brightness = POWERD_NUM_DISPLAY_BRIGHTNESS_STATES;
127- do_test(requestDisplayState(pdr, &cookie) == FALSE);
128-
129- pdr.state = POWERD_DISPLAY_STATE_ON;
130- pdr.brightness = POWERD_DISPLAY_BRIGHTNESS_DONT_CARE;
131 pdr.flags = 0xdeadbeef;
132 do_test(requestDisplayState(pdr, &cookie) == FALSE);
133
134 // updateDisplayState tests
135 pdr.state = POWERD_DISPLAY_STATE_ON;
136- pdr.brightness = POWERD_DISPLAY_BRIGHTNESS_BRIGHT;
137 pdr.flags = 0;
138 do_test(requestDisplayState(pdr, &cookie) == TRUE);
139
140@@ -608,7 +597,6 @@
141 pdr.state = POWERD_DISPLAY_STATE_DONT_CARE;
142 do_test(updateDisplayState(pdr, cookie) == TRUE);
143
144- pdr.brightness = POWERD_DISPLAY_BRIGHTNESS_DIM;
145 pdr.flags = POWERD_DISPLAY_FLAG_DISABLE_AUTOBRIGHTNESS;
146 do_test(updateDisplayState(pdr, cookie) == TRUE);
147
148@@ -699,27 +687,8 @@
149 return FALSE;
150 }
151
152- if (!strcasecmp(argv[3],"dc")) {
153- pdr->brightness = POWERD_DISPLAY_BRIGHTNESS_DONT_CARE;
154- cli_debug("Requesting Brightness Don't Care");
155- }
156- else if (!strcasecmp(argv[3],"dim")) {
157- cli_debug("Requesting Brightness Dim");
158- pdr->brightness = POWERD_DISPLAY_BRIGHTNESS_DIM;
159- }
160- else if (!strcasecmp(argv[3],"bright")) {
161- cli_debug("Requesting Brightness Bright");
162- pdr->brightness = POWERD_DISPLAY_BRIGHTNESS_BRIGHT;
163- }
164- else {
165- fprintf(stderr,"invalid brightness %s, must be one of dc, dim, or bright\n",
166- argv[2]);
167- return FALSE;
168- }
169-
170 pdr->flags = 0;
171-
172- for (i=4; i<argc; i++) {
173+ for (i=3; i<argc; i++) {
174 if (!strcmp(argv[i],"proximity")) {
175 pdr->flags |= POWERD_DISPLAY_FLAG_USE_PROXIMITY;
176 cli_debug("Requesting Proximity Sensor Enabled");
177@@ -728,6 +697,10 @@
178 pdr->flags |= POWERD_DISPLAY_FLAG_DISABLE_AUTOBRIGHTNESS;
179 cli_debug("Requesting Proximity Disable AutoBrightness");
180 }
181+ else if (!strcasecmp(argv[i],"bright")) {
182+ pdr->flags |= POWERD_DISPLAY_FLAG_BRIGHT;
183+ cli_debug("Requesting Bright");
184+ }
185 }
186
187 return TRUE;
188@@ -744,14 +717,14 @@
189 "exit, causing the request to be dropped.\n");
190 printf("clear-sys <cookie> - clear a System state request given a cookie\n");
191 printf("clear-disp <cookie> - clear a Display state request given a cookie\n");
192- printf("display <on|dc> <dc|dim|bright> [proximity] [disableab]\n"\
193+ printf("display <on|dc> [bright] [proximity] [disableab]\n"\
194 "\tMake a display state request with the input parameters.\n"\
195 "\tThe first argument represents the state of the display:\n"\
196 "\tOn, Off, or Don't Care (dc).\n"\
197- "\tThe second arguement represents the state of the brightness:\n"\
198- "\tDefault, Dim, or Bright\n"\
199- "\tThe final optional arguments enable the proximity sensor [proximity]\n"\
200- "\tand disable autobrightness [disableab], respectively\n");
201+ "\tThe final optional arguments respectively:\n"\
202+ "\t * make the screen bright [bright]\n"\
203+ "\t * enable the proximity sensor [proximity]\n"\
204+ "\t * disable autobrightness [disableab]\n");
205 printf("help - display this usage information\n");
206 printf("list - list outstanding requests\n");
207 printf("listen - listen for signals from powerd. This runs a\n"\
208@@ -924,7 +897,6 @@
209 requestSysState(POWERD_SYS_STATE_ACTIVE,&cookie);
210 requestSysState(POWERD_SYS_STATE_ACTIVE,&cookie);
211 pdr.state = POWERD_DISPLAY_STATE_DONT_CARE;
212- pdr.brightness= POWERD_DISPLAY_STATE_DONT_CARE;
213 pdr.flags = 0;
214 requestDisplayState(pdr, &cookie);
215 requestDisplayState(pdr, &cookie);
216
217=== modified file 'data/com.canonical.powerd.xml'
218--- data/com.canonical.powerd.xml 2013-07-02 13:52:40 +0000
219+++ data/com.canonical.powerd.xml 2013-07-19 20:03:25 +0000
220@@ -15,7 +15,6 @@
221
222 <method name="requestDisplayState">
223 <arg type="i" name="state" direction="in" />
224- <arg type="i" name="brightness" direction="in" />
225 <arg type="u" name="flags" direction="in" />
226 <arg type="s" name="cookie" direction="out" />
227 </method>
228@@ -23,7 +22,6 @@
229 <method name="updateDisplayState">
230 <arg type="s" name="cookie" direction="in" />
231 <arg type="i" name="state" direction="in" />
232- <arg type="i" name="brightness" direction="in" />
233 <arg type="u" name="flags" direction="in" />
234 </method>
235
236@@ -37,7 +35,7 @@
237 </method>
238
239 <method name="listDisplayRequests">
240- <arg type="a(siiu)" name="requestList" direction="out" />
241+ <arg type="a(siu)" name="requestList" direction="out" />
242 </method>
243
244 <!-- Signals -->
245@@ -46,7 +44,7 @@
246 </signal>
247
248 <signal name="DisplayPowerStateChange">
249- <arg type="(iiu)" name="displayState" direction="out" />
250+ <arg type="(iu)" name="displayState" direction="out" />
251 </signal>
252 </interface>
253 </node>
254
255=== modified file 'src/display-request.c'
256--- src/display-request.c 2013-07-02 16:37:37 +0000
257+++ src/display-request.c 2013-07-19 20:03:25 +0000
258@@ -40,13 +40,11 @@
259
260 static struct {
261 unsigned int state[POWERD_NUM_DISPLAY_STATES];
262- unsigned int brightness[POWERD_NUM_DISPLAY_BRIGHTNESS_STATES];
263 unsigned int flags[POWERD_NUM_DISPLAY_FLAGS];
264 } display_state_count;
265
266 static struct powerd_display_request internal_state = {
267 .state = POWERD_DISPLAY_STATE_DONT_CARE,
268- .brightness = POWERD_DISPLAY_BRIGHTNESS_DONT_CARE,
269 .flags = 0,
270 };
271
272@@ -65,14 +63,6 @@
273 else
274 new_state.state = POWERD_DISPLAY_STATE_DONT_CARE;
275
276- new_state.brightness = POWERD_DISPLAY_BRIGHTNESS_DONT_CARE;
277- for (i = POWERD_NUM_DISPLAY_BRIGHTNESS_STATES - 1; i > 0; i--) {
278- if (display_state_count.brightness[i] > 0) {
279- new_state.brightness = i;
280- break;
281- }
282- }
283-
284 for (i = 0; i < POWERD_NUM_DISPLAY_FLAGS; i++) {
285 if (display_state_count.flags[i] > 0)
286 new_state.flags |= (1U << i);
287@@ -83,8 +73,8 @@
288 return;
289 }
290
291- powerd_debug("Internal state updated: state %d brightness %d flags 0x%08x",
292- new_state.state, new_state.brightness, new_state.flags);
293+ powerd_debug("Internal state updated: state %d flags 0x%08x",
294+ new_state.state, new_state.flags);
295 internal_state = new_state;
296 powerd_set_display_state(&internal_state);
297 powerd_display_state_signal_emit(&internal_state);
298@@ -96,7 +86,6 @@
299 int i;
300
301 display_state_count.state[req->state]++;
302- display_state_count.brightness[req->brightness]++;
303
304 flags = req->flags;
305 for (i = 0; flags && i < POWERD_NUM_DISPLAY_FLAGS; flags >>= 1, i++) {
306@@ -113,9 +102,6 @@
307 if (display_state_count.state[req->state] > 0)
308 display_state_count.state[req->state]--;
309
310- if (display_state_count.brightness[req->brightness] > 0)
311- display_state_count.brightness[req->brightness]--;
312-
313 flags = req->flags;
314 for (i = 0; flags && i < POWERD_NUM_DISPLAY_FLAGS; flags >>= 1, i++) {
315 if ((flags & 1) && display_state_count.flags[i] > 0)
316@@ -145,7 +131,6 @@
317 __add_request(new_req);
318
319 ireq->req.state = new_req->state;
320- ireq->req.brightness = new_req->brightness;
321 ireq->req.flags = new_req->flags;
322
323 update_internal_state();
324@@ -207,12 +192,6 @@
325 return -EINVAL;
326 }
327
328- if ((unsigned)request->brightness >= POWERD_NUM_DISPLAY_BRIGHTNESS_STATES) {
329- powerd_warn("Invalid display brightness requested: %d",
330- request->brightness);
331- return -EINVAL;
332- }
333-
334 /*
335 * XXX: This will warn if we get up to 32 flags, but in that
336 * case the check should just be removed.
337@@ -276,7 +255,7 @@
338
339 gboolean handle_add_display_request(PowerdSource *obj,
340 GDBusMethodInvocation *invocation,
341- int state, int brightness, guint32 flags)
342+ int state, guint32 flags)
343 {
344 struct powerd_display_request req;
345 const char *owner;
346@@ -286,11 +265,10 @@
347 memset(&req, 0, sizeof(req));
348
349 owner = g_dbus_method_invocation_get_sender(invocation);
350- powerd_debug("%s from %s: state %d brightness %d flags %#08x",
351- __func__, owner, state, brightness, flags);
352+ powerd_debug("%s from %s: state %d flags %#08x",
353+ __func__, owner, state, flags);
354
355 req.state = state;
356- req.brightness = brightness;
357 req.flags = flags;
358
359 ret = __powerd_add_display_request(&req, owner);
360@@ -311,7 +289,7 @@
361 gboolean handle_update_display_request(PowerdSource *obj,
362 GDBusMethodInvocation *invocation,
363 const gchar *ext_cookie, int state,
364- int brightness, guint32 flags)
365+ guint32 flags)
366 {
367 struct powerd_display_request req;
368 uuid_t cookie;
369@@ -319,9 +297,9 @@
370
371 memset(&req, 0, sizeof(req));
372
373- powerd_debug("%s from %s: cookie: %s state %d brightness %d flags %#08x",
374+ powerd_debug("%s from %s: cookie: %s state %d flags %#08x",
375 __func__, g_dbus_method_invocation_get_sender(invocation),
376- ext_cookie, state, brightness, flags);
377+ ext_cookie, state, flags);
378
379 if (uuid_parse(ext_cookie, cookie)) {
380 g_dbus_method_invocation_return_error(invocation, G_DBUS_ERROR,
381@@ -333,7 +311,6 @@
382
383 memcpy(req.cookie, cookie, sizeof(uuid_t));
384 req.state = state;
385- req.brightness = brightness;
386 req.flags = flags;
387
388 ret = powerd_update_display_request(&req);
389@@ -387,12 +364,10 @@
390 char cookie_str[UUID_STR_LEN];
391
392 uuid_unparse(req->cookie, cookie_str);
393- powerd_debug(" owner: %s, cookie: %s, state: %d, brightness: %d, flags: %#08x",
394- ireq->owner, cookie_str, req->state, req->brightness,
395- req->flags);
396+ powerd_debug(" owner: %s, cookie: %s, state: %d, flags: %#08x",
397+ ireq->owner, cookie_str, req->state, req->flags);
398
399- g_variant_builder_add(builder, "(siiu)", ireq->owner, req->state,
400- req->brightness, req->flags);
401+ g_variant_builder_add(builder, "(siu)", ireq->owner, req->state, req->flags);
402 }
403
404 static int build_display_request_list(GVariantBuilder *builder)
405@@ -409,13 +384,13 @@
406 GVariantBuilder *builder;
407 int count;
408
409- builder = g_variant_builder_new(G_VARIANT_TYPE("a(siiu)"));
410+ builder = g_variant_builder_new(G_VARIANT_TYPE("a(siu)"));
411 count = build_display_request_list(builder);
412 if (count > 0) {
413 list = g_variant_builder_end(builder);
414 } else {
415 g_variant_builder_clear(builder);
416- list = g_variant_new_array(G_VARIANT_TYPE("(siiu)"), NULL, 0);
417+ list = g_variant_new_array(G_VARIANT_TYPE("(siu)"), NULL, 0);
418 }
419
420 tuple = g_variant_new_tuple(&list, 1);
421
422=== modified file 'src/display.c'
423--- src/display.c 2013-07-02 16:37:37 +0000
424+++ src/display.c 2013-07-19 20:03:25 +0000
425@@ -51,7 +51,6 @@
426 /* Currently requested state of the display */
427 struct powerd_display_request internal_state = {
428 .state = DISPLAY_STATE_OFF,
429- .brightness = POWERD_DISPLAY_BRIGHTNESS_DONT_CARE,
430 .flags = 0,
431 };
432
433@@ -86,12 +85,6 @@
434 [POWERD_DISPLAY_STATE_ON] = "on",
435 };
436
437-static const char *brightness_state_strs[POWERD_NUM_DISPLAY_BRIGHTNESS_STATES] = {
438- [POWERD_DISPLAY_BRIGHTNESS_DONT_CARE] = "don't care",
439- [POWERD_DISPLAY_BRIGHTNESS_DIM] = "dim",
440- [POWERD_DISPLAY_BRIGHTNESS_BRIGHT] = "bright",
441-};
442-
443 static const char *display_state_to_str(enum powerd_display_state state)
444 {
445 if (state >= POWERD_NUM_DISPLAY_STATES)
446@@ -99,13 +92,6 @@
447 return display_state_strs[state];
448 }
449
450-static const char *brightness_to_str(enum powerd_display_brightness brightness)
451-{
452- if (brightness >= POWERD_NUM_DISPLAY_BRIGHTNESS_STATES)
453- return "invalid";
454- return brightness_state_strs[brightness];
455-}
456-
457 static void turn_on_display(void) {
458 powerd_debug("turning on display");
459 sf_unblank(0);
460@@ -117,17 +103,13 @@
461 return actual_screen_state == POWERD_DISPLAY_STATE_ON;
462 }
463
464-static int get_target_brightness(enum powerd_display_brightness brightness,
465- int hw_value)
466+static int get_target_brightness(gboolean request_bright, int hw_value)
467 {
468- if (brightness < 0)
469- return saved_brightness;
470-
471 /*
472 * If not requesting bright, return the dim brightness, but never
473 * return something higher than the current "bright" brightness.
474 */
475- if (brightness < POWERD_DISPLAY_BRIGHTNESS_BRIGHT)
476+ if (request_bright == FALSE)
477 return (saved_brightness < dim_brightness) ?
478 saved_brightness : dim_brightness;
479
480@@ -135,8 +117,7 @@
481 * If bright is requested and our current state is also bright,
482 * just return the current hardware value.
483 */
484- if (internal_state.brightness == POWERD_DISPLAY_BRIGHTNESS_BRIGHT &&
485- hw_value > 0)
486+ if ((internal_state.flags & POWERD_DISPLAY_FLAG_BRIGHT) && (hw_value > 0))
487 return hw_value;
488
489 /* Otherwise we're going from dim to bright, so return the saved value */
490@@ -154,10 +135,11 @@
491 if (hw_brightness < 0)
492 hw_brightness = saved_brightness;
493
494- if (internal_state.brightness == POWERD_DISPLAY_BRIGHTNESS_BRIGHT &&
495- hw_brightness != 0)
496+ if ((internal_state.flags & POWERD_DISPLAY_FLAG_BRIGHT) &&
497+ (hw_brightness != 0))
498 saved_brightness = hw_brightness;
499- target_brightness = get_target_brightness(req->brightness, hw_brightness);
500+ target_brightness = get_target_brightness((!!(req->flags & POWERD_DISPLAY_FLAG_BRIGHT)),
501+ hw_brightness);
502
503 applied_state = screen_off_overrides ? DISPLAY_STATE_OFF : state;
504
505@@ -199,7 +181,8 @@
506 turn_on_display();
507 } else {
508 /* Only changing brightness */
509- if (req->brightness != internal_state.brightness)
510+ if ((req->flags & POWERD_DISPLAY_FLAG_BRIGHT) !=
511+ (internal_state.flags & POWERD_DISPLAY_FLAG_BRIGHT))
512 powerd_set_brightness(target_brightness);
513 }
514 break;
515@@ -237,11 +220,9 @@
516 */
517 void powerd_set_display_state(struct powerd_display_request *req)
518 {
519- powerd_debug("powerd_set_display_state: %s -> %s, %s -> %s, 0x%x -> 0x%x",
520+ powerd_debug("powerd_set_display_state: %s -> %s, 0x%x -> 0x%x",
521 display_state_to_str(internal_state.state),
522 display_state_to_str(req->state),
523- brightness_to_str(internal_state.brightness),
524- brightness_to_str(req->brightness),
525 internal_state.flags, req->flags);
526
527 /* Update flags before display state to ensure proximity flag is
528
529=== modified file 'src/powerd-internal.h'
530--- src/powerd-internal.h 2013-07-12 19:14:33 +0000
531+++ src/powerd-internal.h 2013-07-19 20:03:25 +0000
532@@ -36,7 +36,6 @@
533 struct powerd_display_request {
534 uuid_t cookie;
535 enum powerd_display_state state;
536- enum powerd_display_brightness brightness;
537 guint32 flags;
538 };
539
540@@ -87,11 +86,11 @@
541 void display_request_deinit(void);
542 gboolean handle_add_display_request(PowerdSource *obj,
543 GDBusMethodInvocation *invocation,
544- int state, int brightness, guint32 flags);
545+ int state, guint32 flags);
546 gboolean handle_update_display_request(PowerdSource *obj,
547 GDBusMethodInvocation *invocation,
548 const gchar *ext_cookie, int state,
549- int brightness, guint32 flags);
550+ guint32 flags);
551 gboolean handle_clear_display_request(PowerdSource *obj,
552 GDBusMethodInvocation *invocation,
553 const gchar *ext_cookie);
554
555=== modified file 'src/powerd-object.c'
556--- src/powerd-object.c 2013-07-10 23:27:14 +0000
557+++ src/powerd-object.c 2013-07-19 20:03:25 +0000
558@@ -177,15 +177,15 @@
559 if (!powerd_source)
560 return;
561
562- powerd_debug("Emitting signal for display state change: state=%d brightness=%d flags=0x%08x",
563- req->state, req->brightness, req->flags);
564+ powerd_debug("Emitting signal for display state change: state=%d flags=0x%08x",
565+ req->state, req->flags);
566 g_dbus_connection_emit_signal(
567 POWERD_SOURCE_GET_PRIVATE(powerd_source)->system_bus,
568 NULL, /* destination */
569 "/com/canonical/powerd",
570 "com.canonical.powerd",
571 "DisplayPowerStateChange",
572- g_variant_new("(iiu)", req->state, req->brightness, req->flags),
573+ g_variant_new("(iu)", req->state, req->flags),
574 &error);
575 if (error) {
576 powerd_warn("Unable to signal a state change update: %s", error->message);
577
578=== modified file 'src/powerd.cpp'
579--- src/powerd.cpp 2013-07-12 19:14:33 +0000
580+++ src/powerd.cpp 2013-07-19 20:03:25 +0000
581@@ -105,15 +105,13 @@
582 static struct powerd_display_request activity_timer_req = {
583 {0,}, /* cookie */
584 POWERD_DISPLAY_STATE_ON, /* state */
585- POWERD_DISPLAY_BRIGHTNESS_BRIGHT, /* brightness */
586- 0 /* flags */
587+ POWERD_DISPLAY_FLAG_BRIGHT /* flags */
588 };
589
590 /* Display request for use of proximity sensor during phone calls */
591 static struct powerd_display_request prox_sensor_req = {
592 {0,}, /* cookie */
593 POWERD_DISPLAY_STATE_DONT_CARE, /* state */
594- POWERD_DISPLAY_BRIGHTNESS_DONT_CARE, /* brightness */
595 POWERD_DISPLAY_FLAG_USE_PROXIMITY /* flags */
596 };
597
598@@ -214,15 +212,15 @@
599 powerd_remove_display_request(activity_timer_req.cookie);
600 } else {
601 if (new_state == SCREEN_STATE_DIM)
602- activity_timer_req.brightness = POWERD_DISPLAY_BRIGHTNESS_DIM;
603+ activity_timer_req.flags &= ~POWERD_DISPLAY_FLAG_BRIGHT;
604 else
605- activity_timer_req.brightness = POWERD_DISPLAY_BRIGHTNESS_BRIGHT;
606+ activity_timer_req.flags |= POWERD_DISPLAY_FLAG_BRIGHT;
607
608 if (activity_timer_screen_state == SCREEN_STATE_OFF)
609 ret = powerd_add_display_request(&activity_timer_req);
610 else
611 ret = powerd_update_display_request(&activity_timer_req);
612-
613+
614 if (ret)
615 powerd_warn("Error adding display state request for activity timer");
616 }
617
618=== modified file 'src/powerd.h'
619--- src/powerd.h 2013-06-13 20:48:54 +0000
620+++ src/powerd.h 2013-07-19 20:03:25 +0000
621@@ -42,22 +42,15 @@
622 POWERD_NUM_DISPLAY_STATES
623 };
624
625-enum powerd_display_brightness {
626- POWERD_DISPLAY_BRIGHTNESS_DONT_CARE = 0,
627- POWERD_DISPLAY_BRIGHTNESS_DIM,
628- POWERD_DISPLAY_BRIGHTNESS_BRIGHT,
629-
630- /* Keep last */
631- POWERD_NUM_DISPLAY_BRIGHTNESS_STATES
632-};
633-
634 /* Use proximity sensor to override screen state */
635 #define POWERD_DISPLAY_FLAG_USE_PROXIMITY (1 << 0)
636 /* Force autobrightness to be disabled */
637 #define POWERD_DISPLAY_FLAG_DISABLE_AUTOBRIGHTNESS (1 << 1)
638+/* Request the screen to stay bright */
639+#define POWERD_DISPLAY_FLAG_BRIGHT (1 << 2)
640
641 /* Must be updated when new flags are added */
642-#define POWERD_NUM_DISPLAY_FLAGS 2
643+#define POWERD_NUM_DISPLAY_FLAGS 3
644
645 /*
646 * Clients should treat this as an opaque type. Though this isn't really

Subscribers

People subscribed via source and target branches