Merge lp:~afrantzis/unity-system-compositor/fix-1485737-notification-with-inactivity-zero into lp:unity-system-compositor

Proposed by Alexandros Frantzis
Status: Merged
Approved by: Alexandros Frantzis
Approved revision: 247
Merged at revision: 244
Proposed branch: lp:~afrantzis/unity-system-compositor/fix-1485737-notification-with-inactivity-zero
Merge into: lp:unity-system-compositor
Diff against target: 84 lines (+59/-0)
2 files modified
src/mir_screen.cpp (+10/-0)
tests/unit-tests/test_mir_screen.cpp (+49/-0)
To merge this branch: bzr merge lp:~afrantzis/unity-system-compositor/fix-1485737-notification-with-inactivity-zero
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Michael Terry (community) Approve
Mir development team Pending
Review via email: mp+268294@code.launchpad.net

Commit message

Cancel active timeouts and ignore notification timeouts when inactivity timeouts are zero (LP: #1485737)

Description of the change

Cancel active timeouts and ignore notification timeouts when inactivity timeouts are zero (LP: #1485737)

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Michael Terry (mterry) wrote :

Thanks for taking this branch over for me while I was EOD! :) Efficient.

Instead of directly comparing timeouts_inactivity (and making adding more timeout types even more complicated), might this be more generic if in the new "else" case we did:

else
{
   power_off_alarm->cancel();
   next_power_off = mir::time::Timestamp::max;
}

Instead of {}. This way, when a notification happens, the "new_next_power_off > next_power_off" check won't override the inactivity "never" timeout. But inactivity will still be turned off when the screen is manually turned off (as we do a next_power_off = {} when cancelling timers).

And of course the same for the dimmer logic.

Then we can drop all the extra if logic in this branch, I think?

review: Needs Information
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
247. By Alexandros Frantzis

Simplify code based on mterry's suggestion

Revision history for this message
Alexandros Frantzis (afrantzis) wrote :

> Then we can drop all the extra if logic in this branch, I think?

Good idea. Applied.

Revision history for this message
Michael Terry (mterry) wrote :

LGTM, but I'm not a Mir guy.

review: Approve
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
1=== modified file 'src/mir_screen.cpp'
2--- src/mir_screen.cpp 2015-07-27 17:01:28 +0000
3+++ src/mir_screen.cpp 2015-08-18 13:15:46 +0000
4@@ -257,6 +257,11 @@
5 next_power_off = new_next_power_off;
6 }
7 }
8+ else
9+ {
10+ power_off_alarm->cancel();
11+ next_power_off = mir::time::Timestamp::max();
12+ }
13
14 if (timeouts.dimming_timeout.count() > 0)
15 {
16@@ -267,6 +272,11 @@
17 next_dimming = new_next_dimming;
18 }
19 }
20+ else
21+ {
22+ dimmer_alarm->cancel();
23+ next_dimming = mir::time::Timestamp::max();
24+ }
25 }
26
27 void usc::MirScreen::enable_inactivity_timers_l(bool enable)
28
29=== modified file 'tests/unit-tests/test_mir_screen.cpp'
30--- tests/unit-tests/test_mir_screen.cpp 2015-07-27 17:01:28 +0000
31+++ tests/unit-tests/test_mir_screen.cpp 2015-08-18 13:15:46 +0000
32@@ -730,3 +730,52 @@
33 MirPowerMode::mir_power_mode_on,
34 PowerStateChangeReason::proximity);
35 }
36+
37+TEST_F(AMirScreen, disables_active_timeout_when_setting_zero_inactivity_timeouts)
38+{
39+ std::chrono::hours const ten_hours{10};
40+
41+ expect_no_reconfiguration();
42+ mir_screen.set_inactivity_timeouts(0, 0);
43+ timer->advance_by(ten_hours);
44+ verify_and_clear_expectations();
45+}
46+
47+TEST_F(AMirScreen, notification_timeout_is_ignored_if_inactivity_timeouts_are_zero)
48+{
49+ std::chrono::hours const ten_hours{10};
50+
51+ expect_no_reconfiguration();
52+ mir_screen.set_inactivity_timeouts(0, 0);
53+ receive_notification();
54+ timer->advance_by(ten_hours);
55+ verify_and_clear_expectations();
56+}
57+
58+TEST_F(AMirScreen, notification_timeout_is_respected_when_screen_is_off_if_inactivity_timeouts_are_zero)
59+{
60+ mir_screen.set_inactivity_timeouts(0, 0);
61+ turn_screen_off();
62+ receive_notification();
63+ verify_and_clear_expectations();
64+
65+ expect_screen_is_turned_off();
66+ timer->advance_by(notification_power_off_timeout);
67+ verify_and_clear_expectations();
68+}
69+
70+TEST_F(AMirScreen, keep_display_on_temporarily_after_notification_keeps_display_on_forever_if_inactivity_timeouts_are_zero)
71+{
72+ std::chrono::hours const ten_hours{10};
73+
74+ mir_screen.set_inactivity_timeouts(0, 0);
75+ turn_screen_off();
76+
77+ receive_notification();
78+ verify_and_clear_expectations();
79+
80+ expect_no_reconfiguration();
81+ mir_screen.keep_display_on_temporarily();
82+ timer->advance_by(ten_hours);
83+ verify_and_clear_expectations();
84+}

Subscribers

People subscribed via source and target branches