on xenial help sign in
Add Showable.showNow() method and use it in Shell to immediately show greeter when we blank the screen rather than animating it. Fixes: https://bugs.launchpad.net/bugs/1233564.
64e5148Michael Terry
Components/Showable.qml+11
@@ -30,6 +30,7 @@ Item {
30 property bool created: true
30 property bool created: true
31 property bool required
31 property bool required
32 property bool __shouldShow: false
32 property bool __shouldShow: false
33+ property bool __skipShowAnimation: false
33
34
34 property list<QtObject> hides
35 property list<QtObject> hides
35 property var showAnimation
36 property var showAnimation
@@ -58,6 +59,11 @@ Item {
58 }
59 }
59 }
60 }
60
61
62+ function showNow() {
63+ __skipShowAnimation = true;
64+ show();
65+ }
66+
61 onCreatedChanged: {
67 onCreatedChanged: {
62 if (created && __shouldShow) {
68 if (created && __shouldShow) {
63 __reallyShow();
69 __reallyShow();
@@ -67,6 +73,7 @@ Item {
67
73
68 function __reallyShow() {
74 function __reallyShow() {
69 if (!available) {
75 if (!available) {
76+ __skipShowAnimation = false;
70 return false;
77 return false;
71 }
78 }
72
79
@@ -80,11 +87,15 @@ Item {
80 if (!showAnimation.running) {
87 if (!showAnimation.running) {
81 showAnimation.restart()
88 showAnimation.restart()
82 }
89 }
90+ if (__skipShowAnimation) {
91+ showAnimation.complete();
92+ }
83 } else {
93 } else {
84 visible = true;
94 visible = true;
85 }
95 }
86
96
87 shown = true;
97 shown = true;
98+ __skipShowAnimation = false;
88 return true;
99 return true;
89 }
100 }
90
101
Shell.qml+1−1
@@ -535,7 +535,7 @@ FocusScope {
535 // is active. This usually indicates something like a phone call.
535 // is active. This usually indicates something like a phone call.
536 if (status == Powerd.Off && (flags & Powerd.UseProximity) == 0) {
536 if (status == Powerd.Off && (flags & Powerd.UseProximity) == 0) {
537 powerConnection.setFocused(false);
537 powerConnection.setFocused(false);
538− greeter.show();
538+ greeter.showNow();
539 } else if (status == Powerd.On) {
539 } else if (status == Powerd.On) {
540 powerConnection.setFocused(true);
540 powerConnection.setFocused(true);
541 }
541 }
tests/qmltests/Components/tst_Showable.qml+27
@@ -155,5 +155,32 @@ Item {
155 show1.created = true;
155 show1.created = true;
156 compare(show1.shown, true, "Showable should automatically show when created changes to true if attempted to show before.");
156 compare(show1.shown, true, "Showable should automatically show when created changes to true if attempted to show before.");
157 }
157 }
158+
159+ // Test that showNow immediately shows showable
160+ function test_showNow() {
161+ init_test();
162+
163+ show1.opacity = 0.2;
164+
165+ show1.showNow();
166+ compare(show1.shown, true, "Showable should be shown after showNow");
167+ compare(show1.showAnimation.running, false, "Showable should be done running after showNow");
168+ compare(show1.opacity, 1.0, "Showable should be at end of animation after showNow");
169+ }
170+
171+ // Test the lazy showNow mechanism while waiting for the created flag.
172+ function test_showNow_when_not_created() {
173+ init_test();
174+
175+ show1.opacity = 0.2;
176+ show1.created = false;
177+
178+ show1.showNow();
179+ compare(show1.shown, false, "Showable should not showNow when created == false");
180+ show1.created = true;
181+ compare(show1.shown, true, "Showable should automatically show when created changes to true if attempted to showNow before.");
182+ compare(show1.showAnimation.running, false, "Showable should be done running after delayed showNow");
183+ compare(show1.opacity, 1.0, "Showable should be at end of animation after delayed showNow");
184+ }
158 }
185 }
159}
186}