on xenial help sign in
shell chrome fixes
commit077284d65103dc02bdd14673c4eaf423e3a231bc authorLukáš Tinkl <lukas.tinkl@canonical.com> dateWed 22 Feb 2017, 18:47 (10 years ago) parent879cd78
5 files changed+54−39
qml/Stage/Stage.qml+35−13 qml/Stage/StagedFullscreenPolicy.qml+7−5 qml/Stage/WindowStateSaver.qml+2−1 qml/Stage/WindowedFullscreenPolicy.qml+4−10 tests/qmltests/tst_Shell.qml+6−10
qml/Stage/Stage.qml+35−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,22 @@ FocusScope {
945946 }
946947 }
947948
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;
961+ }
962+ }
963+ }
964+
948965 Component.onCompleted: {
949966 if (application && application.rotatesWindowContents) {
950967 decoratedWindow.surfaceOrientationAngle = shellOrientationAngle;
@@ -955,9 +972,12 @@ FocusScope {
955972 // First, cascade the newly created window, relative to the currently/old focused window.
956973 windowedX = priv.focusedAppDelegate ? priv.focusedAppDelegate.windowedX + units.gu(3) : (normalZ - 1) * units.gu(3)
957974 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!
959− windowStateSaver.load();
960− model.window.requestState(WindowStateStorage.toMirState(windowState));
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+ }
961981
962982 updateQmlFocusFromMirSurfaceFocus();
963983
@@ -965,7 +985,9 @@ FocusScope {
965985 _constructing = false;
966986 }
967987 Component.onDestruction: {
968− windowStateSaver.save();
988+ if (root.mode == "windowed") {
989+ windowStateSaver.save();
990+ }
969991
970992 if (!root.parent) {
971993 // This stage is about to be destroyed. Don't mess up with the model at this point
@@ -1441,7 +1463,7 @@ FocusScope {
14411463 ]
14421464 transitions: [
14431465 Transition {
1444− from: "staged,stagedWithSideStage"; to: "normal"
1466+ from: "staged,stagedWithSideStage"
14451467 enabled: appDelegate.animationsEnabled
14461468 PropertyAction { target: appDelegate; properties: "visuallyMinimized,visuallyMaximized" }
14471469 UbuntuNumberAnimation { target: appDelegate; properties: "x,y,requestedX,requestedY,opacity,requestedWidth,requestedHeight,scale"; duration: priv.animationDuration }
@@ -1462,8 +1484,7 @@ FocusScope {
14621484 },
14631485 Transition {
14641486 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 }
1487+ UbuntuNumberAnimation { target: appDelegate; properties: "x,y,requestedWidth,requestedHeight"; duration: priv.animationDuration }
14671488 },
14681489 Transition {
14691490 to: "windowedRightEdge"
@@ -1503,7 +1524,6 @@ FocusScope {
15031524 from: ",normal,restored,maximized,maximizedLeft,maximizedRight,maximizedTopLeft,maximizedTopRight,maximizedBottomLeft,maximizedBottomRight,maximizedHorizontally,maximizedVertically,fullscreen"
15041525 to: "minimized"
15051526 SequentialAnimation {
1506− ScriptAction { script: print("transitioning:", appDelegate.x, appDelegate.y, appDelegate.scale) }
15071527 ScriptAction { script: { fakeRectangle.stop(); } }
15081528 PropertyAction { target: appDelegate; property: "visuallyMaximized" }
15091529 UbuntuNumberAnimation { target: appDelegate; properties: "x,y,scale,opacity"; duration: priv.animationDuration }
@@ -1514,7 +1534,6 @@ FocusScope {
15141534 from: "minimized"
15151535 to: ",normal,restored,maximized,maximizedLeft,maximizedRight,maximizedTopLeft,maximizedTopRight,maximizedBottomLeft,maximizedBottomRight,maximizedHorizontally,maximizedVertically,fullscreen"
15161536 SequentialAnimation {
1517− ScriptAction { script: print("transitioning:", appDelegate.x, appDelegate.y, appDelegate.scale) }
15181537 PropertyAction { target: appDelegate; property: "visuallyMinimized,z" }
15191538 ParallelAnimation {
15201539 UbuntuNumberAnimation { target: appDelegate; properties: "x"; from: -appDelegate.width / 2; duration: priv.animationDuration }
@@ -1662,12 +1681,15 @@ FocusScope {
16621681 WindowedFullscreenPolicy {
16631682 id: windowedFullscreenPolicy
16641683 active: root.mode == "windowed"
1665− surface: model.window.surface
16661684 }
16671685 StagedFullscreenPolicy {
16681686 id: stagedFullscreenPolicy
16691687 active: root.mode == "staged" || root.mode == "stagedWithSideStage"
16701688 surface: model.window.surface
1689+ onStateRequested: {
1690+ delayedStateTimer.windowState = requestedState;
1691+ delayedStateTimer.restart();
1692+ }
16711693 }
16721694
16731695 SpreadDelegateInputArea {
qml/Stage/StagedFullscreenPolicy.qml+7−5
@@ -28,11 +28,13 @@ import Unity.Application 0.1
2828QtObject {
2929 property bool active: true
3030
31+ signal stateRequested(int requestedState)
32+
3133 property var surface: null
3234 onSurfaceChanged: {
3335 if (!active || !surface) return;
3436 if (surface.shellChrome === Mir.LowChrome) {
35− surface.requestState(Mir.FullscreenState);
37+ stateRequested(Mir.FullscreenState);
3638 }
3739 }
3840
@@ -41,15 +43,15 @@ QtObject {
4143 onShellChromeChanged: {
4244 if (!active || !surface) return;
4345 if (surface.shellChrome === Mir.LowChrome) {
44− surface.requestState(Mir.FullscreenState);
46+ stateRequested(Mir.FullscreenState);
4547 } else {
46− surface.requestState(Mir.RestoredState);
48+ stateRequested(Mir.RestoredState);
4749 }
4850 }
4951 onStateChanged: {
50− if (!active) return;
52+ if (!active || !surface) return;
5153 if (surface.state === Mir.RestoredState && surface.shellChrome === Mir.LowChrome) {
52− surface.requestState(Mir.FullscreenState);
54+ stateRequested(Mir.FullscreenState);
5355 }
5456 }
5557 }
qml/Stage/WindowStateSaver.qml+2−1
@@ -42,13 +42,14 @@ QtObject {
4242 target.windowedY = Qt.binding(function() { return Math.max(Math.min(windowGeometry.y, screenHeight - target.windowedHeight), minimumY); });
4343
4444 var windowState = WindowStateStorage.getState(target.appId, WindowStateStorage.WindowStateNormal)
45− target.restore(false /* animated */, windowState);
4645
4746 target.updateNormalGeometry();
4847
4948 // initialize the x/y to restore to
5049 target.restoredX = target.normalX;
5150 target.restoredY = target.normalY;
51+
52+ return windowState;
5253 }
5354
5455 function save() {
qml/Stage/WindowedFullscreenPolicy.qml+4−10
@@ -23,17 +23,11 @@ import Unity.Application 0.1
2323// state of the window is returned to restored.
2424QtObject {
2525 property bool active: true
26− property QtObject surface: null
2726
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);
27+ function applyPolicy(surfaceState, surfaceChrome) {
28+ if (surfaceState === Mir.FullscreenState && surfaceChrome === Mir.LowChrome) {
29+ return Mir.RestoredState;
3730 }
31+ return surfaceState;
3832 }
3933}
tests/qmltests/tst_Shell.qml+6−10
@@ -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 {