on xenial help sign in
Don't block handling power events on loading the greeter's qml and the background image.

During power button press, we call greeter.showNow(), which was taking so long to return that we couldn't handle the power button release for a few seconds. Which meant that the shutdown dialog thought it would be a good time to appear. The easiest fix is to delay calling showNow until after we finish handling the event. Fixes: #1383277 Approved by: Daniel d'Andrada, PS Jenkins bot

commita4804287e8404bedf11b8a065280f73217aedd33 authorMichael Terry <michael.terry@canonical.com> dateFri 9 Jan 2015, 10:41 (12 years ago) parent20b705f1bcaf72
2 files changed+29−9
qml/Greeter/Infographics.qml+9−7 qml/Shell.qml+20−2
qml/Greeter/Infographics.qml+9−7
@@ -127,7 +127,7 @@ Item {
127127
128128 index: model.index
129129 count: pastCircles.count
130− radius: parent.width / 2
130+ radius: dataCircle.width / 2
131131 halfSize: pastCircle.width / 2
132132 posOffset: 0.0
133133
@@ -187,7 +187,7 @@ Item {
187187
188188 index: model.index
189189 count: presentCircles.count
190− radius: parent.width / 2
190+ radius: dataCircle.width / 2
191191 halfSize: presentCircle.width / 2
192192 posOffset: 0.0
193193
@@ -255,14 +255,16 @@ Item {
255255 interval: animDuration * 0.5; running: false; repeat: true
256256 onTriggered: {
257257 if (dotCounter < dots.count) {
258− var nextDot = dots.itemAt(dotCounter++)
259− nextDot.unlockAnimation.start()
258+ var nextDot = dots.itemAt(dotCounter);
259+ if (nextDot) {
260+ nextDot.unlockAnimation.start();
261+ if (++dotCounter == Math.round(dots.count / 2)) {
262+ circleChangeAnimTimer.startFromBeginning();
263+ }
264+ }
260265 } else {
261266 stop()
262267 }
263− if (dotCounter == Math.round(dots.count / 2)) {
264− circleChangeAnimTimer.startFromBeginning()
265− }
266268 }
267269
268270 function startFromBeginning() {
qml/Shell.qml+20−2
@@ -400,7 +400,7 @@ Item {
400400
401401 function maybeShow() {
402402 if (!shell.forcedUnlock) {
403− show()
403+ showNow();
404404 }
405405 }
406406
@@ -594,6 +594,15 @@ Item {
594594 enabled = true;
595595 }
596596
597+ Timer {
598+ // See powerConnection for why this is useful
599+ id: showGreeterDelayed
600+ interval: 1
601+ onTriggered: {
602+ greeter.showNow();
603+ }
604+ }
605+
597606 onShownChanged: {
598607 if (shown) {
599608 // Disable everything so that user can't swipe greeter or
@@ -664,7 +673,16 @@ Item {
664673 onStatusChanged: {
665674 if (Powerd.status === Powerd.Off && reason !== Powerd.Proximity &&
666675 !callManager.hasCalls && !edgeDemo.running) {
667− greeter.showNow()
676+ // We don't want to simply call greeter.showNow() here, because
677+ // that will take too long. Qt will delay button event
678+ // handling until the greeter is done loading and may think the
679+ // user held down the power button the whole time, leading to a
680+ // power dialog being shown. Instead, delay showing the
681+ // greeter until we've finished handling the event. We could
682+ // make the greeter load asynchronously instead, but that
683+ // introduces a whole host of timing issues, especially with
684+ // its animations. So this is simpler.
685+ showGreeterDelayed.start();
668686 }
669687 }
670688 }