@@ -946,19 +946,20 @@ FocusScope {
946946 }
947947 }
948948
949− // queue the requests to change the window/surface state
950− Timer {
951− id: delayedStateTimer
952− property int windowState: -1 // Mir::State
953− interval: 1000
954− onTriggered: {
955− if (delayedStateTimer.windowState != -1) {
956− if (windowedFullscreenPolicy.active) { // need to apply the windowed shell chrome policy on top the saved window state
957− delayedStateTimer.windowState = windowedFullscreenPolicy.applyPolicy(delayedStateTimer.windowState, appDelegate.surface.shellChrome);
958− }
959− appDelegate.window.requestState(delayedStateTimer.windowState);
960− delayedStateTimer.windowState = -1;
949+ readonly property bool windowReady: clientAreaItem.surfaceInitialized
950+ onWindowReadyChanged: {
951+ if (windowReady) {
952+ // First, cascade the newly created window, relative to the currently/old focused window.
953+ windowedX = priv.focusedAppDelegate ? priv.focusedAppDelegate.windowedX + units.gu(3) : (normalZ - 1) * units.gu(3)
954+ windowedY = priv.focusedAppDelegate ? priv.focusedAppDelegate.windowedY + units.gu(3) : normalZ * units.gu(3)
955+
956+ // Now load any saved state. This needs to happen *after* the cascading!
957+ var ws = WindowStateStorage.toMirState(windowStateSaver.load());
958+ if (root.mode == "windowed") {
959+ // need to apply the windowed shell chrome policy on top the saved window state
960+ ws = windowedFullscreenPolicy.applyPolicy(ws, surface.shellChrome);
961961 }
962+ window.requestState(ws);
962963 }
963964 }
964965
@@ -969,19 +970,6 @@ FocusScope {
969970 decoratedWindow.surfaceOrientationAngle = 0;
970971 }
971972
972− // First, cascade the newly created window, relative to the currently/old focused window.
973− windowedX = priv.focusedAppDelegate ? priv.focusedAppDelegate.windowedX + units.gu(3) : (normalZ - 1) * units.gu(3)
974− windowedY = priv.focusedAppDelegate ? priv.focusedAppDelegate.windowedY + units.gu(3) : normalZ * units.gu(3)
975−
976− if (root.mode == "windowed") {
977− // Now load any saved state. This needs to happen *after* the cascading!
978− delayedStateTimer.windowState = WindowStateStorage.toMirState(windowStateSaver.load());
979− delayedStateTimer.restart();
980− } else {
981− // just load and init the windowedX/Y/Width/Height values
982− windowStateSaver.load();
983− }
984−
985973 updateQmlFocusFromMirSurfaceFocus();
986974
987975 refreshStage();
@@ -1015,6 +1003,7 @@ FocusScope {
10151003 !visuallyMinimized
10161004 && !greeter.fullyShown
10171005 && (priv.foregroundMaximizedAppDelegate === null || priv.foregroundMaximizedAppDelegate.normalZ <= z)
1006+ //&& windowReady
10181007 )
10191008 || appDelegate.fullscreen
10201009 || focusAnimation.running || rightEdgeFocusAnimation.running || hidingAnimation.running
@@ -1683,16 +1672,11 @@ FocusScope {
16831672
16841673 WindowedFullscreenPolicy {
16851674 id: windowedFullscreenPolicy
1686− active: root.mode == "windowed"
16871675 }
16881676 StagedFullscreenPolicy {
16891677 id: stagedFullscreenPolicy
16901678 active: root.mode == "staged" || root.mode == "stagedWithSideStage"
16911679 surface: model.window.surface
1692− onStateRequested: {
1693− delayedStateTimer.windowState = requestedState;
1694− delayedStateTimer.restart();
1695− }
16961680 }
16971681
16981682 SpreadDelegateInputArea {