@@ -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,19 @@ 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: parent.height / 3
575+ background: root.background
576+ opacity: 0
577+ visible: opacity > 0
578+ }
579+
566580 Spread {
567581 id: spreadItem
568582 objectName: "spreadItem"
569− anchors.fill: appContainer
583+ anchors { left: parent.left; bottom: parent.bottom; right: parent.right; top: screensAndWorkspaces.bottom }
570584 leftMargin: root.leftMargin
571585 model: root.topLevelSurfaceList
572586 spreadFlickable: floatingFlickable
@@ -575,6 +589,83 @@ FocusScope {
575589 onLeaveSpread: {
576590 priv.goneToSpread = false;
577591 }
592+
593+ FloatingFlickable {
594+ id: floatingFlickable
595+ objectName: "spreadFlickable"
596+ anchors.fill: parent
597+ enabled: false
598+ contentWidth: spreadItem.spreadTotalWidth
599+
600+ function snap(toIndex) {
601+ var delegate = appRepeater.itemAt(toIndex)
602+ var targetContentX = floatingFlickable.contentWidth / spreadItem.totalItemCount * toIndex;
603+ if (targetContentX - floatingFlickable.contentX > spreadItem.rightStackXPos - (spreadItem.spreadItemWidth / 2)) {
604+ var offset = (spreadItem.rightStackXPos - (spreadItem.spreadItemWidth / 2)) - (targetContentX - floatingFlickable.contentX)
605+ snapAnimation.to = floatingFlickable.contentX - offset;
606+ snapAnimation.start();
607+ } else if (targetContentX - floatingFlickable.contentX < spreadItem.leftStackXPos + units.gu(1)) {
608+ var offset = (spreadItem.leftStackXPos + units.gu(1)) - (targetContentX - floatingFlickable.contentX);
609+ snapAnimation.to = floatingFlickable.contentX - offset;
610+ snapAnimation.start();
611+ }
612+ }
613+ UbuntuNumberAnimation {id: snapAnimation; target: floatingFlickable; property: "contentX"}
614+ }
615+
616+ MouseArea {
617+ id: hoverMouseArea
618+ objectName: "hoverMouseArea"
619+ anchors.fill: parent
620+ propagateComposedEvents: true
621+ hoverEnabled: true
622+ enabled: false
623+ visible: enabled
624+
625+ property int scrollAreaWidth: width / 3
626+ property bool progressiveScrollingEnabled: false
627+
628+ onPressed: mouse.accepted = false
629+
630+ onMouseXChanged: {
631+ mouse.accepted = false
632+
633+ if (hoverMouseArea.pressed) {
634+ return;
635+ }
636+
637+ // Find the hovered item and mark it active
638+ for (var i = appRepeater.count - 1; i >= 0; i--) {
639+ var appDelegate = appRepeater.itemAt(i);
640+ var mapped = mapToItem(appDelegate, hoverMouseArea.mouseX, hoverMouseArea.mouseY)
641+ var itemUnder = appDelegate.childAt(mapped.x, mapped.y);
642+ if (itemUnder && (itemUnder.objectName === "dragArea" || itemUnder.objectName === "windowInfoItem" || itemUnder.objectName == "closeMouseArea")) {
643+ spreadItem.highlightedIndex = i;
644+ break;
645+ }
646+ }
647+
648+ if (floatingFlickable.contentWidth > floatingFlickable.width) {
649+ var margins = floatingFlickable.width * 0.05;
650+
651+ if (!progressiveScrollingEnabled && mouseX < floatingFlickable.width - scrollAreaWidth) {
652+ progressiveScrollingEnabled = true
653+ }
654+
655+ // do we need to scroll?
656+ if (mouseX < scrollAreaWidth + margins) {
657+ var progress = Math.min(1, (scrollAreaWidth + margins - mouseX) / (scrollAreaWidth - margins));
658+ var contentX = (1 - progress) * (floatingFlickable.contentWidth - floatingFlickable.width)
659+ floatingFlickable.contentX = Math.max(0, Math.min(floatingFlickable.contentX, contentX))
660+ }
661+ if (mouseX > floatingFlickable.width - scrollAreaWidth && progressiveScrollingEnabled) {
662+ var progress = Math.min(1, (mouseX - (floatingFlickable.width - scrollAreaWidth)) / (scrollAreaWidth - margins))
663+ var contentX = progress * (floatingFlickable.contentWidth - floatingFlickable.width)
664+ floatingFlickable.contentX = Math.min(floatingFlickable.contentWidth - floatingFlickable.width, Math.max(floatingFlickable.contentX, contentX))
665+ }
666+ }
667+ }
668+ }
578669 }
579670
580671 Connections {
@@ -669,10 +760,27 @@ FocusScope {
669760 }
670761 }
671762
763+ MirSurfaceItem {
764+ id: fakeDragItem
765+ property real previewScale: .5
766+ width: implicitWidth * previewScale
767+ height: implicitHeight * previewScale
768+ surfaceWidth: -1
769+ surfaceHeight: -1
770+ opacity: surface != null ? 1 : 0
771+ Behavior on opacity { UbuntuNumberAnimation {} }
772+ visible: opacity > 0
773+
774+ Drag.active: surface != null
775+ Drag.keys: ["application"]
776+
777+ z: 1000
778+ }
779+
672780 Item {
673781 id: boundariesForWindowPlacement
674782 anchors.fill: parent
675− anchors.topMargin: PanelState.panelHeight
783+ anchors.topMargin: panelState.panelHeight
676784 visible: false
677785 }
678786
@@ -704,6 +812,9 @@ FocusScope {
704812 }
705813 z: normalZ
706814
815+ opacity: fakeDragItem.surface == model.window.surface && fakeDragItem.Drag.active ? 0 : 1
816+ Behavior on opacity { UbuntuNumberAnimation {} }
817+
707818 // Normally we want x/y where the surface thinks it is. Width/height of our delegate will
708819 // match what the actual surface size is.
709820 // Don't write to those, they will be set by states
@@ -764,7 +875,7 @@ FocusScope {
764875 target: appDelegate
765876 property: "y"
766877 value: appDelegate.requestedY -
767− Math.min(appDelegate.requestedY - PanelState.panelHeight,
878+ Math.min(appDelegate.requestedY - panelState.panelHeight,
768879 Math.max(0, priv.virtualKeyboardHeight - (appContainer.height - (appDelegate.requestedY + appDelegate.height))))
769880 when: root.oskEnabled && appDelegate.focus && (appDelegate.state == "normal" || appDelegate.state == "restored")
770881 && root.inputMethodRect.height > 0
@@ -1148,7 +1259,7 @@ FocusScope {
11481259 progress: 0
11491260 targetHeight: spreadItem.stackHeight
11501261 targetX: spreadMaths.targetX
1151− startY: appDelegate.fullscreen ? 0 : PanelState.panelHeight
1262+ startY: appDelegate.fullscreen ? 0 : panelState.panelHeight
11521263 targetY: spreadMaths.targetY
11531264 targetAngle: spreadMaths.targetAngle
11541265 targetScale: spreadMaths.targetScale
@@ -1267,9 +1378,9 @@ FocusScope {
12671378 PropertyChanges {
12681379 target: appDelegate
12691380 x: stageMaths.itemX
1270− y: appDelegate.fullscreen ? 0 : PanelState.panelHeight
1381+ y: appDelegate.fullscreen ? 0 : panelState.panelHeight
12711382 requestedWidth: appContainer.width
1272− requestedHeight: appDelegate.fullscreen ? appContainer.height : appContainer.height - PanelState.panelHeight
1383+ requestedHeight: appDelegate.fullscreen ? appContainer.height : appContainer.height - panelState.panelHeight
12731384 visuallyMaximized: true
12741385 visible: appDelegate.x < root.width
12751386 }
@@ -1295,10 +1406,10 @@ FocusScope {
12951406 PropertyChanges {
12961407 target: appDelegate
12971408 x: stageMaths.itemX
1298− y: appDelegate.fullscreen ? 0 : PanelState.panelHeight
1409+ y: appDelegate.fullscreen ? 0 : panelState.panelHeight
12991410 z: stageMaths.itemZ
13001411 requestedWidth: stageMaths.itemWidth
1301− requestedHeight: appDelegate.fullscreen ? appContainer.height : appContainer.height - PanelState.panelHeight
1412+ requestedHeight: appDelegate.fullscreen ? appContainer.height : appContainer.height - panelState.panelHeight
13021413 visuallyMaximized: true
13031414 visible: appDelegate.x < root.width
13041415 }
@@ -1363,9 +1474,9 @@ FocusScope {
13631474 PropertyChanges {
13641475 target: appDelegate
13651476 windowedX: root.leftMargin
1366− windowedY: PanelState.panelHeight
1477+ windowedY: panelState.panelHeight
13671478 windowedWidth: (appContainer.width - root.leftMargin)/2
1368− windowedHeight: appContainer.height - PanelState.panelHeight
1479+ windowedHeight: appContainer.height - panelState.panelHeight
13691480 }
13701481 },
13711482 State {
@@ -1382,9 +1493,9 @@ FocusScope {
13821493 PropertyChanges {
13831494 target: appDelegate
13841495 windowedX: root.leftMargin
1385− windowedY: PanelState.panelHeight
1496+ windowedY: panelState.panelHeight
13861497 windowedWidth: (appContainer.width - root.leftMargin)/2
1387− windowedHeight: (appContainer.height - PanelState.panelHeight)/2
1498+ windowedHeight: (appContainer.height - panelState.panelHeight)/2
13881499 }
13891500 },
13901501 State {
@@ -1401,7 +1512,7 @@ FocusScope {
14011512 PropertyChanges {
14021513 target: appDelegate
14031514 windowedX: root.leftMargin
1404− windowedY: (appContainer.height + PanelState.panelHeight)/2
1515+ windowedY: (appContainer.height + panelState.panelHeight)/2
14051516 windowedWidth: (appContainer.width - root.leftMargin)/2
14061517 windowedHeight: appContainer.height/2
14071518 }
@@ -1423,8 +1534,8 @@ FocusScope {
14231534 State {
14241535 name: "maximizedVertically"; when: appDelegate.maximizedVertically && !appDelegate.minimized
14251536 extend: "normal"
1426− PropertyChanges { target: appDelegate; windowedX: windowedX; windowedY: PanelState.panelHeight;
1427− windowedWidth: windowedWidth; windowedHeight: appContainer.height - PanelState.panelHeight }
1537+ PropertyChanges { target: appDelegate; windowedX: windowedX; windowedY: panelState.panelHeight;
1538+ windowedWidth: windowedWidth; windowedHeight: appContainer.height - panelState.panelHeight }
14281539 },
14291540 State {
14301541 name: "minimized"; when: appDelegate.minimized
@@ -1540,7 +1651,7 @@ FocusScope {
15401651 ]
15411652
15421653 Binding {
1543− target: PanelState
1654+ target: panelState
15441655 property: "decorationsAlwaysVisible"
15451656 value: appDelegate && appDelegate.maximized && touchControls.overlayShown
15461657 }
@@ -1718,12 +1829,15 @@ FocusScope {
17181829 objectName: "closeMouseArea"
17191830 anchors { left: parent.left; top: parent.top; leftMargin: -height / 2; topMargin: -height / 2 + spreadMaths.closeIconOffset }
17201831 readonly property var mousePos: hoverMouseArea.mapToItem(appDelegate, hoverMouseArea.mouseX, hoverMouseArea.mouseY)
1721− visible: !appDelegate.isDash && dragArea.distance == 0
1832+ readonly property bool shown: !appDelegate.isDash && dragArea.distance == 0
17221833 && index == spreadItem.highlightedIndex
17231834 && mousePos.y < (decoratedWindow.height / 3)
17241835 && mousePos.y > -units.gu(4)
17251836 && mousePos.x > -units.gu(4)
17261837 && mousePos.x < (decoratedWindow.width * 2 / 3)
1838+ opacity: shown ? 1 : 0
1839+ visible: opacity > 0
1840+ Behavior on opacity { UbuntuNumberAnimation { duration: UbuntuAnimation.SnapDuration } }
17271841 height: units.gu(6)
17281842 width: height
17291843
@@ -1785,83 +1899,7 @@ FocusScope {
17851899 leftMargin: root.leftMargin
17861900 appContainerWidth: appContainer.width
17871901 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"}
1902+ panelState: root.panelState
18651903 }
18661904
18671905 PropertyAnimation {