@@ -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 property PanelState panelState
5051
5152 // Configuration
@@ -102,6 +103,8 @@ FocusScope {
102103 // No we didn't, do a quick alt-tab
103104 if (appRepeater.count > 1) {
104105 appRepeater.itemAt(1).activate();
106+ } else if (appRepeater.count > 0) {
107+ appRepeater.itemAt(0).activate(); // quick alt-tab to the only (minimized) window should still activate it
105108 }
106109 }
107110 }
@@ -126,11 +129,6 @@ FocusScope {
126129 // functions to be called from outside
127130 function updateFocusedAppOrientation() { /* TODO */ }
128131 function updateFocusedAppOrientationAnimated() { /* TODO */}
129− function pushRightEdge(amount) {
130− if (root.spreadEnabled) {
131− edgeBarrier.push(amount);
132− }
133− }
134132
135133 function closeSpread() {
136134 priv.goneToSpread = false;
@@ -142,6 +140,12 @@ FocusScope {
142140 }
143141 }
144142
143+ onRightEdgePushProgressChanged: {
144+ if (spreadEnabled && rightEdgePushProgress >= 1) {
145+ priv.goneToSpread = true
146+ }
147+ }
148+
145149 GSettings {
146150 id: lifecycleExceptions
147151 schema.id: "com.canonical.qtmir"
@@ -454,7 +458,7 @@ FocusScope {
454458 PropertyChanges { target: screensAndWorkspaces; opacity: 1 }
455459 },
456460 State {
457− name: "stagedRightEdge"; when: (rightEdgeDragArea.dragging || edgeBarrier.progress > 0) && root.mode == "staged"
461+ name: "stagedRightEdge"; when: root.spreadEnabled && (rightEdgeDragArea.dragging || rightEdgePushProgress > 0) && root.mode == "staged"
458462 PropertyChanges {
459463 target: blurLayer;
460464 visible: true;
@@ -464,7 +468,7 @@ FocusScope {
464468 }
465469 },
466470 State {
467− name: "sideStagedRightEdge"; when: (rightEdgeDragArea.dragging || edgeBarrier.progress > 0) && root.mode == "stagedWithSideStage"
471+ name: "sideStagedRightEdge"; when: root.spreadEnabled && (rightEdgeDragArea.dragging || rightEdgePushProgress > 0) && root.mode == "stagedWithSideStage"
468472 extend: "stagedRightEdge"
469473 PropertyChanges {
470474 target: sideStage
@@ -473,18 +477,18 @@ FocusScope {
473477 }
474478 },
475479 State {
476− name: "windowedRightEdge"; when: (rightEdgeDragArea.dragging || edgeBarrier.progress > 0) && root.mode == "windowed"
480+ name: "windowedRightEdge"; when: root.spreadEnabled && (rightEdgeDragArea.dragging || rightEdgePushProgress > 0) && root.mode == "windowed"
477481 PropertyChanges {
478482 target: blurLayer;
479483 visible: true
480484 blurRadius: 32
481485 brightness: .65
482− opacity: MathUtils.linearAnimation(spreadItem.rightEdgeBreakPoint, 1, 0, 1, Math.max(rightEdgeDragArea.dragging ? rightEdgeDragArea.progress : 0, edgeBarrier.progress))
486+ opacity: MathUtils.linearAnimation(spreadItem.rightEdgeBreakPoint, 1, 0, 1, Math.max(rightEdgeDragArea.dragging ? rightEdgeDragArea.progress : 0, rightEdgePushProgress))
483487 }
484488 },
485489 State {
486490 name: "staged"; when: root.mode === "staged"
487− PropertyChanges { target: wallpaper; visible: priv.focusedAppDelegate && priv.focusedAppDelegate.x === 0 }
491+ PropertyChanges { target: wallpaper; visible: !priv.focusedAppDelegate || priv.focusedAppDelegate.x !== 0 }
488492 },
489493 State {
490494 name: "stagedWithSideStage"; when: root.mode === "stagedWithSideStage"
@@ -521,6 +525,7 @@ FocusScope {
521525 }
522526 }
523527 PropertyAction { target: spreadItem; property: "highlightedIndex"; value: -1 }
528+ PropertyAction { target: floatingFlickable; property: "contentX"; value: 0 }
524529 }
525530 },
526531 Transition {
@@ -775,7 +780,7 @@ FocusScope {
775780 Item {
776781 id: boundariesForWindowPlacement
777782 anchors.fill: parent
778− anchors.topMargin: PanelState.panelHeight
783+ anchors.topMargin: panelState.panelHeight
779784 visible: false
780785 }
781786
@@ -921,7 +926,7 @@ FocusScope {
921926 maximizedTopLeft || maximizedTopRight || maximizedBottomLeft || maximizedBottomRight
922927
923928 readonly property bool minimized: windowState & WindowStateStorage.WindowStateMinimized
924− readonly property bool fullscreen: window.state === Mir.FullscreenState
929+ readonly property bool fullscreen: windowState === WindowStateStorage.WindowStateFullscreen
925930
926931 readonly property bool canBeMaximized: canBeMaximizedHorizontally && canBeMaximizedVertically
927932 readonly property bool canBeMaximizedLeftRight: (maximumWidth == 0 || maximumWidth >= appContainer.width/2) &&
@@ -932,7 +937,10 @@ FocusScope {
932937 readonly property bool canBeMaximizedVertically: maximumHeight == 0 || maximumHeight >= appContainer.height
933938 readonly property alias orientationChangesEnabled: decoratedWindow.orientationChangesEnabled
934939
940+ // TODO drop our own windowType once Mir/Miral/Qtmir gets in sync with ours
935941 property int windowState: WindowStateStorage.WindowStateNormal
942+ property int prevWindowState: WindowStateStorage.WindowStateRestored
943+
936944 property bool animationsEnabled: true
937945 property alias title: decoratedWindow.title
938946 readonly property string appName: model.application ? model.application.name : ""
@@ -987,9 +995,6 @@ FocusScope {
987995 }
988996 priv.updateMainAndSideStageIndexes();
989997 }
990− if (root.mode == "windowed") {
991− appDelegate.restore(true /* animated */, appDelegate.windowState);
992− }
993998 appDelegate.focus = true;
994999 }
9951000
@@ -1039,7 +1044,14 @@ FocusScope {
10391044 } else if (model.window.state === Mir.MaximizedBottomRightState) {
10401045 appDelegate.maximizeBottomRight();
10411046 } else if (model.window.state === Mir.RestoredState) {
1042− appDelegate.restore();
1047+ if (appDelegate.fullscreen && appDelegate.prevWindowState != WindowStateStorage.WindowStateRestored) {
1048+ model.window.requestState(WindowStateStorage.toMirState(appDelegate.prevWindowState));
1049+ } else {
1050+ appDelegate.restore();
1051+ }
1052+ } else if (model.window.state === Mir.FullscreenState) {
1053+ appDelegate.prevWindowState = appDelegate.windowState;
1054+ appDelegate.windowState = WindowStateStorage.WindowStateFullscreen;
10431055 }
10441056 }
10451057 }
@@ -1141,6 +1153,7 @@ FocusScope {
11411153 animationsEnabled = (animated === undefined) || animated;
11421154 windowState = state || WindowStateStorage.WindowStateRestored;
11431155 windowState &= ~WindowStateStorage.WindowStateMinimized; // clear the minimized bit
1156+ prevWindowState = windowState;
11441157 }
11451158
11461159 function playFocusAnimation() {
@@ -1303,7 +1316,7 @@ FocusScope {
13031316 when: (root.mode == "staged" || root.mode == "stagedWithSideStage") && (root.state == "sideStagedRightEdge" || root.state == "stagedRightEdge" || rightEdgeFocusAnimation.running || hidingAnimation.running)
13041317 PropertyChanges {
13051318 target: stagedRightEdgeMaths
1306− progress: Math.max(edgeBarrier.progress, rightEdgeDragArea.draggedProgress)
1319+ progress: Math.max(rightEdgePushProgress, rightEdgeDragArea.draggedProgress)
13071320 }
13081321 PropertyChanges {
13091322 target: appDelegate
@@ -1330,11 +1343,11 @@ FocusScope {
13301343 },
13311344 State {
13321345 name: "windowedRightEdge"
1333− when: root.mode == "windowed" && (root.state == "windowedRightEdge" || rightEdgeFocusAnimation.running || hidingAnimation.running || edgeBarrier.progress > 0)
1346+ when: root.mode == "windowed" && (root.state == "windowedRightEdge" || rightEdgeFocusAnimation.running || hidingAnimation.running || rightEdgePushProgress > 0)
13341347 PropertyChanges {
13351348 target: windowedRightEdgeMaths
13361349 swipeProgress: rightEdgeDragArea.dragging ? rightEdgeDragArea.progress : 0
1337− pushProgress: edgeBarrier.progress
1350+ pushProgress: rightEdgePushProgress
13381351 }
13391352 PropertyChanges {
13401353 target: appDelegate
@@ -1528,11 +1541,12 @@ FocusScope {
15281541 name: "minimized"; when: appDelegate.minimized
15291542 PropertyChanges {
15301543 target: appDelegate
1531− requestedX: -appDelegate.width / 2
15321544 scale: units.gu(5) / appDelegate.width
15331545 opacity: 0;
15341546 visuallyMinimized: true
15351547 visuallyMaximized: false
1548+ x: -appDelegate.width / 2
1549+ y: root.height / 2
15361550 }
15371551 }
15381552 ]
@@ -1548,15 +1562,6 @@ FocusScope {
15481562 to: "staged,stagedWithSideStage"
15491563 UbuntuNumberAnimation { target: appDelegate; properties: "x,y,requestedX,requestedY,requestedWidth,requestedHeight"; duration: priv.animationDuration}
15501564 },
1551− Transition {
1552− to: "minimized"
1553− enabled: appDelegate.animationsEnabled
1554− PropertyAction { target: appDelegate; property: "visuallyMaximized" }
1555− SequentialAnimation {
1556− UbuntuNumberAnimation { target: appDelegate; properties: "requestedX,requestedY,opacity,scale,requestedWidth,requestedHeight" }
1557− PropertyAction { target: appDelegate; property: "visuallyMinimized" }
1558− }
1559− },
15601565 Transition {
15611566 to: "spread"
15621567 // DecoratedWindow wants the scaleToPreviewSize set before enabling scaleToPreview
@@ -1605,6 +1610,31 @@ FocusScope {
16051610 PropertyAction { target: appDelegate; property: "visible" }
16061611 }
16071612 },
1613+ Transition {
1614+ from: ",normal,restored,maximized,maximizedLeft,maximizedRight,maximizedTopLeft,maximizedTopRight,maximizedBottomLeft,maximizedBottomRight,maximizedHorizontally,maximizedVertically,fullscreen"
1615+ to: "minimized"
1616+ SequentialAnimation {
1617+ ScriptAction { script: print("transitioning:", appDelegate.x, appDelegate.y, appDelegate.scale) }
1618+ ScriptAction { script: { fakeRectangle.stop(); } }
1619+ PropertyAction { target: appDelegate; property: "visuallyMaximized" }
1620+ UbuntuNumberAnimation { target: appDelegate; properties: "x,y,scale,opacity"; duration: priv.animationDuration }
1621+ PropertyAction { target: appDelegate; property: "visuallyMinimized" }
1622+ }
1623+ },
1624+ Transition {
1625+ from: "minimized"
1626+ to: ",normal,restored,maximized,maximizedLeft,maximizedRight,maximizedTopLeft,maximizedTopRight,maximizedBottomLeft,maximizedBottomRight,maximizedHorizontally,maximizedVertically,fullscreen"
1627+ SequentialAnimation {
1628+ ScriptAction { script: print("transitioning:", appDelegate.x, appDelegate.y, appDelegate.scale) }
1629+ PropertyAction { target: appDelegate; property: "visuallyMinimized,z" }
1630+ ParallelAnimation {
1631+ UbuntuNumberAnimation { target: appDelegate; properties: "x"; from: -appDelegate.width / 2; duration: priv.animationDuration }
1632+ UbuntuNumberAnimation { target: appDelegate; properties: "y,opacity"; duration: priv.animationDuration }
1633+ UbuntuNumberAnimation { target: appDelegate; properties: "scale"; from: 0; duration: priv.animationDuration }
1634+ }
1635+ PropertyAction { target: appDelegate; property: "visuallyMaximized" }
1636+ }
1637+ },
16081638 Transition {
16091639 id: windowedTransition
16101640 from: ",normal,restored,maximized,maximizedLeft,maximizedRight,maximizedTopLeft,maximizedTopRight,maximizedBottomLeft,maximizedBottomRight,maximizedHorizontally,maximizedVertically,fullscreen,minimized"
@@ -1696,7 +1726,10 @@ FocusScope {
16961726 onDecorationReleased: fakeRectangle.commit();
16971727
16981728 property real angle: 0
1729+ Behavior on angle { enabled: priv.closingIndex >= 0; UbuntuNumberAnimation {} }
16991730 property real itemScale: 1
1731+ Behavior on itemScale { enabled: priv.closingIndex >= 0; UbuntuNumberAnimation {} }
1732+
17001733 transform: [
17011734 Scale {
17021735 origin.x: 0
@@ -1758,7 +1791,6 @@ FocusScope {
17581791 onClicked: {
17591792 spreadItem.highlightedIndex = index;
17601793 if (distance == 0) {
1761− model.window.activate();
17621794 priv.goneToSpread = false;
17631795 }
17641796 }
@@ -1867,30 +1899,6 @@ FocusScope {
18671899 panelState: root.panelState
18681900 }
18691901
1870− EdgeBarrier {
1871− id: edgeBarrier
1872−
1873− // NB: it does its own positioning according to the specified edge
1874− edge: Qt.RightEdge
1875−
1876− onPassed: priv.goneToSpread = true;
1877−
1878− material: Component {
1879− Item {
1880− Rectangle {
1881− width: parent.height
1882− height: parent.width
1883− rotation: 90
1884− anchors.centerIn: parent
1885− gradient: Gradient {
1886− GradientStop { position: 0.0; color: Qt.rgba(0.16,0.16,0.16,0.5)}
1887− GradientStop { position: 1.0; color: Qt.rgba(0.16,0.16,0.16,0)}
1888− }
1889− }
1890− }
1891− }
1892− }
1893−
18941902 PropertyAnimation {
18951903 id: shortRightEdgeSwipeAnimation
18961904 property: "x"