on xenial help sign in
merge lp:~lukas-kde/unity8/fix-shell-chrome
commit861db81eabba3d71f7af7b97cfaaf3cd25370146 authorDaniel d'Andrada <daniel.dandrada@canonical.com> dateFri 24 Feb 2017, 09:31 (10 years ago) parent6f314eace04531
8 files changed+52−57
qml/Stage/ApplicationWindow.qml+2 qml/Stage/Stage.qml+24−13 qml/Stage/StagedFullscreenPolicy.qml+5−11 qml/Stage/WindowStateSaver.qml+2−3 qml/Stage/WindowedFullscreenPolicy.qml+4−12 tests/qmltests/Stage/tst_DesktopStage.qml+2−2 tests/qmltests/tst_OrientedShell.qml+5−3 tests/qmltests/tst_Shell.qml+8−13
qml/Stage/ApplicationWindow.qml+2
@@ -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
@@ -124,6 +125,7 @@ FocusScope {
124125 target: root.application
125126 property: "initialSurfaceSize"
126127 value: Qt.size(root.requestedWidth, root.requestedHeight)
128+ when: d.surfaceInitialized
127129 }
128130
129131 Timer {
qml/Stage/Stage.qml+24−13
@@ -470,7 +470,7 @@ FocusScope {
470470 extend: "stagedRightEdge"
471471 PropertyChanges {
472472 target: sideStage
473− opacity: priv.sideStageDelegate.x === sideStage.x ? 1 : 0
473+ opacity: priv.sideStageDelegate && priv.sideStageDelegate.x === sideStage.x ? 1 : 0
474474 visible: true
475475 }
476476 },
@@ -723,6 +723,7 @@ FocusScope {
723723 // miral doesn't know about our window decorations. So we have to deduct them
724724 value: Qt.point(appDelegate.requestedX + appDelegate.clientAreaItem.x,
725725 appDelegate.requestedY + appDelegate.clientAreaItem.y)
726+ when: root.mode == "windowed"
726727 }
727728
728729 // In those are for windowed mode. Those values basically store the window's properties
@@ -768,7 +769,6 @@ FocusScope {
768769 Math.max(0, priv.virtualKeyboardHeight - (appContainer.height - (appDelegate.requestedY + appDelegate.height))))
769770 when: root.oskEnabled && appDelegate.focus && (appDelegate.state == "normal" || appDelegate.state == "restored")
770771 && root.inputMethodRect.height > 0
771−
772772 }
773773
774774 Behavior on x { id: xBehavior; enabled: priv.closingIndex >= 0; UbuntuNumberAnimation { onRunningChanged: if (!running) priv.closingIndex = -1} }
@@ -933,7 +933,8 @@ FocusScope {
933933 } else if (model.window.state === Mir.MaximizedBottomRightState) {
934934 appDelegate.maximizeBottomRight();
935935 } else if (model.window.state === Mir.RestoredState) {
936− if (appDelegate.fullscreen && appDelegate.prevWindowState != WindowStateStorage.WindowStateRestored) {
936+ if (appDelegate.fullscreen && appDelegate.prevWindowState != WindowStateStorage.WindowStateRestored
937+ && appDelegate.prevWindowState != WindowStateStorage.WindowStateNormal) {
937938 model.window.requestState(WindowStateStorage.toMirState(appDelegate.prevWindowState));
938939 } else {
939940 appDelegate.restore();
@@ -945,6 +946,20 @@ FocusScope {
945946 }
946947 }
947948
949+ readonly property bool windowReady: clientAreaItem.surfaceInitialized
950+ property int requestedWindowState: Mir.RestoredState
951+ onWindowReadyChanged: {
952+ if (windowReady) {
953+ // need to apply the shell chrome policy on top the saved window state
954+ if (root.mode == "windowed") {
955+ requestedWindowState = windowedFullscreenPolicy.applyPolicy(requestedWindowState, surface.shellChrome);
956+ } else {
957+ requestedWindowState = stagedFullscreenPolicy.applyPolicy(requestedWindowState, surface.shellChrome);
958+ }
959+ window.requestState(requestedWindowState);
960+ }
961+ }
962+
948963 Component.onCompleted: {
949964 if (application && application.rotatesWindowContents) {
950965 decoratedWindow.surfaceOrientationAngle = shellOrientationAngle;
@@ -956,8 +971,7 @@ FocusScope {
956971 windowedX = priv.focusedAppDelegate ? priv.focusedAppDelegate.windowedX + units.gu(3) : (normalZ - 1) * units.gu(3)
957972 windowedY = priv.focusedAppDelegate ? priv.focusedAppDelegate.windowedY + units.gu(3) : normalZ * units.gu(3)
958973 // Now load any saved state. This needs to happen *after* the cascading!
959− windowStateSaver.load();
960− model.window.requestState(WindowStateStorage.toMirState(windowState));
974+ requestedWindowState = WindowStateStorage.toMirState(windowStateSaver.load());
961975
962976 updateQmlFocusFromMirSurfaceFocus();
963977
@@ -965,7 +979,9 @@ FocusScope {
965979 _constructing = false;
966980 }
967981 Component.onDestruction: {
968− windowStateSaver.save();
982+ if (root.mode == "windowed") {
983+ windowStateSaver.save();
984+ }
969985
970986 if (!root.parent) {
971987 // This stage is about to be destroyed. Don't mess up with the model at this point
@@ -1441,7 +1457,7 @@ FocusScope {
14411457 ]
14421458 transitions: [
14431459 Transition {
1444− from: "staged,stagedWithSideStage"; to: "normal"
1460+ from: "staged,stagedWithSideStage"
14451461 enabled: appDelegate.animationsEnabled
14461462 PropertyAction { target: appDelegate; properties: "visuallyMinimized,visuallyMaximized" }
14471463 UbuntuNumberAnimation { target: appDelegate; properties: "x,y,requestedX,requestedY,opacity,requestedWidth,requestedHeight,scale"; duration: priv.animationDuration }
@@ -1462,8 +1478,7 @@ FocusScope {
14621478 },
14631479 Transition {
14641480 from: "normal,staged"; to: "stagedWithSideStage"
1465− UbuntuNumberAnimation { target: appDelegate; properties: "x,y"; duration: priv.animationDuration }
1466− UbuntuNumberAnimation { target: appDelegate; properties: "requestedWidth,requestedHeight"; duration: priv.animationDuration }
1481+ UbuntuNumberAnimation { target: appDelegate; properties: "x,y,requestedWidth,requestedHeight"; duration: priv.animationDuration }
14671482 },
14681483 Transition {
14691484 to: "windowedRightEdge"
@@ -1503,7 +1518,6 @@ FocusScope {
15031518 from: ",normal,restored,maximized,maximizedLeft,maximizedRight,maximizedTopLeft,maximizedTopRight,maximizedBottomLeft,maximizedBottomRight,maximizedHorizontally,maximizedVertically,fullscreen"
15041519 to: "minimized"
15051520 SequentialAnimation {
1506− ScriptAction { script: print("transitioning:", appDelegate.x, appDelegate.y, appDelegate.scale) }
15071521 ScriptAction { script: { fakeRectangle.stop(); } }
15081522 PropertyAction { target: appDelegate; property: "visuallyMaximized" }
15091523 UbuntuNumberAnimation { target: appDelegate; properties: "x,y,scale,opacity"; duration: priv.animationDuration }
@@ -1514,7 +1528,6 @@ FocusScope {
15141528 from: "minimized"
15151529 to: ",normal,restored,maximized,maximizedLeft,maximizedRight,maximizedTopLeft,maximizedTopRight,maximizedBottomLeft,maximizedBottomRight,maximizedHorizontally,maximizedVertically,fullscreen"
15161530 SequentialAnimation {
1517− ScriptAction { script: print("transitioning:", appDelegate.x, appDelegate.y, appDelegate.scale) }
15181531 PropertyAction { target: appDelegate; property: "visuallyMinimized,z" }
15191532 ParallelAnimation {
15201533 UbuntuNumberAnimation { target: appDelegate; properties: "x"; from: -appDelegate.width / 2; duration: priv.animationDuration }
@@ -1661,8 +1674,6 @@ FocusScope {
16611674
16621675 WindowedFullscreenPolicy {
16631676 id: windowedFullscreenPolicy
1664− active: root.mode == "windowed"
1665− surface: model.window.surface
16661677 }
16671678 StagedFullscreenPolicy {
16681679 id: stagedFullscreenPolicy
qml/Stage/StagedFullscreenPolicy.qml+5−11
@@ -28,14 +28,14 @@ import Unity.Application 0.1
2828QtObject {
2929 property bool active: true
3030
31− property var surface: null
32− onSurfaceChanged: {
33− if (!active || !surface) return;
34− if (surface.shellChrome === Mir.LowChrome) {
35− surface.requestState(Mir.FullscreenState);
31+ function applyPolicy(surfaceState, surfaceChrome) {
32+ if (surfaceChrome === Mir.LowChrome) {
33+ return Mir.FullscreenState;
3634 }
35+ return surfaceState;
3736 }
3837
38+ property var surface: null
3939 property var _connections: Connections {
4040 target: surface
4141 onShellChromeChanged: {
@@ -46,11 +46,5 @@ QtObject {
4646 surface.requestState(Mir.RestoredState);
4747 }
4848 }
49− onStateChanged: {
50− if (!active) return;
51− if (surface.state === Mir.RestoredState && surface.shellChrome === Mir.LowChrome) {
52− surface.requestState(Mir.FullscreenState);
53− }
54− }
5549 }
5650}
qml/Stage/WindowStateSaver.qml+2−3
@@ -41,14 +41,13 @@ QtObject {
4141 (target.fullscreen ? 0 : root.leftMargin)); });
4242 target.windowedY = Qt.binding(function() { return Math.max(Math.min(windowGeometry.y, screenHeight - target.windowedHeight), minimumY); });
4343
44− var windowState = WindowStateStorage.getState(target.appId, WindowStateStorage.WindowStateNormal)
45− target.restore(false /* animated */, windowState);
46−
4744 target.updateNormalGeometry();
4845
4946 // initialize the x/y to restore to
5047 target.restoredX = target.normalX;
5148 target.restoredY = target.normalY;
49+
50+ return WindowStateStorage.getState(target.appId, WindowStateStorage.WindowStateNormal);
5251 }
5352
5453 function save() {
qml/Stage/WindowedFullscreenPolicy.qml+4−12
@@ -22,18 +22,10 @@ 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− property QtObject surface: null
27−
28− property bool _firstTimeSurface: true
29−
30− onSurfaceChanged: {
31− if (!active || !surface) return;
32− if (!_firstTimeSurface) return;
33− _firstTimeSurface = false;
34−
35− if (surface.state === Mir.FullscreenState && surface.shellChrome === Mir.LowChrome) {
36− surface.requestState(Mir.RestoredState);
25+ function applyPolicy(surfaceState, surfaceChrome) {
26+ if (surfaceState === Mir.FullscreenState && surfaceChrome === Mir.LowChrome) {
27+ return Mir.RestoredState;
3728 }
29+ return surfaceState;
3830 }
3931}
tests/qmltests/Stage/tst_DesktopStage.qml+2−2
@@ -321,7 +321,7 @@ Item {
321321 var maximizeButton = findChild(appDelegate, "maximizeWindowButton");
322322 verify(maximizeButton);
323323 mouseClick(maximizeButton);
324− tryCompare(appDelegate, "visuallyMaximized", true);
324+ tryCompare(appDelegate, "maximized", true);
325325 }
326326
327327 function test_tappingOnDecorationFocusesApplication(data) {
@@ -637,7 +637,7 @@ Item {
637637 var dialerAppDelegate = startApplication("dialer-app");
638638
639639 // verify the drop shadow becomes visible
640− verify(PanelState.dropShadow == true);
640+ tryCompareFunction(function() { return PanelState.dropShadow; }, true);
641641
642642 // close the maximized app
643643 ApplicationManager.stopApplication("facebook-webapp");
tests/qmltests/tst_OrientedShell.qml+5−3
@@ -695,9 +695,11 @@ Rectangle {
695695 // false -> true -> false
696696 compare(transitionSpy.count, 2);
697697
698− // It should retain native dimensions regardless of its rotation/orientation
699− compare(cameraSurface.width, orientedShell.width);
700− compare(cameraSurface.height, orientedShell.height);
698+ if (!data.windowed) { // subject to shell-chrome policies
699+ // It should retain native dimensions regardless of its rotation/orientation
700+ compare(cameraSurface.width, orientedShell.width);
701+ compare(cameraSurface.height, orientedShell.height);
702+ }
701703
702704 // Surface focus shouldn't have been touched because of the rotation
703705 compare(focusChangedSpy.count, 0);
tests/qmltests/tst_Shell.qml+8−13
@@ -334,7 +334,7 @@ Rectangle {
334334
335335 Row {
336336 CheckBox {
337− id: fullscreeAppCheck
337+ id: fullscreenAppCheck
338338 activeFocusOnPress: false
339339 activeFocusOnTab: false
340340
@@ -348,13 +348,10 @@ Rectangle {
348348 }
349349
350350 Binding {
351− target: fullscreeAppCheck
351+ target: fullscreenAppCheck
352352 when: topLevelSurfaceList && topLevelSurfaceList.focusedWindow
353353 property: "checked"
354− value: {
355− if (!topLevelSurfaceList || !topLevelSurfaceList.focusedWindow) return false;
356− return topLevelSurfaceList.focusedWindow.state === Mir.FullscreenState
357− }
354+ value: topLevelSurfaceList.focusedWindow.state === Mir.FullscreenState
358355 }
359356 }
360357 Label {
@@ -365,6 +362,8 @@ Rectangle {
365362 Row {
366363 CheckBox {
367364 id: chromeAppCheck
365+ activeFocusOnPress: false
366+ activeFocusOnTab: false
368367
369368 onTriggered: {
370369 if (!topLevelSurfaceList.focusedWindow || !topLevelSurfaceList.focusedWindow.surface) return;
@@ -380,10 +379,7 @@ Rectangle {
380379 target: chromeAppCheck
381380 when: topLevelSurfaceList && topLevelSurfaceList.focusedWindow !== null && topLevelSurfaceList.focusedWindow.surface !== null
382381 property: "checked"
383− value: {
384− if (!topLevelSurfaceList || !topLevelSurfaceList.focusedWindow || !topLevelSurfaceList.focusedWindow.surface) return false;
385− topLevelSurfaceList.focusedWindow.surface.shellChrome === Mir.LowChrome
386− }
382+ value: topLevelSurfaceList.focusedWindow.surface.shellChrome === Mir.LowChrome
387383 }
388384 }
389385 Label {
@@ -2294,7 +2290,6 @@ Rectangle {
22942290 return [
22952291 { tag: "phone" },
22962292 { tag: "tablet" },
2297− { tag: "desktop" },
22982293 ]
22992294 }
23002295
@@ -2674,8 +2669,8 @@ Rectangle {
26742669 }
26752670
26762671 function test_cursorHidingWithFullscreenApp() {
2677− loadShell("desktop");
2678− shell.usageScenario = "desktop";
2672+ loadShell("phone");
2673+ shell.usageScenario = "phone";
26792674 waitForRendering(shell);
26802675 swipeAwayGreeter();
26812676