on xenial help sign in
Accept auto repeats for the power down button if timer is not yet running
f7b0fa2Albert Astals Cid
qml/Components/PhysicalKeysMapper.qml+1−1
@@ -68,7 +68,7 @@ Item {
68
68
69 function onKeyPressed(event) {
69 function onKeyPressed(event) {
70 if ((event.key == Qt.Key_PowerDown || event.key == Qt.Key_PowerOff)
70 if ((event.key == Qt.Key_PowerDown || event.key == Qt.Key_PowerOff)
71− && !event.isAutoRepeat) {
71+ && (!event.isAutoRepeat || !powerKeyLongPressTimer.running)) {
72
72
73 // FIXME: We only consider power key presses if the screen is
73 // FIXME: We only consider power key presses if the screen is
74 // on because of bugs 1410830/1409003. The theory is that when
74 // on because of bugs 1410830/1409003. The theory is that when
tests/qmltests/Components/tst_PhysicalKeysMapper.qml+15−1
@@ -17,6 +17,7 @@
17import QtQuick 2.0
17import QtQuick 2.0
18import QtTest 1.0
18import QtTest 1.0
19import "../../../qml/Components"
19import "../../../qml/Components"
20+import Powerd 0.1
20
21
21TestCase {
22TestCase {
22 name: "PhysicalKeysMapper"
23 name: "PhysicalKeysMapper"
@@ -56,6 +57,7 @@ TestCase {
56 }
57 }
57
58
58 function init() {
59 function init() {
60+ Powerd.status = Powerd.On;
59 loader.active = true;
61 loader.active = true;
60 tryCompare(loader.status == Loader.Ready);
62 tryCompare(loader.status == Loader.Ready);
61 }
63 }
@@ -68,11 +70,23 @@ TestCase {
68 screenshotSpy.clear();
70 screenshotSpy.clear();
69 }
71 }
70
72
73+ function test_powerKeyLongPressed_data() {
74+ return [
75+ { tag: "screenOn", status: Powerd.On },
76+ { tag: "screenOff", status: Powerd.Off },
77+ ];
78+ }
79+
71− function test_powerKeyLongPressed() {
80+ function test_powerKeyLongPressed(data) {
81+ Powerd.status = data.status;
72 physicalKeysMapper.powerKeyLongPressTime = 500;
82 physicalKeysMapper.powerKeyLongPressTime = 500;
73
83
74 physicalKeysMapper.onKeyPressed({ key: Qt.Key_PowerDown, isAutoRepeat: false });
84 physicalKeysMapper.onKeyPressed({ key: Qt.Key_PowerDown, isAutoRepeat: false });
75
85
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+
76 for (var i = 0; i < 3; ++i) {
90 for (var i = 0; i < 3; ++i) {
77 wait(10);
91 wait(10);
78 physicalKeysMapper.onKeyPressed({ key: Qt.Key_PowerDown, isAutoRepeat: true});
92 physicalKeysMapper.onKeyPressed({ key: Qt.Key_PowerDown, isAutoRepeat: true});