@@ -19,6 +19,7 @@ import Ubuntu.Application 0.1
19import Ubuntu.Components 0.1
19import Ubuntu.Components 0.1
20import Ubuntu.Gestures 0.1
20import Ubuntu.Gestures 0.1
21import LightDM 0.1 as LightDM
21import LightDM 0.1 as LightDM
22import "Dash"
23import "Dash"
23import "Greeter"
24import "Greeter"
24import "Launcher"
25import "Launcher"
@@ -420,9 +421,6 @@ FocusScope {
421 dragHandleWidth: shell.edgeSize
422 dragHandleWidth: shell.edgeSize
423− property var previousMainApp: null
424− property var previousSideApp: null
426 onShownChanged: {
424 onShownChanged: {
427 if (shown) {
425 if (shown) {
428 lockscreen.reset();
426 lockscreen.reset();
@@ -432,20 +430,6 @@ FocusScope {
432 LightDM.Greeter.authenticate(LightDM.Users.data(0, LightDM.UserRoles.NameRole));
430 LightDM.Greeter.authenticate(LightDM.Users.data(0, LightDM.UserRoles.NameRole));
434 greeter.forceActiveFocus();
432 greeter.forceActiveFocus();
435− // FIXME: *FocusedApplication are not updated when unfocused, hence the need to check whether
436− // the stage was actually shown
437− if (mainStage.fullyShown) greeter.previousMainApp = applicationManager.mainStageFocusedApplication;
438− if (sideStage.fullyShown) greeter.previousSideApp = applicationManager.sideStageFocusedApplication;
439− applicationManager.unfocusCurrentApplication();
441− if (greeter.previousMainApp) {
442− applicationManager.focusApplication(greeter.previousMainApp);
443− greeter.previousMainApp = null;
445− if (greeter.previousSideApp) {
446− applicationManager.focusApplication(greeter.previousSideApp);
447− greeter.previousSideApp = null;
@@ -467,6 +451,41 @@ FocusScope {
467 blockInput: greeter.shown || lockscreen.shown
451 blockInput: greeter.shown || lockscreen.shown
458+ property var previousMainApp: null
459+ property var previousSideApp: null
461+ function setFocused(focused) {
463+ // FIXME: *FocusedApplication are not updated when unfocused, hence the need to check whether
464+ // the stage was actually shown
465+ if (mainStage.fullyShown) powerConnection.previousMainApp = applicationManager.mainStageFocusedApplication;
466+ if (sideStage.fullyShown) powerConnection.previousSideApp = applicationManager.sideStageFocusedApplication;
467+ applicationManager.unfocusCurrentApplication();
469+ if (powerConnection.previousMainApp) {
470+ applicationManager.focusApplication(powerConnection.previousMainApp);
471+ powerConnection.previousMainApp = null;
473+ if (powerConnection.previousSideApp) {
474+ applicationManager.focusApplication(powerConnection.previousSideApp);
475+ powerConnection.previousSideApp = null;
480+ onPowerStateChange: {
481+ if (state == 0) { // suspend
482+ powerConnection.setFocused(false);
483+ } else if (state == 1) { // active
484+ powerConnection.setFocused(true);
471 id: overlay
490 id: overlay