on xenial help sign in
Accept auto repeats for the power down button if timer is not yet running

Can happen if you start pressing the power down button when the screen was off Fixes: #1486953, #1488927 Approved by: Michael Zanetti

commitf7b0fa27a30782e8d4105e9a55c51a04f7fe5624 authorAlbert Astals Cid <albert.astals@canonical.com> dateMon 31 Aug 2015, 10:25 (11 years ago) parent2a1ddfe5329f14
2 files changed+16−2
qml/Components/PhysicalKeysMapper.qml+1−1 tests/qmltests/Components/tst_PhysicalKeysMapper.qml+15−1
qml/Components/PhysicalKeysMapper.qml+1−1
@@ -68,7 +68,7 @@ Item {
6868
6969 function onKeyPressed(event) {
7070 if ((event.key == Qt.Key_PowerDown || event.key == Qt.Key_PowerOff)
71− && !event.isAutoRepeat) {
71+ && (!event.isAutoRepeat || !powerKeyLongPressTimer.running)) {
7272
7373 // FIXME: We only consider power key presses if the screen is
7474 // on because of bugs 1410830/1409003. The theory is that when
tests/qmltests/Components/tst_PhysicalKeysMapper.qml+15−1
@@ -17,6 +17,7 @@
1717import QtQuick 2.0
1818import QtTest 1.0
1919import "../../../qml/Components"
20+import Powerd 0.1
2021
2122TestCase {
2223 name: "PhysicalKeysMapper"
@@ -56,6 +57,7 @@ TestCase {
5657 }
5758
5859 function init() {
60+ Powerd.status = Powerd.On;
5961 loader.active = true;
6062 tryCompare(loader.status == Loader.Ready);
6163 }
@@ -68,11 +70,23 @@ TestCase {
6870 screenshotSpy.clear();
6971 }
7072
71− function test_powerKeyLongPressed() {
73+ function test_powerKeyLongPressed_data() {
74+ return [
75+ { tag: "screenOn", status: Powerd.On },
76+ { tag: "screenOff", status: Powerd.Off },
77+ ];
78+ }
79+
80+ function test_powerKeyLongPressed(data) {
81+ Powerd.status = data.status;
7282 physicalKeysMapper.powerKeyLongPressTime = 500;
7383
7484 physicalKeysMapper.onKeyPressed({ key: Qt.Key_PowerDown, isAutoRepeat: false });
7585
86+ // After the first key press the screen is always on
87+ // and the rest of keypresses are auto repeat
88+ Powerd.status = Powerd.On;
89+
7690 for (var i = 0; i < 3; ++i) {
7791 wait(10);
7892 physicalKeysMapper.onKeyPressed({ key: Qt.Key_PowerDown, isAutoRepeat: true});