@@ -20,6 +20,7 @@ import Ubuntu.Application 0.1
20import Ubuntu.Components 0.1
20import Ubuntu.Components 0.1
21import Ubuntu.Gestures 0.1
21import Ubuntu.Gestures 0.1
22import LightDM 0.1 as LightDM
22import LightDM 0.1 as LightDM
23import "Dash"
24import "Dash"
24import "Greeter"
25import "Greeter"
25import "Launcher"
26import "Launcher"
@@ -428,9 +429,6 @@ FocusScope {
429 dragHandleWidth: shell.edgeSize
430 dragHandleWidth: shell.edgeSize
431− property var previousMainApp: null
432− property var previousSideApp: null
434 onShownChanged: {
432 onShownChanged: {
435 if (shown) {
433 if (shown) {
436 lockscreen.reset();
434 lockscreen.reset();
@@ -440,20 +438,6 @@ FocusScope {
440 LightDM.Greeter.authenticate(LightDM.Users.data(0, LightDM.UserRoles.NameRole));
438 LightDM.Greeter.authenticate(LightDM.Users.data(0, LightDM.UserRoles.NameRole));
442 greeter.forceActiveFocus();
440 greeter.forceActiveFocus();
443− // FIXME: *FocusedApplication are not updated when unfocused, hence the need to check whether
444− // the stage was actually shown
445− if (mainStage.fullyShown) greeter.previousMainApp = applicationManager.mainStageFocusedApplication;
446− if (sideStage.fullyShown) greeter.previousSideApp = applicationManager.sideStageFocusedApplication;
447− applicationManager.unfocusCurrentApplication();
449− if (greeter.previousMainApp) {
450− applicationManager.focusApplication(greeter.previousMainApp);
451− greeter.previousMainApp = null;
453− if (greeter.previousSideApp) {
454− applicationManager.focusApplication(greeter.previousSideApp);
455− greeter.previousSideApp = null;
@@ -475,6 +459,41 @@ FocusScope {
475 blockInput: greeter.shown || lockscreen.shown
459 blockInput: greeter.shown || lockscreen.shown
466+ property var previousMainApp: null
467+ property var previousSideApp: null
469+ function setFocused(focused) {
471+ // FIXME: *FocusedApplication are not updated when unfocused, hence the need to check whether
472+ // the stage was actually shown
473+ if (mainStage.fullyShown) powerConnection.previousMainApp = applicationManager.mainStageFocusedApplication;
474+ if (sideStage.fullyShown) powerConnection.previousSideApp = applicationManager.sideStageFocusedApplication;
475+ applicationManager.unfocusCurrentApplication();
477+ if (powerConnection.previousMainApp) {
478+ applicationManager.focusApplication(powerConnection.previousMainApp);
479+ powerConnection.previousMainApp = null;
481+ if (powerConnection.previousSideApp) {
482+ applicationManager.focusApplication(powerConnection.previousSideApp);
483+ powerConnection.previousSideApp = null;
488+ onPowerStateChange: {
489+ if (state == 0) { // suspend
490+ powerConnection.setFocused(false);
491+ } else if (state == 1) { // active
492+ powerConnection.setFocused(true);
479 id: overlay
498 id: overlay