Merge lp:~albaguirre/unity-system-compositor/fix-1383279 into lp:unity-system-compositor

Proposed by Alberto Aguirre
Status: Work in progress
Proposed branch: lp:~albaguirre/unity-system-compositor/fix-1383279
Merge into: lp:unity-system-compositor
Diff against target: 30 lines (+15/-4)
1 file modified
src/powerkey_handler.cpp (+15/-4)
To merge this branch: bzr merge lp:~albaguirre/unity-system-compositor/fix-1383279
Reviewer Review Type Date Requested Status
Alan Griffiths Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+239255@code.launchpad.net

Commit message

Ignore repeated power key up events within 100ms time window.

Description of the change

Ignore repeated power key up events within 100ms time window.

This prevents the queue up of power key events (which make the screen flash on/off for seconds) when the power key is repeatedly pressed specially for krillin devices.

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
Alan Griffiths (alan-griffiths) wrote :

Not quite the way I'd code it. (I'd save the end of the ignore window and compare that with now()).

But seems to do what it intends.

review: Approve
Revision history for this message
Alberto Aguirre (albaguirre) wrote :

Unmerged revisions

184. By Alberto Aguirre

Ignore repeated power key up events within 100ms time window.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/powerkey_handler.cpp'
2--- src/powerkey_handler.cpp 2014-07-21 21:33:35 +0000
3+++ src/powerkey_handler.cpp 2014-10-22 18:30:54 +0000
4@@ -67,12 +67,23 @@
5
6 void PowerKeyHandler::power_key_up()
7 {
8+ using namespace std::chrono;
9+ static auto prev_tp = steady_clock::now();
10+ static std::chrono::milliseconds ignore_repeat_keyups_time_window{100};
11+
12+ auto time_after_last_key_up = duration_cast<milliseconds>(steady_clock::now() - prev_tp);
13+
14 std::lock_guard<std::mutex> lock{guard};
15- shutdown_alarm->cancel();
16- long_press_alarm->cancel();
17- if (!long_press_detected)
18+ if (time_after_last_key_up > ignore_repeat_keyups_time_window)
19 {
20- screen_state_handler->toggle_screen_power_mode(PowerStateChangeReason::power_key);
21+ shutdown_alarm->cancel();
22+ long_press_alarm->cancel();
23+
24+ if (!long_press_detected)
25+ {
26+ screen_state_handler->toggle_screen_power_mode(PowerStateChangeReason::power_key);
27+ }
28+ prev_tp = steady_clock::now();
29 }
30 }
31

Subscribers

People subscribed via source and target branches