@@ -57,27 +57,20 @@ Item {
5757
5858 property bool altPressed: false
5959 property bool altTabPressed: false
60− }
6160
62− Timer {
63− id: powerKeyLongPressTimer
64− interval: root.powerKeyLongPressTime
65− onTriggered: root.powerKeyLongPressed();
61+ property var powerButtonPressStart: 0
6662 }
6763
68− function onKeyPressed(event) {
69− if ((event.key == Qt.Key_PowerDown || event.key == Qt.Key_PowerOff)
70− && (!event.isAutoRepeat || !powerKeyLongPressTimer.running)) {
71−
72− // FIXME: We only consider power key presses if the screen is
73− // on because of bugs 1410830/1409003. The theory is that when
74− // those bugs are encountered, there is a >2s delay between the
75− // power press event and the power release event, which causes
76− // the shutdown dialog to appear on resume. So to avoid that
77− // symptom while we investigate the root cause, we simply won't
78− // initiate any dialogs when the screen is off.
79− if (Powerd.status === Powerd.On) {
80− powerKeyLongPressTimer.restart();
64+ function onKeyPressed(event, currentEventTimestamp) {
65+ if (event.key == Qt.Key_PowerDown || event.key == Qt.Key_PowerOff) {
66+ if (event.isAutoRepeat) {
67+ if (d.powerButtonPressStart > 0
68+ && currentEventTimestamp - d.powerButtonPressStart >= powerKeyLongPressTime) {
69+ d.powerButtonPressStart = 0;
70+ root.powerKeyLongPressed();
71+ }
72+ } else {
73+ d.powerButtonPressStart = currentEventTimestamp;
8174 }
8275 } else if ((event.key == Qt.Key_MediaTogglePlayPause || event.key == Qt.Key_MediaPlay) && !event.isAutoRepeat) {
8376 event.accepted = callManager.handleMediaKey(false);
@@ -113,9 +106,9 @@ Item {
113106 }
114107 }
115108
116− function onKeyReleased(event) {
109+ function onKeyReleased(event, currentEventTimestamp) {
117110 if (event.key == Qt.Key_PowerDown || event.key == Qt.Key_PowerOff) {
118− powerKeyLongPressTimer.stop();
111+ d.powerButtonPressStart = 0;
119112 event.accepted = true;
120113 } else if (event.key == Qt.Key_VolumeDown) {
121114 if (!d.ignoreVolumeEvents) root.volumeDownTriggered();