@@ -46,6 +46,7 @@ FocusScope {
4646 property int leftMargin: 0
4747 property bool oskEnabled: false
4848 property rect inputMethodRect
49+ property real rightEdgePushProgress: 0
4950
5051 // Configuration
5152 property string mode: "staged"
@@ -101,6 +102,8 @@ FocusScope {
101102 // No we didn't, do a quick alt-tab
102103 if (appRepeater.count > 1) {
103104 appRepeater.itemAt(1).activate();
105+ } else if (appRepeater.count > 0) {
106+ appRepeater.itemAt(0).activate(); // quick alt-tab to the only (minimized) window should still activate it
104107 }
105108 }
106109 }
@@ -125,11 +128,6 @@ FocusScope {
125128 // functions to be called from outside
126129 function updateFocusedAppOrientation() { /* TODO */ }
127130 function updateFocusedAppOrientationAnimated() { /* TODO */}
128− function pushRightEdge(amount) {
129− if (root.spreadEnabled) {
130− edgeBarrier.push(amount);
131− }
132− }
133131
134132 function closeSpread() {
135133 priv.goneToSpread = false;
@@ -141,6 +139,12 @@ FocusScope {
141139 }
142140 }
143141
142+ onRightEdgePushProgressChanged: {
143+ if (spreadEnabled && rightEdgePushProgress >= 1) {
144+ priv.goneToSpread = true
145+ }
146+ }
147+
144148 GSettings {
145149 id: lifecycleExceptions
146150 schema.id: "com.canonical.qtmir"
@@ -452,7 +456,7 @@ FocusScope {
452456 PropertyChanges { target: wallpaper; visible: false }
453457 },
454458 State {
455− name: "stagedRightEdge"; when: (rightEdgeDragArea.dragging || edgeBarrier.progress > 0) && root.mode == "staged"
459+ name: "stagedRightEdge"; when: root.spreadEnabled && (rightEdgeDragArea.dragging || rightEdgePushProgress > 0) && root.mode == "staged"
456460 PropertyChanges {
457461 target: blurLayer;
458462 visible: true;
@@ -462,7 +466,7 @@ FocusScope {
462466 }
463467 },
464468 State {
465− name: "sideStagedRightEdge"; when: (rightEdgeDragArea.dragging || edgeBarrier.progress > 0) && root.mode == "stagedWithSideStage"
469+ name: "sideStagedRightEdge"; when: root.spreadEnabled && (rightEdgeDragArea.dragging || rightEdgePushProgress > 0) && root.mode == "stagedWithSideStage"
466470 extend: "stagedRightEdge"
467471 PropertyChanges {
468472 target: sideStage
@@ -471,18 +475,18 @@ FocusScope {
471475 }
472476 },
473477 State {
474− name: "windowedRightEdge"; when: (rightEdgeDragArea.dragging || edgeBarrier.progress > 0) && root.mode == "windowed"
478+ name: "windowedRightEdge"; when: root.spreadEnabled && (rightEdgeDragArea.dragging || rightEdgePushProgress > 0) && root.mode == "windowed"
475479 PropertyChanges {
476480 target: blurLayer;
477481 visible: true
478482 blurRadius: 32
479483 brightness: .65
480− opacity: MathUtils.linearAnimation(spreadItem.rightEdgeBreakPoint, 1, 0, 1, Math.max(rightEdgeDragArea.dragging ? rightEdgeDragArea.progress : 0, edgeBarrier.progress))
484+ opacity: MathUtils.linearAnimation(spreadItem.rightEdgeBreakPoint, 1, 0, 1, Math.max(rightEdgeDragArea.dragging ? rightEdgeDragArea.progress : 0, rightEdgePushProgress))
481485 }
482486 },
483487 State {
484488 name: "staged"; when: root.mode === "staged"
485− PropertyChanges { target: wallpaper; visible: false }
489+ PropertyChanges { target: wallpaper; visible: !priv.focusedAppDelegate || priv.focusedAppDelegate.x !== 0 }
486490 },
487491 State {
488492 name: "stagedWithSideStage"; when: root.mode === "stagedWithSideStage"
@@ -502,7 +506,6 @@ FocusScope {
502506 Transition {
503507 to: "spread"
504508 PropertyAction { target: spreadItem; property: "highlightedIndex"; value: appRepeater.count > 1 ? 1 : 0 }
505− PropertyAction { target: floatingFlickable; property: "contentX"; value: 0 }
506509 },
507510 Transition {
508511 from: "spread"
@@ -517,6 +520,7 @@ FocusScope {
517520 }
518521 }
519522 PropertyAction { target: spreadItem; property: "highlightedIndex"; value: -1 }
523+ PropertyAction { target: floatingFlickable; property: "contentX"; value: 0 }
520524 }
521525 },
522526 Transition {
@@ -811,7 +815,7 @@ FocusScope {
811815 maximizedTopLeft || maximizedTopRight || maximizedBottomLeft || maximizedBottomRight
812816
813817 readonly property bool minimized: windowState & WindowStateStorage.WindowStateMinimized
814− readonly property bool fullscreen: window.state === Mir.FullscreenState
818+ readonly property bool fullscreen: windowState === WindowStateStorage.WindowStateFullscreen
815819
816820 readonly property bool canBeMaximized: canBeMaximizedHorizontally && canBeMaximizedVertically
817821 readonly property bool canBeMaximizedLeftRight: (maximumWidth == 0 || maximumWidth >= appContainer.width/2) &&
@@ -822,7 +826,10 @@ FocusScope {
822826 readonly property bool canBeMaximizedVertically: maximumHeight == 0 || maximumHeight >= appContainer.height
823827 readonly property alias orientationChangesEnabled: decoratedWindow.orientationChangesEnabled
824828
829+ // TODO drop our own windowType once Mir/Miral/Qtmir gets in sync with ours
825830 property int windowState: WindowStateStorage.WindowStateNormal
831+ property int prevWindowState: WindowStateStorage.WindowStateRestored
832+
826833 property bool animationsEnabled: true
827834 property alias title: decoratedWindow.title
828835 readonly property string appName: model.application ? model.application.name : ""
@@ -877,9 +884,6 @@ FocusScope {
877884 }
878885 priv.updateMainAndSideStageIndexes();
879886 }
880− if (root.mode == "windowed") {
881− appDelegate.restore(true /* animated */, appDelegate.windowState);
882− }
883887 appDelegate.focus = true;
884888 }
885889
@@ -929,7 +933,14 @@ FocusScope {
929933 } else if (model.window.state === Mir.MaximizedBottomRightState) {
930934 appDelegate.maximizeBottomRight();
931935 } else if (model.window.state === Mir.RestoredState) {
932− appDelegate.restore();
936+ if (appDelegate.fullscreen && appDelegate.prevWindowState != WindowStateStorage.WindowStateRestored) {
937+ model.window.requestState(WindowStateStorage.toMirState(appDelegate.prevWindowState));
938+ } else {
939+ appDelegate.restore();
940+ }
941+ } else if (model.window.state === Mir.FullscreenState) {
942+ appDelegate.prevWindowState = appDelegate.windowState;
943+ appDelegate.windowState = WindowStateStorage.WindowStateFullscreen;
933944 }
934945 }
935946 }
@@ -1031,6 +1042,7 @@ FocusScope {
10311042 animationsEnabled = (animated === undefined) || animated;
10321043 windowState = state || WindowStateStorage.WindowStateRestored;
10331044 windowState &= ~WindowStateStorage.WindowStateMinimized; // clear the minimized bit
1045+ prevWindowState = windowState;
10341046 }
10351047
10361048 function playFocusAnimation() {
@@ -1193,7 +1205,7 @@ FocusScope {
11931205 when: (root.mode == "staged" || root.mode == "stagedWithSideStage") && (root.state == "sideStagedRightEdge" || root.state == "stagedRightEdge" || rightEdgeFocusAnimation.running || hidingAnimation.running)
11941206 PropertyChanges {
11951207 target: stagedRightEdgeMaths
1196− progress: Math.max(edgeBarrier.progress, rightEdgeDragArea.draggedProgress)
1208+ progress: Math.max(rightEdgePushProgress, rightEdgeDragArea.draggedProgress)
11971209 }
11981210 PropertyChanges {
11991211 target: appDelegate
@@ -1220,11 +1232,11 @@ FocusScope {
12201232 },
12211233 State {
12221234 name: "windowedRightEdge"
1223− when: root.mode == "windowed" && (root.state == "windowedRightEdge" || rightEdgeFocusAnimation.running || hidingAnimation.running || edgeBarrier.progress > 0)
1235+ when: root.mode == "windowed" && (root.state == "windowedRightEdge" || rightEdgeFocusAnimation.running || hidingAnimation.running || rightEdgePushProgress > 0)
12241236 PropertyChanges {
12251237 target: windowedRightEdgeMaths
12261238 swipeProgress: rightEdgeDragArea.dragging ? rightEdgeDragArea.progress : 0
1227− pushProgress: edgeBarrier.progress
1239+ pushProgress: rightEdgePushProgress
12281240 }
12291241 PropertyChanges {
12301242 target: appDelegate
@@ -1418,11 +1430,12 @@ FocusScope {
14181430 name: "minimized"; when: appDelegate.minimized
14191431 PropertyChanges {
14201432 target: appDelegate
1421− requestedX: -appDelegate.width / 2
14221433 scale: units.gu(5) / appDelegate.width
14231434 opacity: 0;
14241435 visuallyMinimized: true
14251436 visuallyMaximized: false
1437+ x: -appDelegate.width / 2
1438+ y: root.height / 2
14261439 }
14271440 }
14281441 ]
@@ -1438,15 +1451,6 @@ FocusScope {
14381451 to: "staged,stagedWithSideStage"
14391452 UbuntuNumberAnimation { target: appDelegate; properties: "x,y,requestedX,requestedY,requestedWidth,requestedHeight"; duration: priv.animationDuration}
14401453 },
1441− Transition {
1442− to: "minimized"
1443− enabled: appDelegate.animationsEnabled
1444− PropertyAction { target: appDelegate; property: "visuallyMaximized" }
1445− SequentialAnimation {
1446− UbuntuNumberAnimation { target: appDelegate; properties: "requestedX,requestedY,opacity,scale,requestedWidth,requestedHeight" }
1447− PropertyAction { target: appDelegate; property: "visuallyMinimized" }
1448− }
1449− },
14501454 Transition {
14511455 to: "spread"
14521456 // DecoratedWindow wants the scaleToPreviewSize set before enabling scaleToPreview
@@ -1495,6 +1499,31 @@ FocusScope {
14951499 PropertyAction { target: appDelegate; property: "visible" }
14961500 }
14971501 },
1502+ Transition {
1503+ from: ",normal,restored,maximized,maximizedLeft,maximizedRight,maximizedTopLeft,maximizedTopRight,maximizedBottomLeft,maximizedBottomRight,maximizedHorizontally,maximizedVertically,fullscreen"
1504+ to: "minimized"
1505+ SequentialAnimation {
1506+ ScriptAction { script: print("transitioning:", appDelegate.x, appDelegate.y, appDelegate.scale) }
1507+ ScriptAction { script: { fakeRectangle.stop(); } }
1508+ PropertyAction { target: appDelegate; property: "visuallyMaximized" }
1509+ UbuntuNumberAnimation { target: appDelegate; properties: "x,y,scale,opacity"; duration: priv.animationDuration }
1510+ PropertyAction { target: appDelegate; property: "visuallyMinimized" }
1511+ }
1512+ },
1513+ Transition {
1514+ from: "minimized"
1515+ to: ",normal,restored,maximized,maximizedLeft,maximizedRight,maximizedTopLeft,maximizedTopRight,maximizedBottomLeft,maximizedBottomRight,maximizedHorizontally,maximizedVertically,fullscreen"
1516+ SequentialAnimation {
1517+ ScriptAction { script: print("transitioning:", appDelegate.x, appDelegate.y, appDelegate.scale) }
1518+ PropertyAction { target: appDelegate; property: "visuallyMinimized,z" }
1519+ ParallelAnimation {
1520+ UbuntuNumberAnimation { target: appDelegate; properties: "x"; from: -appDelegate.width / 2; duration: priv.animationDuration }
1521+ UbuntuNumberAnimation { target: appDelegate; properties: "y,opacity"; duration: priv.animationDuration }
1522+ UbuntuNumberAnimation { target: appDelegate; properties: "scale"; from: 0; duration: priv.animationDuration }
1523+ }
1524+ PropertyAction { target: appDelegate; property: "visuallyMaximized" }
1525+ }
1526+ },
14981527 Transition {
14991528 id: windowedTransition
15001529 from: ",normal,restored,maximized,maximizedLeft,maximizedRight,maximizedTopLeft,maximizedTopRight,maximizedBottomLeft,maximizedBottomRight,maximizedHorizontally,maximizedVertically,fullscreen,minimized"
@@ -1586,7 +1615,10 @@ FocusScope {
15861615 onDecorationReleased: fakeRectangle.commit();
15871616
15881617 property real angle: 0
1618+ Behavior on angle { enabled: priv.closingIndex >= 0; UbuntuNumberAnimation {} }
15891619 property real itemScale: 1
1620+ Behavior on itemScale { enabled: priv.closingIndex >= 0; UbuntuNumberAnimation {} }
1621+
15901622 transform: [
15911623 Scale {
15921624 origin.x: 0
@@ -1648,7 +1680,6 @@ FocusScope {
16481680 onClicked: {
16491681 spreadItem.highlightedIndex = index;
16501682 if (distance == 0) {
1651− model.window.activate();
16521683 priv.goneToSpread = false;
16531684 }
16541685 }
@@ -1756,30 +1787,6 @@ FocusScope {
17561787 appContainerHeight: appContainer.height
17571788 }
17581789
1759− EdgeBarrier {
1760− id: edgeBarrier
1761−
1762− // NB: it does its own positioning according to the specified edge
1763− edge: Qt.RightEdge
1764−
1765− onPassed: priv.goneToSpread = true;
1766−
1767− material: Component {
1768− Item {
1769− Rectangle {
1770− width: parent.height
1771− height: parent.width
1772− rotation: 90
1773− anchors.centerIn: parent
1774− gradient: Gradient {
1775− GradientStop { position: 0.0; color: Qt.rgba(0.16,0.16,0.16,0.5)}
1776− GradientStop { position: 1.0; color: Qt.rgba(0.16,0.16,0.16,0)}
1777− }
1778− }
1779− }
1780− }
1781− }
1782−
17831790 MouseArea {
17841791 id: hoverMouseArea
17851792 objectName: "hoverMouseArea"
@@ -1846,11 +1853,11 @@ FocusScope {
18461853 var targetContentX = floatingFlickable.contentWidth / spreadItem.totalItemCount * toIndex;
18471854 if (targetContentX - floatingFlickable.contentX > spreadItem.rightStackXPos - (spreadItem.spreadItemWidth / 2)) {
18481855 var offset = (spreadItem.rightStackXPos - (spreadItem.spreadItemWidth / 2)) - (targetContentX - floatingFlickable.contentX)
1849− snapAnimation.to = floatingFlickable.contentX - offset;
1856+ snapAnimation.to = Math.max(0, floatingFlickable.contentX - offset);
18501857 snapAnimation.start();
18511858 } else if (targetContentX - floatingFlickable.contentX < spreadItem.leftStackXPos + units.gu(1)) {
18521859 var offset = (spreadItem.leftStackXPos + units.gu(1)) - (targetContentX - floatingFlickable.contentX);
1853− snapAnimation.to = floatingFlickable.contentX - offset;
1860+ snapAnimation.to = Math.max(0, floatingFlickable.contentX - offset);
18541861 snapAnimation.start();
18551862 }
18561863 }