on xenial help sign in
Make tablet greeter work correctly when apps request focus and have it reset itself every show
42b94b6Michael Terry
qml/Greeter/Greeter.qml+12
@@ -57,6 +57,18 @@ Showable {
57 }
57 }
58 }
58 }
59
59
60+ function tryToUnlock() {
61+ if (created) {
62+ greeterContentLoader.item.tryToUnlock()
63+ }
64+ }
65+
66+ function reset() {
67+ if (created) {
68+ greeterContentLoader.item.reset()
69+ }
70+ }
71+
60 onRequiredChanged: {
72 onRequiredChanged: {
61 // Reset hide animation to default once we're finished with it
73 // Reset hide animation to default once we're finished with it
62 if (required) {
74 if (required) {
qml/Greeter/GreeterContent.qml+12
@@ -29,6 +29,18 @@ Item {
29 signal selected(int uid)
29 signal selected(int uid)
30 signal unlocked(int uid)
30 signal unlocked(int uid)
31
31
32+ function tryToUnlock() {
33+ if (loginLoader.item) {
34+ loginLoader.item.tryToUnlock()
35+ }
36+ }
37+
38+ function reset() {
39+ if (loginLoader.item) {
40+ loginLoader.item.reset()
41+ }
42+ }
43+
32 Rectangle {
44 Rectangle {
33 // In case background fails to load
45 // In case background fails to load
34 id: backgroundBackup
46 id: backgroundBackup
qml/Greeter/LoginList.qml+17−6
@@ -35,6 +35,22 @@ Item {
35 signal selected(int uid)
35 signal selected(int uid)
36 signal unlocked(int uid)
36 signal unlocked(int uid)
37
37
38+ function tryToUnlock() {
39+ if (LightDM.Greeter.promptless) {
40+ if (LightDM.Greeter.authenticated) {
41+ root.unlocked(userList.currentIndex)
42+ } else {
43+ root.resetAuthentication()
44+ }
45+ } else {
46+ passwordInput.forceActiveFocus()
47+ }
48+ }
49+
50+ function reset() {
51+ root.resetAuthentication()
52+ }
53+
38 Keys.onEscapePressed: root.resetAuthentication()
54 Keys.onEscapePressed: root.resetAuthentication()
39
55
40 Rectangle {
56 Rectangle {
@@ -231,12 +247,7 @@ Item {
231 MouseArea {
247 MouseArea {
232 anchors.fill: passwordInput
248 anchors.fill: passwordInput
233 enabled: LightDM.Greeter.promptless
249 enabled: LightDM.Greeter.promptless
234− onClicked: {
250+ onClicked: root.tryToUnlock()
235− if (LightDM.Greeter.authenticated)
236− root.unlocked(userList.currentIndex);
237− else
238− root.resetAuthentication();
239− }
240 }
251 }
241
252
242 function resetAuthentication() {
253 function resetAuthentication() {
qml/Launcher/Launcher.qml+1−2
@@ -243,10 +243,9 @@ Item {
243 onDraggingChanged: {
243 onDraggingChanged: {
244 if (!dragging) {
244 if (!dragging) {
245 if (distance > panel.width / 2) {
245 if (distance > panel.width / 2) {
246+ root.switchToNextState("visible")
246 if (distance > minimizeDistance) {
247 if (distance > minimizeDistance) {
247 root.dash();
248 root.dash();
248− } else {
249− root.switchToNextState("visible")
250 }
249 }
251 } else {
250 } else {
252 root.switchToNextState("")
251 root.switchToNextState("")
qml/Shell.qml+41−22
@@ -139,29 +139,35 @@ Item {
139 Connections {
139 Connections {
140 target: ApplicationManager
140 target: ApplicationManager
141 onFocusRequested: {
141 onFocusRequested: {
142+ if (greeter.narrowMode) {
142− if (appId === "dialer-app") {
143+ if (appId === "dialer-app") {
143− // Always let the dialer-app through. Either user asked
144+ // Always let the dialer-app through. Either user asked
144− // for an emergency call or accepted an incoming call.
145+ // for an emergency call or accepted an incoming call.
145− setLockedApp(appId)
146+ setLockedApp(appId)
146− } else if (greeter.hasLockedApp && greeter.lockedApp !== appId) {
147+ } else if (greeter.hasLockedApp && greeter.lockedApp !== appId) {
147− lockscreen.show();
148+ greeter.startUnlock()
149+ }
150+ greeter.hide();
151+ launcher.hide();
152+ } else {
153+ if (LightDM.Greeter.active) {
154+ greeter.startUnlock()
155+ }
148 }
156 }
149− greeter.hide();
150− launcher.hide();
151 }
157 }
152
158
153 onFocusedApplicationIdChanged: {
159 onFocusedApplicationIdChanged: {
154 if (greeter.hasLockedApp && greeter.lockedApp !== ApplicationManager.focusedApplicationId) {
160 if (greeter.hasLockedApp && greeter.lockedApp !== ApplicationManager.focusedApplicationId) {
155− lockscreen.show();
161+ greeter.startUnlock()
156 }
162 }
157 panel.indicators.hide();
163 panel.indicators.hide();
158 }
164 }
159
165
160 onApplicationAdded: {
166 onApplicationAdded: {
161 if (greeter.shown && appId != "unity8-dash") {
167 if (greeter.shown && appId != "unity8-dash") {
162− greeter.hide();
168+ greeter.startUnlock()
163 }
169 }
164− if (appId === "dialer-app") {
170+ if (greeter.narrowMode && appId === "dialer-app") {
165 // Always let the dialer-app through. Either user asked
171 // Always let the dialer-app through. Either user asked
166 // for an emergency call or accepted an incoming call.
172 // for an emergency call or accepted an incoming call.
167 setLockedApp(appId)
173 setLockedApp(appId)
@@ -306,11 +312,13 @@ Item {
306 }
312 }
307
313
308 onPromptlessChanged: {
314 onPromptlessChanged: {
315+ if (greeter.narrowMode) {
309− if (LightDM.Greeter.promptless && LightDM.Greeter.authenticated) {
316+ if (LightDM.Greeter.promptless && LightDM.Greeter.authenticated) {
310− lockscreen.hide()
317+ lockscreen.hide()
311− } else {
318+ } else {
312− lockscreen.reset();
319+ lockscreen.reset();
313− lockscreen.show();
320+ lockscreen.show();
321+ }
314 }
322 }
315 }
323 }
316
324
@@ -384,7 +392,7 @@ Item {
384 property bool fullyShown: showProgress === 1.0
392 property bool fullyShown: showProgress === 1.0
385 onFullyShownChanged: {
393 onFullyShownChanged: {
386 // Wait until the greeter is completely covering lockscreen before resetting it.
394 // Wait until the greeter is completely covering lockscreen before resetting it.
387− if (fullyShown && !LightDM.Greeter.authenticated) {
395+ if (greeter.narrowMode && fullyShown && !LightDM.Greeter.authenticated) {
388 lockscreen.reset();
396 lockscreen.reset();
389 lockscreen.show();
397 lockscreen.show();
390 }
398 }
@@ -414,6 +422,18 @@ Item {
414
422
415 dragHandleWidth: shell.edgeSize
423 dragHandleWidth: shell.edgeSize
416
424
425+ function startUnlock() {
426+ if (narrowMode) {
427+ if (!LightDM.Greeter.authenticated) {
428+ lockscreen.show()
429+ }
430+ hide()
431+ } else {
432+ show()
433+ tryToUnlock()
434+ }
435+ }
436+
417 function login() {
437 function login() {
418 enabled = false;
438 enabled = false;
419 if (LightDM.Greeter.startSessionSync()) {
439 if (LightDM.Greeter.startSessionSync()) {
@@ -429,6 +449,8 @@ Item {
429 if (shown) {
449 if (shown) {
430 if (greeter.narrowMode) {
450 if (greeter.narrowMode) {
431 LightDM.Greeter.authenticate(LightDM.Users.data(0, LightDM.UserRoles.NameRole));
451 LightDM.Greeter.authenticate(LightDM.Users.data(0, LightDM.UserRoles.NameRole));
452+ } else {
453+ reset()
432 }
454 }
433 greeter.lockedApp = "";
455 greeter.lockedApp = "";
434 greeter.forceActiveFocus();
456 greeter.forceActiveFocus();
@@ -475,10 +497,7 @@ Item {
475 }
497 }
476
498
477 if (LightDM.Greeter.active) {
499 if (LightDM.Greeter.active) {
478− if (!LightDM.Greeter.authenticated) {
479− lockscreen.show()
480− }
481− greeter.hide()
500+ greeter.startUnlock()
482 }
501 }
483
502
484 var animate = !LightDM.Greeter.active && !stages.shown
503 var animate = !LightDM.Greeter.active && !stages.shown
@@ -546,7 +565,7 @@ Item {
546 }
565 }
547 onLauncherApplicationSelected: {
566 onLauncherApplicationSelected: {
548 if (greeter.hasLockedApp) {
567 if (greeter.hasLockedApp) {
549− lockscreen.show()
568+ greeter.startUnlock()
550 }
569 }
551 if (!edgeDemo.running)
570 if (!edgeDemo.running)
552 shell.activateApplication(appId)
571 shell.activateApplication(appId)