on xenial help sign in
w/o timer
commit01bfeff0dd8964bb5fea0c361d459349c7fb43ef authorLukáš Tinkl <lukas.tinkl@canonical.com> dateFri 24 Feb 2017, 05:26 (10 years ago) parentef236c5
4 files changed+19−38
qml/Stage/ApplicationWindow.qml+1 qml/Stage/Stage.qml+14−30 qml/Stage/StagedFullscreenPolicy.qml+4−6 qml/Stage/WindowedFullscreenPolicy.qml−2
qml/Stage/ApplicationWindow.qml+1
@@ -28,6 +28,7 @@ FocusScope {
2828 property bool orientationChangesEnabled: d.supportsSurfaceResize ? d.surfaceOldEnoughToBeResized : true
2929 readonly property string title: surface && surface.name !== "" ? surface.name : d.name
3030 readonly property QtObject focusedSurface: d.focusedSurface.surface
31+ readonly property alias surfaceInitialized: d.surfaceInitialized
3132
3233 // to be set from outside
3334 property QtObject surface
qml/Stage/Stage.qml+14−30
@@ -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 {
qml/Stage/StagedFullscreenPolicy.qml+4−6
@@ -28,13 +28,11 @@ import Unity.Application 0.1
2828QtObject {
2929 property bool active: true
3030
31− signal stateRequested(int requestedState)
32−
3331 property var surface: null
3432 onSurfaceChanged: {
3533 if (!active || !surface) return;
3634 if (surface.shellChrome === Mir.LowChrome) {
37− stateRequested(Mir.FullscreenState);
35+ surface.requestState(Mir.FullscreenState);
3836 }
3937 }
4038
@@ -43,15 +41,15 @@ QtObject {
4341 onShellChromeChanged: {
4442 if (!active || !surface) return;
4543 if (surface.shellChrome === Mir.LowChrome) {
46− stateRequested(Mir.FullscreenState);
44+ urface.requestState(Mir.FullscreenState);
4745 } else {
48− stateRequested(Mir.RestoredState);
46+ surface.requestState(Mir.RestoredState);
4947 }
5048 }
5149 onStateChanged: {
5250 if (!active || !surface) return;
5351 if (surface.state === Mir.RestoredState && surface.shellChrome === Mir.LowChrome) {
54− stateRequested(Mir.FullscreenState);
52+ surface.requestState(Mir.FullscreenState);
5553 }
5654 }
5755 }
qml/Stage/WindowedFullscreenPolicy.qml−2
@@ -22,8 +22,6 @@ import Unity.Application 0.1
2222// On first surface load; if the surface is set to low chrome & fullscreen, the
2323// state of the window is returned to restored.
2424QtObject {
25− property bool active: true
26−
2725 function applyPolicy(surfaceState, surfaceChrome) {
2826 if (surfaceState === Mir.FullscreenState && surfaceChrome === Mir.LowChrome) {
2927 return Mir.RestoredState;