Merge lp:~afrantzis/unity-system-compositor/fix-1488413-pointer-and-key-unblank into lp:unity-system-compositor

Proposed by Alexandros Frantzis
Status: Merged
Approved by: Andreas Pokorny
Approved revision: 265
Merged at revision: 269
Proposed branch: lp:~afrantzis/unity-system-compositor/fix-1488413-pointer-and-key-unblank
Merge into: lp:unity-system-compositor
Diff against target: 132 lines (+58/-9)
3 files modified
src/screen_event_handler.cpp (+23/-4)
src/screen_event_handler.h (+1/-0)
tests/unit-tests/test_screen_event_handler.cpp (+34/-5)
To merge this branch: bzr merge lp:~afrantzis/unity-system-compositor/fix-1488413-pointer-and-key-unblank
Reviewer Review Type Date Requested Status
Andreas Pokorny (community) Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+283367@code.launchpad.net

Commit message

Unblank the screen when a pointer or key event arrives

Description of the change

Unblank the screen when a pointer or key event arrives

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
Andreas Pokorny (andreas-pokorny) wrote :

wow looks astonishing simple..

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/screen_event_handler.cpp'
2--- src/screen_event_handler.cpp 2015-11-07 13:29:29 +0000
3+++ src/screen_event_handler.cpp 2016-01-20 21:26:16 +0000
4@@ -71,16 +71,20 @@
5 }
6 else
7 {
8- std::lock_guard<std::mutex> lock{guard};
9- screen->keep_display_on_temporarily();
10+ keep_or_turn_screen_on();
11 }
12 }
13- else if (input_event_type == mir_input_event_type_touch ||
14- input_event_type == mir_input_event_type_pointer)
15+ else if (input_event_type == mir_input_event_type_touch)
16 {
17 std::lock_guard<std::mutex> lock{guard};
18 screen->keep_display_on_temporarily();
19 }
20+ else if (input_event_type == mir_input_event_type_pointer)
21+ {
22+ bool const filter_out_event = screen->get_screen_power_mode() != mir_power_mode_on;
23+ keep_or_turn_screen_on();
24+ return filter_out_event;
25+ }
26
27 return false;
28 }
29@@ -138,3 +142,18 @@
30 MirPowerMode::mir_power_mode_on, PowerStateChangeReason::power_key);
31 long_press_detected = true;
32 }
33+
34+void usc::ScreenEventHandler::keep_or_turn_screen_on()
35+{
36+ std::lock_guard<std::mutex> lock{guard};
37+
38+ if (screen->get_screen_power_mode() == mir_power_mode_off)
39+ {
40+ screen->set_screen_power_mode(
41+ MirPowerMode::mir_power_mode_on, PowerStateChangeReason::unknown);
42+ }
43+ else
44+ {
45+ screen->keep_display_on_temporarily();
46+ }
47+}
48
49=== modified file 'src/screen_event_handler.h'
50--- src/screen_event_handler.h 2015-04-29 14:39:19 +0000
51+++ src/screen_event_handler.h 2016-01-20 21:26:16 +0000
52@@ -56,6 +56,7 @@
53 void power_key_down();
54 void shutdown_alarm_notification();
55 void long_press_notification();
56+ void keep_or_turn_screen_on();
57
58 std::mutex guard;
59 std::shared_ptr<Screen> const screen;
60
61=== modified file 'tests/unit-tests/test_screen_event_handler.cpp'
62--- tests/unit-tests/test_screen_event_handler.cpp 2015-12-01 13:53:20 +0000
63+++ tests/unit-tests/test_screen_event_handler.cpp 2016-01-20 21:26:16 +0000
64@@ -203,23 +203,50 @@
65 touch_screen();
66 }
67
68-TEST_F(AScreenEventHandler, keeps_display_on_temporarily_on_pointer_event)
69-{
70+TEST_F(AScreenEventHandler, turns_on_screen_and_filters_first_pointer_event_when_screen_is_off)
71+{
72+ mock_screen.mock_mode = MirPowerMode::mir_power_mode_off;
73+ EXPECT_CALL(mock_screen,
74+ set_screen_power_mode(MirPowerMode::mir_power_mode_on,
75+ PowerStateChangeReason::unknown));
76+
77+ auto const event_filtered = screen_event_handler.handle(*pointer_event);
78+ EXPECT_TRUE(event_filtered);
79+}
80+
81+TEST_F(AScreenEventHandler, turns_on_screen_and_propagates_keys_when_screen_is_off)
82+{
83+ mock_screen.mock_mode = MirPowerMode::mir_power_mode_off;
84+ EXPECT_CALL(mock_screen,
85+ set_screen_power_mode(MirPowerMode::mir_power_mode_on,
86+ PowerStateChangeReason::unknown));
87+
88+ auto const event_filtered = screen_event_handler.handle(*another_key_down_event);
89+ EXPECT_FALSE(event_filtered);
90+}
91+
92+TEST_F(AScreenEventHandler, keeps_display_on_temporarily_for_pointer_event_when_screen_is_on)
93+{
94+ mock_screen.mock_mode = MirPowerMode::mir_power_mode_on;
95 EXPECT_CALL(mock_screen, keep_display_on_temporarily());
96
97 move_pointer();
98 }
99
100-TEST_F(AScreenEventHandler, keeps_display_on_temporarily_on_other_keys)
101+TEST_F(AScreenEventHandler, keeps_display_on_temporarily_key_event_when_screen_is_on)
102 {
103+ mock_screen.mock_mode = MirPowerMode::mir_power_mode_on;
104 EXPECT_CALL(mock_screen, keep_display_on_temporarily());
105
106 press_a_key();
107 }
108
109-TEST_F(AScreenEventHandler, does_not_keep_display_on_for_volume_keys)
110+TEST_F(AScreenEventHandler, does_not_affect_screen_state_for_volume_keys)
111 {
112+ using namespace testing;
113+
114 EXPECT_CALL(mock_screen, keep_display_on_temporarily()).Times(0);
115+ EXPECT_CALL(mock_screen, set_screen_power_mode(_,_)).Times(0);
116
117 press_volume_keys();
118 }
119@@ -255,10 +282,12 @@
120 release_power_key();
121 }
122
123-TEST_F(AScreenEventHandler, passes_through_all_handled_events)
124+TEST_F(AScreenEventHandler, passes_through_all_handled_events_when_screen_is_on)
125 {
126 using namespace testing;
127
128+ mock_screen.mock_mode = MirPowerMode::mir_power_mode_on;
129+
130 EXPECT_FALSE(screen_event_handler.handle(*power_key_down_event));
131 EXPECT_FALSE(screen_event_handler.handle(*power_key_up_event));
132 EXPECT_FALSE(screen_event_handler.handle(*touch_event));

Subscribers

People subscribed via source and target branches