@@ -47,6 +47,7 @@ FocusScope {
4747 property bool oskEnabled: false
4848 property rect inputMethodRect
4949 property real rightEdgePushProgress: 0
50+ property PanelState panelState
5051
5152 // Configuration
5253 property string mode: "staged"
@@ -349,23 +350,23 @@ FocusScope {
349350 readonly property real virtualKeyboardHeight: root.inputMethodRect.height
350351 }
351352
352− Component.onCompleted: priv.updateMainAndSideStageIndexes();
353+ Component.onCompleted: {priv.updateMainAndSideStageIndexes(); print("size", root.width, root.height)}
353354
354355 Connections {
355− target: PanelState
356+ target: panelState
356357 onCloseClicked: { if (priv.focusedAppDelegate) { priv.focusedAppDelegate.close(); } }
357358 onMinimizeClicked: { if (priv.focusedAppDelegate) { priv.focusedAppDelegate.requestMinimize(); } }
358359 onRestoreClicked: { if (priv.focusedAppDelegate) { priv.focusedAppDelegate.requestRestore(); } }
359360 }
360361
361362 Binding {
362− target: PanelState
363+ target: panelState
363364 property: "decorationsVisible"
364365 value: priv.focusedAppDelegate !== null && priv.focusedAppDelegate.maximized // FIXME for Locally integrated menus
365366 }
366367
367368 Binding {
368− target: PanelState
369+ target: panelState
369370 property: "title"
370371 value: {
371372 if (priv.focusedAppDelegate !== null) {
@@ -380,7 +381,7 @@ FocusScope {
380381 }
381382
382383 Binding {
383− target: PanelState
384+ target: panelState
384385 property: "focusedPersistentSurfaceId"
385386 value: {
386387 if (priv.focusedAppDelegate !== null) {
@@ -394,21 +395,21 @@ FocusScope {
394395 }
395396
396397 Binding {
397− target: PanelState
398+ target: panelState
398399 property: "dropShadow"
399400 value: priv.focusedAppDelegate && !priv.focusedAppDelegate.maximized && priv.foregroundMaximizedAppDelegate !== null && mode == "windowed"
400401 }
401402
402403 Binding {
403− target: PanelState
404+ target: panelState
404405 property: "closeButtonShown"
405406 value: priv.focusedAppDelegate && priv.focusedAppDelegate.maximized && !priv.focusedAppDelegate.isDash
406407 }
407408
408409 Component.onDestruction: {
409− PanelState.title = "";
410− PanelState.decorationsVisible = false;
411− PanelState.dropShadow = false;
410+ panelState.title = "";
411+ panelState.decorationsVisible = false;
412+ panelState.dropShadow = false;
412413 }
413414
414415 Instantiator {
@@ -454,6 +455,7 @@ FocusScope {
454455 PropertyChanges { target: cancelSpreadMouseArea; enabled: true }
455456 PropertyChanges { target: blurLayer; visible: true; blurRadius: 32; brightness: .65; opacity: 1 }
456457 PropertyChanges { target: wallpaper; visible: false }
458+ PropertyChanges { target: screensAndWorkspaces; opacity: 1 }
457459 },
458460 State {
459461 name: "stagedRightEdge"; when: root.spreadEnabled && (rightEdgeDragArea.dragging || rightEdgePushProgress > 0) && root.mode == "staged"
@@ -502,10 +504,13 @@ FocusScope {
502504 from: "stagedRightEdge,sideStagedRightEdge,windowedRightEdge"; to: "spread"
503505 PropertyAction { target: spreadItem; property: "highlightedIndex"; value: -1 }
504506 PropertyAnimation { target: blurLayer; properties: "brightness,blurRadius"; duration: priv.animationDuration }
507+ UbuntuNumberAnimation { target: screensAndWorkspaces; property: "opacity"; duration: priv.animationDuration }
505508 },
506509 Transition {
507510 to: "spread"
508511 PropertyAction { target: spreadItem; property: "highlightedIndex"; value: appRepeater.count > 1 ? 1 : 0 }
512+ PropertyAction { target: floatingFlickable; property: "contentX"; value: 0 }
513+ UbuntuNumberAnimation { target: screensAndWorkspaces; property: "opacity"; duration: priv.animationDuration }
509514 },
510515 Transition {
511516 from: "spread"
@@ -563,10 +568,21 @@ FocusScope {
563568 visible: false
564569 }
565570
571+ ScreensAndWorkspaces {
572+ id: screensAndWorkspaces
573+ anchors { left: parent.left; top: parent.top; right: parent.right; leftMargin: root.leftMargin }
574+ height: Math.max(units.gu(35), parent.height * .4)
575+ background: root.background
576+ opacity: 0
577+ visible: opacity > 0
578+
579+ onCloseSpread: priv.goneToSpread = false;
580+ }
581+
566582 Spread {
567583 id: spreadItem
568584 objectName: "spreadItem"
569− anchors.fill: appContainer
585+ anchors { left: parent.left; bottom: parent.bottom; right: parent.right; top: screensAndWorkspaces.bottom }
570586 leftMargin: root.leftMargin
571587 model: root.topLevelSurfaceList
572588 spreadFlickable: floatingFlickable
@@ -575,6 +591,83 @@ FocusScope {
575591 onLeaveSpread: {
576592 priv.goneToSpread = false;
577593 }
594+
595+ FloatingFlickable {
596+ id: floatingFlickable
597+ objectName: "spreadFlickable"
598+ anchors.fill: parent
599+ enabled: false
600+ contentWidth: spreadItem.spreadTotalWidth
601+
602+ function snap(toIndex) {
603+ var delegate = appRepeater.itemAt(toIndex)
604+ var targetContentX = floatingFlickable.contentWidth / spreadItem.totalItemCount * toIndex;
605+ if (targetContentX - floatingFlickable.contentX > spreadItem.rightStackXPos - (spreadItem.spreadItemWidth / 2)) {
606+ var offset = (spreadItem.rightStackXPos - (spreadItem.spreadItemWidth / 2)) - (targetContentX - floatingFlickable.contentX)
607+ snapAnimation.to = floatingFlickable.contentX - offset;
608+ snapAnimation.start();
609+ } else if (targetContentX - floatingFlickable.contentX < spreadItem.leftStackXPos + units.gu(1)) {
610+ var offset = (spreadItem.leftStackXPos + units.gu(1)) - (targetContentX - floatingFlickable.contentX);
611+ snapAnimation.to = floatingFlickable.contentX - offset;
612+ snapAnimation.start();
613+ }
614+ }
615+ UbuntuNumberAnimation {id: snapAnimation; target: floatingFlickable; property: "contentX"}
616+ }
617+
618+ MouseArea {
619+ id: hoverMouseArea
620+ objectName: "hoverMouseArea"
621+ anchors.fill: parent
622+ propagateComposedEvents: true
623+ hoverEnabled: true
624+ enabled: false
625+ visible: enabled
626+
627+ property int scrollAreaWidth: width / 3
628+ property bool progressiveScrollingEnabled: false
629+
630+ onPressed: mouse.accepted = false
631+
632+ onMouseXChanged: {
633+ mouse.accepted = false
634+
635+ if (hoverMouseArea.pressed) {
636+ return;
637+ }
638+
639+ // Find the hovered item and mark it active
640+ for (var i = appRepeater.count - 1; i >= 0; i--) {
641+ var appDelegate = appRepeater.itemAt(i);
642+ var mapped = mapToItem(appDelegate, hoverMouseArea.mouseX, hoverMouseArea.mouseY)
643+ var itemUnder = appDelegate.childAt(mapped.x, mapped.y);
644+ if (itemUnder && (itemUnder.objectName === "dragArea" || itemUnder.objectName === "windowInfoItem" || itemUnder.objectName == "closeMouseArea")) {
645+ spreadItem.highlightedIndex = i;
646+ break;
647+ }
648+ }
649+
650+ if (floatingFlickable.contentWidth > floatingFlickable.width) {
651+ var margins = floatingFlickable.width * 0.05;
652+
653+ if (!progressiveScrollingEnabled && mouseX < floatingFlickable.width - scrollAreaWidth) {
654+ progressiveScrollingEnabled = true
655+ }
656+
657+ // do we need to scroll?
658+ if (mouseX < scrollAreaWidth + margins) {
659+ var progress = Math.min(1, (scrollAreaWidth + margins - mouseX) / (scrollAreaWidth - margins));
660+ var contentX = (1 - progress) * (floatingFlickable.contentWidth - floatingFlickable.width)
661+ floatingFlickable.contentX = Math.max(0, Math.min(floatingFlickable.contentX, contentX))
662+ }
663+ if (mouseX > floatingFlickable.width - scrollAreaWidth && progressiveScrollingEnabled) {
664+ var progress = Math.min(1, (mouseX - (floatingFlickable.width - scrollAreaWidth)) / (scrollAreaWidth - margins))
665+ var contentX = progress * (floatingFlickable.contentWidth - floatingFlickable.width)
666+ floatingFlickable.contentX = Math.min(floatingFlickable.contentWidth - floatingFlickable.width, Math.max(floatingFlickable.contentX, contentX))
667+ }
668+ }
669+ }
670+ }
578671 }
579672
580673 Connections {
@@ -669,10 +762,28 @@ FocusScope {
669762 }
670763 }
671764
765+ MirSurfaceItem {
766+ id: fakeDragItem
767+ property real previewScale: .5
768+ height: (screensAndWorkspaces.height - units.gu(8)) / 2
769+ // w : h = iw : ih
770+ width: implicitWidth * height / implicitHeight
771+ surfaceWidth: -1
772+ surfaceHeight: -1
773+ opacity: surface != null ? 1 : 0
774+ Behavior on opacity { UbuntuNumberAnimation {} }
775+ visible: opacity > 0
776+
777+ Drag.active: surface != null
778+ Drag.keys: ["application"]
779+
780+ z: 1000
781+ }
782+
672783 Item {
673784 id: boundariesForWindowPlacement
674785 anchors.fill: parent
675− anchors.topMargin: PanelState.panelHeight
786+ anchors.topMargin: panelState.panelHeight
676787 visible: false
677788 }
678789
@@ -704,6 +815,9 @@ FocusScope {
704815 }
705816 z: normalZ
706817
818+ opacity: fakeDragItem.surface == model.window.surface && fakeDragItem.Drag.active ? 0 : 1
819+ Behavior on opacity { UbuntuNumberAnimation {} }
820+
707821 // Normally we want x/y where the surface thinks it is. Width/height of our delegate will
708822 // match what the actual surface size is.
709823 // Don't write to those, they will be set by states
@@ -764,7 +878,7 @@ FocusScope {
764878 target: appDelegate
765879 property: "y"
766880 value: appDelegate.requestedY -
767− Math.min(appDelegate.requestedY - PanelState.panelHeight,
881+ Math.min(appDelegate.requestedY - panelState.panelHeight,
768882 Math.max(0, priv.virtualKeyboardHeight - (appContainer.height - (appDelegate.requestedY + appDelegate.height))))
769883 when: root.oskEnabled && appDelegate.focus && (appDelegate.state == "normal" || appDelegate.state == "restored")
770884 && root.inputMethodRect.height > 0
@@ -876,7 +990,6 @@ FocusScope {
876990 function claimFocus() {
877991 if (root.state == "spread") {
878992 spreadItem.highlightedIndex = index
879− priv.goneToSpread = false;
880993 }
881994 if (root.mode == "stagedWithSideStage") {
882995 if (appDelegate.stage == ApplicationInfoInterface.SideStage && !sideStage.shown) {
@@ -1148,7 +1261,7 @@ FocusScope {
11481261 progress: 0
11491262 targetHeight: spreadItem.stackHeight
11501263 targetX: spreadMaths.targetX
1151− startY: appDelegate.fullscreen ? 0 : PanelState.panelHeight
1264+ startY: appDelegate.fullscreen ? 0 : panelState.panelHeight
11521265 targetY: spreadMaths.targetY
11531266 targetAngle: spreadMaths.targetAngle
11541267 targetScale: spreadMaths.targetScale
@@ -1267,9 +1380,9 @@ FocusScope {
12671380 PropertyChanges {
12681381 target: appDelegate
12691382 x: stageMaths.itemX
1270− y: appDelegate.fullscreen ? 0 : PanelState.panelHeight
1383+ y: appDelegate.fullscreen ? 0 : panelState.panelHeight
12711384 requestedWidth: appContainer.width
1272− requestedHeight: appDelegate.fullscreen ? appContainer.height : appContainer.height - PanelState.panelHeight
1385+ requestedHeight: appDelegate.fullscreen ? appContainer.height : appContainer.height - panelState.panelHeight
12731386 visuallyMaximized: true
12741387 visible: appDelegate.x < root.width
12751388 }
@@ -1295,10 +1408,10 @@ FocusScope {
12951408 PropertyChanges {
12961409 target: appDelegate
12971410 x: stageMaths.itemX
1298− y: appDelegate.fullscreen ? 0 : PanelState.panelHeight
1411+ y: appDelegate.fullscreen ? 0 : panelState.panelHeight
12991412 z: stageMaths.itemZ
13001413 requestedWidth: stageMaths.itemWidth
1301− requestedHeight: appDelegate.fullscreen ? appContainer.height : appContainer.height - PanelState.panelHeight
1414+ requestedHeight: appDelegate.fullscreen ? appContainer.height : appContainer.height - panelState.panelHeight
13021415 visuallyMaximized: true
13031416 visible: appDelegate.x < root.width
13041417 }
@@ -1363,9 +1476,9 @@ FocusScope {
13631476 PropertyChanges {
13641477 target: appDelegate
13651478 windowedX: root.leftMargin
1366− windowedY: PanelState.panelHeight
1479+ windowedY: panelState.panelHeight
13671480 windowedWidth: (appContainer.width - root.leftMargin)/2
1368− windowedHeight: appContainer.height - PanelState.panelHeight
1481+ windowedHeight: appContainer.height - panelState.panelHeight
13691482 }
13701483 },
13711484 State {
@@ -1382,9 +1495,9 @@ FocusScope {
13821495 PropertyChanges {
13831496 target: appDelegate
13841497 windowedX: root.leftMargin
1385− windowedY: PanelState.panelHeight
1498+ windowedY: panelState.panelHeight
13861499 windowedWidth: (appContainer.width - root.leftMargin)/2
1387− windowedHeight: (appContainer.height - PanelState.panelHeight)/2
1500+ windowedHeight: (appContainer.height - panelState.panelHeight)/2
13881501 }
13891502 },
13901503 State {
@@ -1401,7 +1514,7 @@ FocusScope {
14011514 PropertyChanges {
14021515 target: appDelegate
14031516 windowedX: root.leftMargin
1404− windowedY: (appContainer.height + PanelState.panelHeight)/2
1517+ windowedY: (appContainer.height + panelState.panelHeight)/2
14051518 windowedWidth: (appContainer.width - root.leftMargin)/2
14061519 windowedHeight: appContainer.height/2
14071520 }
@@ -1423,8 +1536,8 @@ FocusScope {
14231536 State {
14241537 name: "maximizedVertically"; when: appDelegate.maximizedVertically && !appDelegate.minimized
14251538 extend: "normal"
1426− PropertyChanges { target: appDelegate; windowedX: windowedX; windowedY: PanelState.panelHeight;
1427− windowedWidth: windowedWidth; windowedHeight: appContainer.height - PanelState.panelHeight }
1539+ PropertyChanges { target: appDelegate; windowedX: windowedX; windowedY: panelState.panelHeight;
1540+ windowedWidth: windowedWidth; windowedHeight: appContainer.height - panelState.panelHeight }
14281541 },
14291542 State {
14301543 name: "minimized"; when: appDelegate.minimized
@@ -1540,7 +1653,7 @@ FocusScope {
15401653 ]
15411654
15421655 Binding {
1543− target: PanelState
1656+ target: panelState
15441657 property: "decorationsAlwaysVisible"
15451658 value: appDelegate && appDelegate.maximized && touchControls.overlayShown
15461659 }
@@ -1718,12 +1831,15 @@ FocusScope {
17181831 objectName: "closeMouseArea"
17191832 anchors { left: parent.left; top: parent.top; leftMargin: -height / 2; topMargin: -height / 2 + spreadMaths.closeIconOffset }
17201833 readonly property var mousePos: hoverMouseArea.mapToItem(appDelegate, hoverMouseArea.mouseX, hoverMouseArea.mouseY)
1721− visible: !appDelegate.isDash && dragArea.distance == 0
1834+ readonly property bool shown: !appDelegate.isDash && dragArea.distance == 0
17221835 && index == spreadItem.highlightedIndex
17231836 && mousePos.y < (decoratedWindow.height / 3)
17241837 && mousePos.y > -units.gu(4)
17251838 && mousePos.x > -units.gu(4)
17261839 && mousePos.x < (decoratedWindow.width * 2 / 3)
1840+ opacity: shown ? 1 : 0
1841+ visible: opacity > 0
1842+ Behavior on opacity { UbuntuNumberAnimation { duration: UbuntuAnimation.SnapDuration } }
17271843 height: units.gu(6)
17281844 width: height
17291845
@@ -1785,83 +1901,7 @@ FocusScope {
17851901 leftMargin: root.leftMargin
17861902 appContainerWidth: appContainer.width
17871903 appContainerHeight: appContainer.height
1788− }
1789−
1790− MouseArea {
1791− id: hoverMouseArea
1792− objectName: "hoverMouseArea"
1793− anchors.fill: appContainer
1794− propagateComposedEvents: true
1795− hoverEnabled: true
1796− enabled: false
1797− visible: enabled
1798−
1799− property int scrollAreaWidth: width / 3
1800− property bool progressiveScrollingEnabled: false
1801−
1802− onMouseXChanged: {
1803− mouse.accepted = false
1804−
1805− if (hoverMouseArea.pressed) {
1806− return;
1807− }
1808−
1809− // Find the hovered item and mark it active
1810− for (var i = appRepeater.count - 1; i >= 0; i--) {
1811− var appDelegate = appRepeater.itemAt(i);
1812− var mapped = mapToItem(appDelegate, hoverMouseArea.mouseX, hoverMouseArea.mouseY)
1813− var itemUnder = appDelegate.childAt(mapped.x, mapped.y);
1814− if (itemUnder && (itemUnder.objectName === "dragArea" || itemUnder.objectName === "windowInfoItem" || itemUnder.objectName == "closeMouseArea")) {
1815− spreadItem.highlightedIndex = i;
1816− break;
1817− }
1818− }
1819−
1820− if (floatingFlickable.contentWidth > floatingFlickable.width) {
1821− var margins = floatingFlickable.width * 0.05;
1822−
1823− if (!progressiveScrollingEnabled && mouseX < floatingFlickable.width - scrollAreaWidth) {
1824− progressiveScrollingEnabled = true
1825− }
1826−
1827− // do we need to scroll?
1828− if (mouseX < scrollAreaWidth + margins) {
1829− var progress = Math.min(1, (scrollAreaWidth + margins - mouseX) / (scrollAreaWidth - margins));
1830− var contentX = (1 - progress) * (floatingFlickable.contentWidth - floatingFlickable.width)
1831− floatingFlickable.contentX = Math.max(0, Math.min(floatingFlickable.contentX, contentX))
1832− }
1833− if (mouseX > floatingFlickable.width - scrollAreaWidth && progressiveScrollingEnabled) {
1834− var progress = Math.min(1, (mouseX - (floatingFlickable.width - scrollAreaWidth)) / (scrollAreaWidth - margins))
1835− var contentX = progress * (floatingFlickable.contentWidth - floatingFlickable.width)
1836− floatingFlickable.contentX = Math.min(floatingFlickable.contentWidth - floatingFlickable.width, Math.max(floatingFlickable.contentX, contentX))
1837− }
1838− }
1839− }
1840−
1841− onPressed: mouse.accepted = false
1842− }
1843−
1844− FloatingFlickable {
1845− id: floatingFlickable
1846− objectName: "spreadFlickable"
1847− anchors.fill: appContainer
1848− enabled: false
1849− contentWidth: spreadItem.spreadTotalWidth
1850−
1851− function snap(toIndex) {
1852− var delegate = appRepeater.itemAt(toIndex)
1853− var targetContentX = floatingFlickable.contentWidth / spreadItem.totalItemCount * toIndex;
1854− if (targetContentX - floatingFlickable.contentX > spreadItem.rightStackXPos - (spreadItem.spreadItemWidth / 2)) {
1855− var offset = (spreadItem.rightStackXPos - (spreadItem.spreadItemWidth / 2)) - (targetContentX - floatingFlickable.contentX)
1856− snapAnimation.to = Math.max(0, floatingFlickable.contentX - offset);
1857− snapAnimation.start();
1858− } else if (targetContentX - floatingFlickable.contentX < spreadItem.leftStackXPos + units.gu(1)) {
1859− var offset = (spreadItem.leftStackXPos + units.gu(1)) - (targetContentX - floatingFlickable.contentX);
1860− snapAnimation.to = Math.max(0, floatingFlickable.contentX - offset);
1861− snapAnimation.start();
1862− }
1863− }
1864− UbuntuNumberAnimation {id: snapAnimation; target: floatingFlickable; property: "contentX"}
1904+ panelState: root.panelState
18651905 }
18661906
18671907 PropertyAnimation {