on xenial help sign in
[Stage] Make sure we only use saved states when appropriate
b76b31eMarius Gripsgard
qml/Stage/Stage.qml+20−1
@@ -1021,6 +1021,25 @@ FocusScope {
1021 onWindowReadyChanged: {
1021 onWindowReadyChanged: {
1022 if (windowReady) {
1022 if (windowReady) {
1023 var loadedMirState = WindowStateStorage.toMirState(windowStateSaver.loadedState);
1023 var loadedMirState = WindowStateStorage.toMirState(windowStateSaver.loadedState);
1024+ var state = loadedMirState;
1025+
1026+ if (window.state == Mir.FullscreenState) {
1027+ // If the app is fullscreen at startup, we should not use saved state
1028+ // Example of why: if you open game that only requests fullscreen at
1029+ // Statup, this will automaticly be set to "restored state" since
1030+ // thats the default value of stateStorage, this will result in the app
1031+ // having the "restored state" as it will not make a fullscreen
1032+ // call after the app has started.
1033+ console.log("Inital window state is fullscreen, not using saved state.");
1034+ state = window.state;
1035+ } else if (loadedMirState == Mir.FullscreenState) {
1036+ // If saved state is fullscreen, we should use app inital state
1037+ // Example of why: if you open browser with youtube video at fullscreen
1038+ // and close this app, it will be fullscreen next time you open the app.
1039+ console.log("Saved window state is fullscreen, using inital window state");
1040+ state = window.state;
1041+ }
1042+
1024 // need to apply the shell chrome policy on top the saved window state
1043 // need to apply the shell chrome policy on top the saved window state
1025 var policy;
1044 var policy;
1026 if (root.mode == "windowed") {
1045 if (root.mode == "windowed") {
@@ -1028,7 +1047,7 @@ FocusScope {
1028 } else {
1047 } else {
1029 policy = stagedFullscreenPolicy
1048 policy = stagedFullscreenPolicy
1030 }
1049 }
1031− window.requestState(policy.applyPolicy(loadedMirState, surface.shellChrome));
1050+ window.requestState(policy.applyPolicy(state, surface.shellChrome));
1032 }
1051 }
1033 }
1052 }
1034
1053
tests/mocks/Unity/Application/ApplicationManager.cpp+13
@@ -355,6 +355,19 @@ void ApplicationManager::buildListOfAvailableApplications()
355 application->setRotatesWindowContents(true);
355 application->setRotatesWindowContents(true);
356 m_availableApplications.append(application);
356 m_availableApplications.append(application);
357
357
358+ application = new ApplicationInfo(this);
359+ application->setAppId("camera-app3");
360+ application->setName("Camera3");
361+ application->setScreenshotId("camera");
362+ application->setIconId("camera");
363+ application->setFullscreen(true);
364+ application->setSupportedOrientations(Qt::PortraitOrientation
365+ | Qt::LandscapeOrientation
366+ | Qt::InvertedPortraitOrientation
367+ | Qt::InvertedLandscapeOrientation);
368+ application->setRotatesWindowContents(true);
369+ m_availableApplications.append(application);
370+
358 application = new ApplicationInfo(this);
371 application = new ApplicationInfo(this);
359 application->setAppId("gallery-app");
372 application->setAppId("gallery-app");
360 application->setName("Gallery");
373 application->setName("Gallery");
tests/qmltests/Stage/tst_DesktopStage.qml+18
@@ -1063,5 +1063,23 @@ Item {
1063 verify(surfaceItem);
1063 verify(surfaceItem);
1064 tryCompare(surfaceItem, "activeFocus", true);
1064 tryCompare(surfaceItem, "activeFocus", true);
1065 }
1065 }
1066+
1067+ function test_ignoreSavedStateIfInitalIsFullscreenAndLowChrome() {
1068+ WindowStateStorage.saveState("camera-app", WindowStateStorage.WindowStateNormal);
1069+ var appDelegate = startApplication("camera-app");
1070+ tryCompare(appDelegate, "state", "restored");
1071+ }
1072+
1073+ function test_ignoreSavedStateIfInitalIsFullscreen() {
1074+ WindowStateStorage.saveState("camera-app3", WindowStateStorage.WindowStateNormal);
1075+ var appDelegate = startApplication("camera-app3");
1076+ tryCompare(appDelegate, "state", "fullscreen");
1077+ }
1078+
1079+ function test_ignoreSavedFullscreen() {
1080+ WindowStateStorage.saveState("dialer-app", WindowStateStorage.WindowStateFullscreen);
1081+ var appDelegate = startApplication("dialer-app");
1082+ tryCompare(appDelegate, "state", "normal");
1083+ }
1066 }
1084 }
1067}
1085}