@@ -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"
@@ -453,7 +457,7 @@ FocusScope {
453457 PropertyChanges { target: wallpaper; visible: false }
454458 },
455459 State {
456− name: "stagedRightEdge"; when: (rightEdgeDragArea.dragging || edgeBarrier.progress > 0) && root.mode == "staged"
460+ name: "stagedRightEdge"; when: root.spreadEnabled && (rightEdgeDragArea.dragging || rightEdgePushProgress > 0) && root.mode == "staged"
457461 PropertyChanges {
458462 target: blurLayer;
459463 visible: true;
@@ -463,7 +467,7 @@ FocusScope {
463467 }
464468 },
465469 State {
466− name: "sideStagedRightEdge"; when: (rightEdgeDragArea.dragging || edgeBarrier.progress > 0) && root.mode == "stagedWithSideStage"
470+ name: "sideStagedRightEdge"; when: root.spreadEnabled && (rightEdgeDragArea.dragging || rightEdgePushProgress > 0) && root.mode == "stagedWithSideStage"
467471 extend: "stagedRightEdge"
468472 PropertyChanges {
469473 target: sideStage
@@ -472,18 +476,18 @@ FocusScope {
472476 }
473477 },
474478 State {
475− name: "windowedRightEdge"; when: (rightEdgeDragArea.dragging || edgeBarrier.progress > 0) && root.mode == "windowed"
479+ name: "windowedRightEdge"; when: root.spreadEnabled && (rightEdgeDragArea.dragging || rightEdgePushProgress > 0) && root.mode == "windowed"
476480 PropertyChanges {
477481 target: blurLayer;
478482 visible: true
479483 blurRadius: 32
480484 brightness: .65
481− opacity: MathUtils.linearAnimation(spreadItem.rightEdgeBreakPoint, 1, 0, 1, Math.max(rightEdgeDragArea.dragging ? rightEdgeDragArea.progress : 0, edgeBarrier.progress))
485+ opacity: MathUtils.linearAnimation(spreadItem.rightEdgeBreakPoint, 1, 0, 1, Math.max(rightEdgeDragArea.dragging ? rightEdgeDragArea.progress : 0, rightEdgePushProgress))
482486 }
483487 },
484488 State {
485489 name: "staged"; when: root.mode === "staged"
486− PropertyChanges { target: wallpaper; visible: false }
490+ PropertyChanges { target: wallpaper; visible: !priv.focusedAppDelegate || priv.focusedAppDelegate.x !== 0 }
487491 },
488492 State {
489493 name: "stagedWithSideStage"; when: root.mode === "stagedWithSideStage"
@@ -503,7 +507,6 @@ FocusScope {
503507 Transition {
504508 to: "spread"
505509 PropertyAction { target: spreadItem; property: "highlightedIndex"; value: appRepeater.count > 1 ? 1 : 0 }
506− PropertyAction { target: floatingFlickable; property: "contentX"; value: 0 }
507510 },
508511 Transition {
509512 from: "spread"
@@ -518,6 +521,7 @@ FocusScope {
518521 }
519522 }
520523 PropertyAction { target: spreadItem; property: "highlightedIndex"; value: -1 }
524+ PropertyAction { target: floatingFlickable; property: "contentX"; value: 0 }
521525 }
522526 },
523527 Transition {
@@ -669,7 +673,7 @@ FocusScope {
669673 Item {
670674 id: boundariesForWindowPlacement
671675 anchors.fill: parent
672− anchors.topMargin: PanelState.panelHeight
676+ anchors.topMargin: panelState.panelHeight
673677 visible: false
674678 }
675679
@@ -812,7 +816,7 @@ FocusScope {
812816 maximizedTopLeft || maximizedTopRight || maximizedBottomLeft || maximizedBottomRight
813817
814818 readonly property bool minimized: windowState & WindowStateStorage.WindowStateMinimized
815− readonly property bool fullscreen: window.state === Mir.FullscreenState
819+ readonly property bool fullscreen: windowState === WindowStateStorage.WindowStateFullscreen
816820
817821 readonly property bool canBeMaximized: canBeMaximizedHorizontally && canBeMaximizedVertically
818822 readonly property bool canBeMaximizedLeftRight: (maximumWidth == 0 || maximumWidth >= appContainer.width/2) &&
@@ -823,7 +827,10 @@ FocusScope {
823827 readonly property bool canBeMaximizedVertically: maximumHeight == 0 || maximumHeight >= appContainer.height
824828 readonly property alias orientationChangesEnabled: decoratedWindow.orientationChangesEnabled
825829
830+ // TODO drop our own windowType once Mir/Miral/Qtmir gets in sync with ours
826831 property int windowState: WindowStateStorage.WindowStateNormal
832+ property int prevWindowState: WindowStateStorage.WindowStateRestored
833+
827834 property bool animationsEnabled: true
828835 property alias title: decoratedWindow.title
829836 readonly property string appName: model.application ? model.application.name : ""
@@ -878,9 +885,6 @@ FocusScope {
878885 }
879886 priv.updateMainAndSideStageIndexes();
880887 }
881− if (root.mode == "windowed") {
882− appDelegate.restore(true /* animated */, appDelegate.windowState);
883− }
884888 appDelegate.focus = true;
885889 }
886890
@@ -930,7 +934,14 @@ FocusScope {
930934 } else if (model.window.state === Mir.MaximizedBottomRightState) {
931935 appDelegate.maximizeBottomRight();
932936 } else if (model.window.state === Mir.RestoredState) {
933− appDelegate.restore();
937+ if (appDelegate.fullscreen && appDelegate.prevWindowState != WindowStateStorage.WindowStateRestored) {
938+ model.window.requestState(WindowStateStorage.toMirState(appDelegate.prevWindowState));
939+ } else {
940+ appDelegate.restore();
941+ }
942+ } else if (model.window.state === Mir.FullscreenState) {
943+ appDelegate.prevWindowState = appDelegate.windowState;
944+ appDelegate.windowState = WindowStateStorage.WindowStateFullscreen;
934945 }
935946 }
936947 }
@@ -1032,6 +1043,7 @@ FocusScope {
10321043 animationsEnabled = (animated === undefined) || animated;
10331044 windowState = state || WindowStateStorage.WindowStateRestored;
10341045 windowState &= ~WindowStateStorage.WindowStateMinimized; // clear the minimized bit
1046+ prevWindowState = windowState;
10351047 }
10361048
10371049 function playFocusAnimation() {
@@ -1194,7 +1206,7 @@ FocusScope {
11941206 when: (root.mode == "staged" || root.mode == "stagedWithSideStage") && (root.state == "sideStagedRightEdge" || root.state == "stagedRightEdge" || rightEdgeFocusAnimation.running || hidingAnimation.running)
11951207 PropertyChanges {
11961208 target: stagedRightEdgeMaths
1197− progress: Math.max(edgeBarrier.progress, rightEdgeDragArea.draggedProgress)
1209+ progress: Math.max(rightEdgePushProgress, rightEdgeDragArea.draggedProgress)
11981210 }
11991211 PropertyChanges {
12001212 target: appDelegate
@@ -1221,11 +1233,11 @@ FocusScope {
12211233 },
12221234 State {
12231235 name: "windowedRightEdge"
1224− when: root.mode == "windowed" && (root.state == "windowedRightEdge" || rightEdgeFocusAnimation.running || hidingAnimation.running || edgeBarrier.progress > 0)
1236+ when: root.mode == "windowed" && (root.state == "windowedRightEdge" || rightEdgeFocusAnimation.running || hidingAnimation.running || rightEdgePushProgress > 0)
12251237 PropertyChanges {
12261238 target: windowedRightEdgeMaths
12271239 swipeProgress: rightEdgeDragArea.dragging ? rightEdgeDragArea.progress : 0
1228− pushProgress: edgeBarrier.progress
1240+ pushProgress: rightEdgePushProgress
12291241 }
12301242 PropertyChanges {
12311243 target: appDelegate
@@ -1419,11 +1431,12 @@ FocusScope {
14191431 name: "minimized"; when: appDelegate.minimized
14201432 PropertyChanges {
14211433 target: appDelegate
1422− requestedX: -appDelegate.width / 2
14231434 scale: units.gu(5) / appDelegate.width
14241435 opacity: 0;
14251436 visuallyMinimized: true
14261437 visuallyMaximized: false
1438+ x: -appDelegate.width / 2
1439+ y: root.height / 2
14271440 }
14281441 }
14291442 ]
@@ -1439,15 +1452,6 @@ FocusScope {
14391452 to: "staged,stagedWithSideStage"
14401453 UbuntuNumberAnimation { target: appDelegate; properties: "x,y,requestedX,requestedY,requestedWidth,requestedHeight"; duration: priv.animationDuration}
14411454 },
1442− Transition {
1443− to: "minimized"
1444− enabled: appDelegate.animationsEnabled
1445− PropertyAction { target: appDelegate; property: "visuallyMaximized" }
1446− SequentialAnimation {
1447− UbuntuNumberAnimation { target: appDelegate; properties: "requestedX,requestedY,opacity,scale,requestedWidth,requestedHeight" }
1448− PropertyAction { target: appDelegate; property: "visuallyMinimized" }
1449− }
1450− },
14511455 Transition {
14521456 to: "spread"
14531457 // DecoratedWindow wants the scaleToPreviewSize set before enabling scaleToPreview
@@ -1496,6 +1500,31 @@ FocusScope {
14961500 PropertyAction { target: appDelegate; property: "visible" }
14971501 }
14981502 },
1503+ Transition {
1504+ from: ",normal,restored,maximized,maximizedLeft,maximizedRight,maximizedTopLeft,maximizedTopRight,maximizedBottomLeft,maximizedBottomRight,maximizedHorizontally,maximizedVertically,fullscreen"
1505+ to: "minimized"
1506+ SequentialAnimation {
1507+ ScriptAction { script: print("transitioning:", appDelegate.x, appDelegate.y, appDelegate.scale) }
1508+ ScriptAction { script: { fakeRectangle.stop(); } }
1509+ PropertyAction { target: appDelegate; property: "visuallyMaximized" }
1510+ UbuntuNumberAnimation { target: appDelegate; properties: "x,y,scale,opacity"; duration: priv.animationDuration }
1511+ PropertyAction { target: appDelegate; property: "visuallyMinimized" }
1512+ }
1513+ },
1514+ Transition {
1515+ from: "minimized"
1516+ to: ",normal,restored,maximized,maximizedLeft,maximizedRight,maximizedTopLeft,maximizedTopRight,maximizedBottomLeft,maximizedBottomRight,maximizedHorizontally,maximizedVertically,fullscreen"
1517+ SequentialAnimation {
1518+ ScriptAction { script: print("transitioning:", appDelegate.x, appDelegate.y, appDelegate.scale) }
1519+ PropertyAction { target: appDelegate; property: "visuallyMinimized,z" }
1520+ ParallelAnimation {
1521+ UbuntuNumberAnimation { target: appDelegate; properties: "x"; from: -appDelegate.width / 2; duration: priv.animationDuration }
1522+ UbuntuNumberAnimation { target: appDelegate; properties: "y,opacity"; duration: priv.animationDuration }
1523+ UbuntuNumberAnimation { target: appDelegate; properties: "scale"; from: 0; duration: priv.animationDuration }
1524+ }
1525+ PropertyAction { target: appDelegate; property: "visuallyMaximized" }
1526+ }
1527+ },
14991528 Transition {
15001529 id: windowedTransition
15011530 from: ",normal,restored,maximized,maximizedLeft,maximizedRight,maximizedTopLeft,maximizedTopRight,maximizedBottomLeft,maximizedBottomRight,maximizedHorizontally,maximizedVertically,fullscreen,minimized"
@@ -1587,7 +1616,10 @@ FocusScope {
15871616 onDecorationReleased: fakeRectangle.commit();
15881617
15891618 property real angle: 0
1619+ Behavior on angle { enabled: priv.closingIndex >= 0; UbuntuNumberAnimation {} }
15901620 property real itemScale: 1
1621+ Behavior on itemScale { enabled: priv.closingIndex >= 0; UbuntuNumberAnimation {} }
1622+
15911623 transform: [
15921624 Scale {
15931625 origin.x: 0
@@ -1649,7 +1681,6 @@ FocusScope {
16491681 onClicked: {
16501682 spreadItem.highlightedIndex = index;
16511683 if (distance == 0) {
1652− model.window.activate();
16531684 priv.goneToSpread = false;
16541685 }
16551686 }
@@ -1758,30 +1789,6 @@ FocusScope {
17581789 panelState: root.panelState
17591790 }
17601791
1761− EdgeBarrier {
1762− id: edgeBarrier
1763−
1764− // NB: it does its own positioning according to the specified edge
1765− edge: Qt.RightEdge
1766−
1767− onPassed: priv.goneToSpread = true;
1768−
1769− material: Component {
1770− Item {
1771− Rectangle {
1772− width: parent.height
1773− height: parent.width
1774− rotation: 90
1775− anchors.centerIn: parent
1776− gradient: Gradient {
1777− GradientStop { position: 0.0; color: Qt.rgba(0.16,0.16,0.16,0.5)}
1778− GradientStop { position: 1.0; color: Qt.rgba(0.16,0.16,0.16,0)}
1779− }
1780− }
1781− }
1782− }
1783− }
1784−
17851792 MouseArea {
17861793 id: hoverMouseArea
17871794 objectName: "hoverMouseArea"
@@ -1848,11 +1855,11 @@ FocusScope {
18481855 var targetContentX = floatingFlickable.contentWidth / spreadItem.totalItemCount * toIndex;
18491856 if (targetContentX - floatingFlickable.contentX > spreadItem.rightStackXPos - (spreadItem.spreadItemWidth / 2)) {
18501857 var offset = (spreadItem.rightStackXPos - (spreadItem.spreadItemWidth / 2)) - (targetContentX - floatingFlickable.contentX)
1851− snapAnimation.to = floatingFlickable.contentX - offset;
1858+ snapAnimation.to = Math.max(0, floatingFlickable.contentX - offset);
18521859 snapAnimation.start();
18531860 } else if (targetContentX - floatingFlickable.contentX < spreadItem.leftStackXPos + units.gu(1)) {
18541861 var offset = (spreadItem.leftStackXPos + units.gu(1)) - (targetContentX - floatingFlickable.contentX);
1855− snapAnimation.to = floatingFlickable.contentX - offset;
1862+ snapAnimation.to = Math.max(0, floatingFlickable.contentX - offset);
18561863 snapAnimation.start();
18571864 }
18581865 }