on xenial help sign in
merge lp:~lukas-kde/unity8/fix-shell-chrome
861db81Daniel d'Andrada
qml/Stage/ApplicationWindow.qml+2
@@ -28,6 +28,7 @@ FocusScope {
28 property bool orientationChangesEnabled: d.supportsSurfaceResize ? d.surfaceOldEnoughToBeResized : true
28 property bool orientationChangesEnabled: d.supportsSurfaceResize ? d.surfaceOldEnoughToBeResized : true
29 readonly property string title: surface && surface.name !== "" ? surface.name : d.name
29 readonly property string title: surface && surface.name !== "" ? surface.name : d.name
30 readonly property QtObject focusedSurface: d.focusedSurface.surface
30 readonly property QtObject focusedSurface: d.focusedSurface.surface
31+ readonly property alias surfaceInitialized: d.surfaceInitialized
31
32
32 // to be set from outside
33 // to be set from outside
33 property QtObject surface
34 property QtObject surface
@@ -124,6 +125,7 @@ FocusScope {
124 target: root.application
125 target: root.application
125 property: "initialSurfaceSize"
126 property: "initialSurfaceSize"
126 value: Qt.size(root.requestedWidth, root.requestedHeight)
127 value: Qt.size(root.requestedWidth, root.requestedHeight)
128+ when: d.surfaceInitialized
127 }
129 }
128
130
129 Timer {
131 Timer {
qml/Stage/Stage.qml+24−13
@@ -470,7 +470,7 @@ FocusScope {
470 extend: "stagedRightEdge"
470 extend: "stagedRightEdge"
471 PropertyChanges {
471 PropertyChanges {
472 target: sideStage
472 target: sideStage
473− opacity: priv.sideStageDelegate.x === sideStage.x ? 1 : 0
473+ opacity: priv.sideStageDelegate && priv.sideStageDelegate.x === sideStage.x ? 1 : 0
474 visible: true
474 visible: true
475 }
475 }
476 },
476 },
@@ -723,6 +723,7 @@ FocusScope {
723 // miral doesn't know about our window decorations. So we have to deduct them
723 // miral doesn't know about our window decorations. So we have to deduct them
724 value: Qt.point(appDelegate.requestedX + appDelegate.clientAreaItem.x,
724 value: Qt.point(appDelegate.requestedX + appDelegate.clientAreaItem.x,
725 appDelegate.requestedY + appDelegate.clientAreaItem.y)
725 appDelegate.requestedY + appDelegate.clientAreaItem.y)
726+ when: root.mode == "windowed"
726 }
727 }
727
728
728 // In those are for windowed mode. Those values basically store the window's properties
729 // In those are for windowed mode. Those values basically store the window's properties
@@ -768,7 +769,6 @@ FocusScope {
768 Math.max(0, priv.virtualKeyboardHeight - (appContainer.height - (appDelegate.requestedY + appDelegate.height))))
769 Math.max(0, priv.virtualKeyboardHeight - (appContainer.height - (appDelegate.requestedY + appDelegate.height))))
769 when: root.oskEnabled && appDelegate.focus && (appDelegate.state == "normal" || appDelegate.state == "restored")
770 when: root.oskEnabled && appDelegate.focus && (appDelegate.state == "normal" || appDelegate.state == "restored")
770 && root.inputMethodRect.height > 0
771 && root.inputMethodRect.height > 0
771−
772 }
772 }
773
773
774 Behavior on x { id: xBehavior; enabled: priv.closingIndex >= 0; UbuntuNumberAnimation { onRunningChanged: if (!running) priv.closingIndex = -1} }
774 Behavior on x { id: xBehavior; enabled: priv.closingIndex >= 0; UbuntuNumberAnimation { onRunningChanged: if (!running) priv.closingIndex = -1} }
@@ -933,7 +933,8 @@ FocusScope {
933 } else if (model.window.state === Mir.MaximizedBottomRightState) {
933 } else if (model.window.state === Mir.MaximizedBottomRightState) {
934 appDelegate.maximizeBottomRight();
934 appDelegate.maximizeBottomRight();
935 } else if (model.window.state === Mir.RestoredState) {
935 } 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) {
937 model.window.requestState(WindowStateStorage.toMirState(appDelegate.prevWindowState));
938 model.window.requestState(WindowStateStorage.toMirState(appDelegate.prevWindowState));
938 } else {
939 } else {
939 appDelegate.restore();
940 appDelegate.restore();
@@ -945,6 +946,20 @@ FocusScope {
945 }
946 }
946 }
947 }
947
948
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+
948 Component.onCompleted: {
963 Component.onCompleted: {
949 if (application && application.rotatesWindowContents) {
964 if (application && application.rotatesWindowContents) {
950 decoratedWindow.surfaceOrientationAngle = shellOrientationAngle;
965 decoratedWindow.surfaceOrientationAngle = shellOrientationAngle;
@@ -956,8 +971,7 @@ FocusScope {
956 windowedX = priv.focusedAppDelegate ? priv.focusedAppDelegate.windowedX + units.gu(3) : (normalZ - 1) * units.gu(3)
971 windowedX = priv.focusedAppDelegate ? priv.focusedAppDelegate.windowedX + units.gu(3) : (normalZ - 1) * units.gu(3)
957 windowedY = priv.focusedAppDelegate ? priv.focusedAppDelegate.windowedY + units.gu(3) : normalZ * units.gu(3)
972 windowedY = priv.focusedAppDelegate ? priv.focusedAppDelegate.windowedY + units.gu(3) : normalZ * units.gu(3)
958 // Now load any saved state. This needs to happen *after* the cascading!
973 // 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());
961
975
962 updateQmlFocusFromMirSurfaceFocus();
976 updateQmlFocusFromMirSurfaceFocus();
963
977
@@ -965,7 +979,9 @@ FocusScope {
965 _constructing = false;
979 _constructing = false;
966 }
980 }
967 Component.onDestruction: {
981 Component.onDestruction: {
982+ if (root.mode == "windowed") {
968− windowStateSaver.save();
983+ windowStateSaver.save();
984+ }
969
985
970 if (!root.parent) {
986 if (!root.parent) {
971 // This stage is about to be destroyed. Don't mess up with the model at this point
987 // This stage is about to be destroyed. Don't mess up with the model at this point
@@ -1441,7 +1457,7 @@ FocusScope {
1441 ]
1457 ]
1442 transitions: [
1458 transitions: [
1443 Transition {
1459 Transition {
1444− from: "staged,stagedWithSideStage"; to: "normal"
1460+ from: "staged,stagedWithSideStage"
1445 enabled: appDelegate.animationsEnabled
1461 enabled: appDelegate.animationsEnabled
1446 PropertyAction { target: appDelegate; properties: "visuallyMinimized,visuallyMaximized" }
1462 PropertyAction { target: appDelegate; properties: "visuallyMinimized,visuallyMaximized" }
1447 UbuntuNumberAnimation { target: appDelegate; properties: "x,y,requestedX,requestedY,opacity,requestedWidth,requestedHeight,scale"; duration: priv.animationDuration }
1463 UbuntuNumberAnimation { target: appDelegate; properties: "x,y,requestedX,requestedY,opacity,requestedWidth,requestedHeight,scale"; duration: priv.animationDuration }
@@ -1462,8 +1478,7 @@ FocusScope {
1462 },
1478 },
1463 Transition {
1479 Transition {
1464 from: "normal,staged"; to: "stagedWithSideStage"
1480 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 }
1467 },
1482 },
1468 Transition {
1483 Transition {
1469 to: "windowedRightEdge"
1484 to: "windowedRightEdge"
@@ -1503,7 +1518,6 @@ FocusScope {
1503 from: ",normal,restored,maximized,maximizedLeft,maximizedRight,maximizedTopLeft,maximizedTopRight,maximizedBottomLeft,maximizedBottomRight,maximizedHorizontally,maximizedVertically,fullscreen"
1518 from: ",normal,restored,maximized,maximizedLeft,maximizedRight,maximizedTopLeft,maximizedTopRight,maximizedBottomLeft,maximizedBottomRight,maximizedHorizontally,maximizedVertically,fullscreen"
1504 to: "minimized"
1519 to: "minimized"
1505 SequentialAnimation {
1520 SequentialAnimation {
1506− ScriptAction { script: print("transitioning:", appDelegate.x, appDelegate.y, appDelegate.scale) }
1507 ScriptAction { script: { fakeRectangle.stop(); } }
1521 ScriptAction { script: { fakeRectangle.stop(); } }
1508 PropertyAction { target: appDelegate; property: "visuallyMaximized" }
1522 PropertyAction { target: appDelegate; property: "visuallyMaximized" }
1509 UbuntuNumberAnimation { target: appDelegate; properties: "x,y,scale,opacity"; duration: priv.animationDuration }
1523 UbuntuNumberAnimation { target: appDelegate; properties: "x,y,scale,opacity"; duration: priv.animationDuration }
@@ -1514,7 +1528,6 @@ FocusScope {
1514 from: "minimized"
1528 from: "minimized"
1515 to: ",normal,restored,maximized,maximizedLeft,maximizedRight,maximizedTopLeft,maximizedTopRight,maximizedBottomLeft,maximizedBottomRight,maximizedHorizontally,maximizedVertically,fullscreen"
1529 to: ",normal,restored,maximized,maximizedLeft,maximizedRight,maximizedTopLeft,maximizedTopRight,maximizedBottomLeft,maximizedBottomRight,maximizedHorizontally,maximizedVertically,fullscreen"
1516 SequentialAnimation {
1530 SequentialAnimation {
1517− ScriptAction { script: print("transitioning:", appDelegate.x, appDelegate.y, appDelegate.scale) }
1518 PropertyAction { target: appDelegate; property: "visuallyMinimized,z" }
1531 PropertyAction { target: appDelegate; property: "visuallyMinimized,z" }
1519 ParallelAnimation {
1532 ParallelAnimation {
1520 UbuntuNumberAnimation { target: appDelegate; properties: "x"; from: -appDelegate.width / 2; duration: priv.animationDuration }
1533 UbuntuNumberAnimation { target: appDelegate; properties: "x"; from: -appDelegate.width / 2; duration: priv.animationDuration }
@@ -1661,8 +1674,6 @@ FocusScope {
1661
1674
1662 WindowedFullscreenPolicy {
1675 WindowedFullscreenPolicy {
1663 id: windowedFullscreenPolicy
1676 id: windowedFullscreenPolicy
1664− active: root.mode == "windowed"
1665− surface: model.window.surface
1666 }
1677 }
1667 StagedFullscreenPolicy {
1678 StagedFullscreenPolicy {
1668 id: stagedFullscreenPolicy
1679 id: stagedFullscreenPolicy
qml/Stage/StagedFullscreenPolicy.qml+5−11
@@ -28,14 +28,14 @@ import Unity.Application 0.1
28QtObject {
28QtObject {
29 property bool active: true
29 property bool active: true
30
30
31− property var surface: null
31+ function applyPolicy(surfaceState, surfaceChrome) {
32− onSurfaceChanged: {
33− if (!active || !surface) return;
34− if (surface.shellChrome === Mir.LowChrome) {
32+ if (surfaceChrome === Mir.LowChrome) {
35− surface.requestState(Mir.FullscreenState);
33+ return Mir.FullscreenState;
36 }
34 }
35+ return surfaceState;
37 }
36 }
38
37
38+ property var surface: null
39 property var _connections: Connections {
39 property var _connections: Connections {
40 target: surface
40 target: surface
41 onShellChromeChanged: {
41 onShellChromeChanged: {
@@ -46,11 +46,5 @@ QtObject {
46 surface.requestState(Mir.RestoredState);
46 surface.requestState(Mir.RestoredState);
47 }
47 }
48 }
48 }
49− onStateChanged: {
50− if (!active) return;
51− if (surface.state === Mir.RestoredState && surface.shellChrome === Mir.LowChrome) {
52− surface.requestState(Mir.FullscreenState);
53− }
54− }
55 }
49 }
56}
50}
qml/Stage/WindowStateSaver.qml+2−3
@@ -41,14 +41,13 @@ QtObject {
41 (target.fullscreen ? 0 : root.leftMargin)); });
41 (target.fullscreen ? 0 : root.leftMargin)); });
42 target.windowedY = Qt.binding(function() { return Math.max(Math.min(windowGeometry.y, screenHeight - target.windowedHeight), minimumY); });
42 target.windowedY = Qt.binding(function() { return Math.max(Math.min(windowGeometry.y, screenHeight - target.windowedHeight), minimumY); });
43
43
44− var windowState = WindowStateStorage.getState(target.appId, WindowStateStorage.WindowStateNormal)
45− target.restore(false /* animated */, windowState);
46−
47 target.updateNormalGeometry();
44 target.updateNormalGeometry();
48
45
49 // initialize the x/y to restore to
46 // initialize the x/y to restore to
50 target.restoredX = target.normalX;
47 target.restoredX = target.normalX;
51 target.restoredY = target.normalY;
48 target.restoredY = target.normalY;
49+
50+ return WindowStateStorage.getState(target.appId, WindowStateStorage.WindowStateNormal);
52 }
51 }
53
52
54 function save() {
53 function save() {
qml/Stage/WindowedFullscreenPolicy.qml+4−12
@@ -22,18 +22,10 @@ import Unity.Application 0.1
22// On first surface load; if the surface is set to low chrome & fullscreen, the
22// On first surface load; if the surface is set to low chrome & fullscreen, the
23// state of the window is returned to restored.
23// state of the window is returned to restored.
24QtObject {
24QtObject {
25− property bool active: true
25+ function applyPolicy(surfaceState, surfaceChrome) {
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) {
26+ if (surfaceState === Mir.FullscreenState && surfaceChrome === Mir.LowChrome) {
36− surface.requestState(Mir.RestoredState);
27+ return Mir.RestoredState;
37 }
28 }
29+ return surfaceState;
38 }
30 }
39}
31}
tests/qmltests/Stage/tst_DesktopStage.qml+2−2
@@ -321,7 +321,7 @@ Item {
321 var maximizeButton = findChild(appDelegate, "maximizeWindowButton");
321 var maximizeButton = findChild(appDelegate, "maximizeWindowButton");
322 verify(maximizeButton);
322 verify(maximizeButton);
323 mouseClick(maximizeButton);
323 mouseClick(maximizeButton);
324− tryCompare(appDelegate, "visuallyMaximized", true);
324+ tryCompare(appDelegate, "maximized", true);
325 }
325 }
326
326
327 function test_tappingOnDecorationFocusesApplication(data) {
327 function test_tappingOnDecorationFocusesApplication(data) {
@@ -637,7 +637,7 @@ Item {
637 var dialerAppDelegate = startApplication("dialer-app");
637 var dialerAppDelegate = startApplication("dialer-app");
638
638
639 // verify the drop shadow becomes visible
639 // verify the drop shadow becomes visible
640− verify(PanelState.dropShadow == true);
640+ tryCompareFunction(function() { return PanelState.dropShadow; }, true);
641
641
642 // close the maximized app
642 // close the maximized app
643 ApplicationManager.stopApplication("facebook-webapp");
643 ApplicationManager.stopApplication("facebook-webapp");
tests/qmltests/tst_OrientedShell.qml+5−3
@@ -695,9 +695,11 @@ Rectangle {
695 // false -> true -> false
695 // false -> true -> false
696 compare(transitionSpy.count, 2);
696 compare(transitionSpy.count, 2);
697
697
698+ if (!data.windowed) { // subject to shell-chrome policies
698− // It should retain native dimensions regardless of its rotation/orientation
699+ // It should retain native dimensions regardless of its rotation/orientation
699− compare(cameraSurface.width, orientedShell.width);
700+ compare(cameraSurface.width, orientedShell.width);
700− compare(cameraSurface.height, orientedShell.height);
701+ compare(cameraSurface.height, orientedShell.height);
702+ }
701
703
702 // Surface focus shouldn't have been touched because of the rotation
704 // Surface focus shouldn't have been touched because of the rotation
703 compare(focusChangedSpy.count, 0);
705 compare(focusChangedSpy.count, 0);
tests/qmltests/tst_Shell.qml+8−13
@@ -334,7 +334,7 @@ Rectangle {
334
334
335 Row {
335 Row {
336 CheckBox {
336 CheckBox {
337− id: fullscreeAppCheck
337+ id: fullscreenAppCheck
338 activeFocusOnPress: false
338 activeFocusOnPress: false
339 activeFocusOnTab: false
339 activeFocusOnTab: false
340
340
@@ -348,13 +348,10 @@ Rectangle {
348 }
348 }
349
349
350 Binding {
350 Binding {
351− target: fullscreeAppCheck
351+ target: fullscreenAppCheck
352 when: topLevelSurfaceList && topLevelSurfaceList.focusedWindow
352 when: topLevelSurfaceList && topLevelSurfaceList.focusedWindow
353 property: "checked"
353 property: "checked"
354− value: {
355− if (!topLevelSurfaceList || !topLevelSurfaceList.focusedWindow) return false;
356− return topLevelSurfaceList.focusedWindow.state === Mir.FullscreenState
354+ value: topLevelSurfaceList.focusedWindow.state === Mir.FullscreenState
357− }
358 }
355 }
359 }
356 }
360 Label {
357 Label {
@@ -365,6 +362,8 @@ Rectangle {
365 Row {
362 Row {
366 CheckBox {
363 CheckBox {
367 id: chromeAppCheck
364 id: chromeAppCheck
365+ activeFocusOnPress: false
366+ activeFocusOnTab: false
368
367
369 onTriggered: {
368 onTriggered: {
370 if (!topLevelSurfaceList.focusedWindow || !topLevelSurfaceList.focusedWindow.surface) return;
369 if (!topLevelSurfaceList.focusedWindow || !topLevelSurfaceList.focusedWindow.surface) return;
@@ -380,10 +379,7 @@ Rectangle {
380 target: chromeAppCheck
379 target: chromeAppCheck
381 when: topLevelSurfaceList && topLevelSurfaceList.focusedWindow !== null && topLevelSurfaceList.focusedWindow.surface !== null
380 when: topLevelSurfaceList && topLevelSurfaceList.focusedWindow !== null && topLevelSurfaceList.focusedWindow.surface !== null
382 property: "checked"
381 property: "checked"
383− value: {
384− if (!topLevelSurfaceList || !topLevelSurfaceList.focusedWindow || !topLevelSurfaceList.focusedWindow.surface) return false;
385− topLevelSurfaceList.focusedWindow.surface.shellChrome === Mir.LowChrome
382+ value: topLevelSurfaceList.focusedWindow.surface.shellChrome === Mir.LowChrome
386− }
387 }
383 }
388 }
384 }
389 Label {
385 Label {
@@ -2294,7 +2290,6 @@ Rectangle {
2294 return [
2290 return [
2295 { tag: "phone" },
2291 { tag: "phone" },
2296 { tag: "tablet" },
2292 { tag: "tablet" },
2297− { tag: "desktop" },
2298 ]
2293 ]
2299 }
2294 }
2300
2295
@@ -2674,8 +2669,8 @@ Rectangle {
2674 }
2669 }
2675
2670
2676 function test_cursorHidingWithFullscreenApp() {
2671 function test_cursorHidingWithFullscreenApp() {
2677− loadShell("desktop");
2672+ loadShell("phone");
2678− shell.usageScenario = "desktop";
2673+ shell.usageScenario = "phone";
2679 waitForRendering(shell);
2674 waitForRendering(shell);
2680 swipeAwayGreeter();
2675 swipeAwayGreeter();
2681
2676