@@ -99,17 +99,6 @@ FocusScope {
103− target: applicationManager
104− ignoreUnknownSignals: true
106− // TODO: this should be protected to only unlock for certain applications / certain usecases
107− // potentially only in connection with a notification
109− shell.activateApplication(desktopFile);
113 function activateApplication(desktopFile, argument) {
102 function activateApplication(desktopFile, argument) {
114 if (applicationManager) {
103 if (applicationManager) {
115 // For newly started applications, as it takes them time to draw their first frame
104 // For newly started applications, as it takes them time to draw their first frame
@@ -468,6 +457,26 @@ FocusScope {
469 dragHandleWidth: shell.edgeSize
458 dragHandleWidth: shell.edgeSize
460+ property var previousMainApp: null
461+ property var previousSideApp: null
463+ function removeApplicationFocus() {
464+ greeter.previousMainApp = applicationManager.mainStageFocusedApplication;
465+ greeter.previousSideApp = applicationManager.sideStageFocusedApplication;
466+ applicationManager.unfocusCurrentApplication();
469+ function restoreApplicationFocus() {
470+ if (greeter.previousMainApp) {
471+ applicationManager.focusApplication(greeter.previousMainApp);
472+ greeter.previousMainApp = null;
474+ if (greeter.previousSideApp) {
475+ applicationManager.focusApplication(greeter.previousSideApp);
476+ greeter.previousSideApp = null;
471 onShownChanged: {
480 onShownChanged: {
472 if (shown) {
481 if (shown) {
473 lockscreen.reset();
482 lockscreen.reset();
@@ -478,6 +487,9 @@ FocusScope {
478 greeter.selected(0);
487 greeter.selected(0);
480 greeter.forceActiveFocus();
489 greeter.forceActiveFocus();
490+ removeApplicationFocus();
492+ restoreApplicationFocus();
@@ -494,6 +506,29 @@ FocusScope {
494 launcher.tease();
506 launcher.tease();
511+ target: applicationManager
512+ ignoreUnknownSignals: true
513+ // If any app is focused when greeter is open, it's due to a user action
514+ // like a snap decision (say, an incoming call).
515+ // TODO: these should be protected to only unlock for certain applications / certain usecases
516+ // potentially only in connection with a notification.
517+ onMainStageFocusedApplicationChanged: {
518+ if (greeter.shown && applicationManager.mainStageFocusedApplication) {
519+ greeter.previousMainApp = null // make way for new focused app
520+ greeter.previousSideApp = null
524+ onSideStageFocusedApplicationChanged: {
525+ if (greeter.shown && applicationManager.sideStageFocusedApplication) {
526+ greeter.previousMainApp = null // make way for new focused app
527+ greeter.previousSideApp = null
499 InputFilterArea {
534 InputFilterArea {
@@ -506,34 +541,11 @@ FocusScope {
506 id: powerConnection
541 id: powerConnection
507 target: Powerd
542 target: Powerd
509− property var previousMainApp: null
510− property var previousSideApp: null
512− function setFocused(focused) {
514− powerConnection.previousMainApp = applicationManager.mainStageFocusedApplication;
515− powerConnection.previousSideApp = applicationManager.sideStageFocusedApplication;
516− applicationManager.unfocusCurrentApplication();
518− if (powerConnection.previousMainApp) {
519− applicationManager.focusApplication(powerConnection.previousMainApp);
520− powerConnection.previousMainApp = null;
522− if (powerConnection.previousSideApp) {
523− applicationManager.focusApplication(powerConnection.previousSideApp);
524− powerConnection.previousSideApp = null;
529 onDisplayPowerStateChange: {
544 onDisplayPowerStateChange: {
530 // We ignore any display-off signals when the proximity sensor
545 // We ignore any display-off signals when the proximity sensor
531 // is active. This usually indicates something like a phone call.
546 // is active. This usually indicates something like a phone call.
532 if (status == Powerd.Off && (flags & Powerd.UseProximity) == 0) {
547 if (status == Powerd.Off && (flags & Powerd.UseProximity) == 0) {
533− powerConnection.setFocused(false);
534 greeter.showNow();
548 greeter.showNow();
535− } else if (status == Powerd.On) {
536− powerConnection.setFocused(true);
539 // No reason to chew demo CPU when user isn't watching
551 // No reason to chew demo CPU when user isn't watching