@@ -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"
@@ -224,6 +225,23 @@ FocusScope {
224225 active: priv.focusedAppDelegate !== null
225226 }
226227
228+ GlobalShortcut {
229+ id: showWorkspaceSwitcherShortcutLeft
230+ shortcut: Qt.AltModifier|Qt.ControlModifier|Qt.Key_Left
231+ active: !workspaceSwitcher.active
232+ onTriggered: {
233+ workspaceSwitcher.showLeft()
234+ }
235+ }
236+ GlobalShortcut {
237+ id: showWorkspaceSwitcherShortcutRight
238+ shortcut: Qt.AltModifier|Qt.ControlModifier|Qt.Key_Right
239+ active: !workspaceSwitcher.active
240+ onTriggered: {
241+ workspaceSwitcher.showRight()
242+ }
243+ }
244+
227245 QtObject {
228246 id: priv
229247 objectName: "DesktopStagePrivate"
@@ -349,23 +367,23 @@ FocusScope {
349367 readonly property real virtualKeyboardHeight: root.inputMethodRect.height
350368 }
351369
352− Component.onCompleted: priv.updateMainAndSideStageIndexes();
370+ Component.onCompleted: priv.updateMainAndSideStageIndexes()
353371
354372 Connections {
355− target: PanelState
373+ target: panelState
356374 onCloseClicked: { if (priv.focusedAppDelegate) { priv.focusedAppDelegate.close(); } }
357375 onMinimizeClicked: { if (priv.focusedAppDelegate) { priv.focusedAppDelegate.requestMinimize(); } }
358376 onRestoreClicked: { if (priv.focusedAppDelegate) { priv.focusedAppDelegate.requestRestore(); } }
359377 }
360378
361379 Binding {
362− target: PanelState
380+ target: panelState
363381 property: "decorationsVisible"
364382 value: priv.focusedAppDelegate !== null && priv.focusedAppDelegate.maximized // FIXME for Locally integrated menus
365383 }
366384
367385 Binding {
368− target: PanelState
386+ target: panelState
369387 property: "title"
370388 value: {
371389 if (priv.focusedAppDelegate !== null) {
@@ -380,7 +398,7 @@ FocusScope {
380398 }
381399
382400 Binding {
383− target: PanelState
401+ target: panelState
384402 property: "focusedPersistentSurfaceId"
385403 value: {
386404 if (priv.focusedAppDelegate !== null) {
@@ -394,21 +412,21 @@ FocusScope {
394412 }
395413
396414 Binding {
397− target: PanelState
415+ target: panelState
398416 property: "dropShadow"
399417 value: priv.focusedAppDelegate && !priv.focusedAppDelegate.maximized && priv.foregroundMaximizedAppDelegate !== null && mode == "windowed"
400418 }
401419
402420 Binding {
403− target: PanelState
421+ target: panelState
404422 property: "closeButtonShown"
405423 value: priv.focusedAppDelegate && priv.focusedAppDelegate.maximized && !priv.focusedAppDelegate.isDash
406424 }
407425
408426 Component.onDestruction: {
409− PanelState.title = "";
410− PanelState.decorationsVisible = false;
411− PanelState.dropShadow = false;
427+ panelState.title = "";
428+ panelState.decorationsVisible = false;
429+ panelState.dropShadow = false;
412430 }
413431
414432 Instantiator {
@@ -454,6 +472,7 @@ FocusScope {
454472 PropertyChanges { target: cancelSpreadMouseArea; enabled: true }
455473 PropertyChanges { target: blurLayer; visible: true; blurRadius: 32; brightness: .65; opacity: 1 }
456474 PropertyChanges { target: wallpaper; visible: false }
475+ PropertyChanges { target: screensAndWorkspaces; opacity: 1 }
457476 },
458477 State {
459478 name: "stagedRightEdge"; when: root.spreadEnabled && (rightEdgeDragArea.dragging || rightEdgePushProgress > 0) && root.mode == "staged"
@@ -502,10 +521,13 @@ FocusScope {
502521 from: "stagedRightEdge,sideStagedRightEdge,windowedRightEdge"; to: "spread"
503522 PropertyAction { target: spreadItem; property: "highlightedIndex"; value: -1 }
504523 PropertyAnimation { target: blurLayer; properties: "brightness,blurRadius"; duration: priv.animationDuration }
524+ UbuntuNumberAnimation { target: screensAndWorkspaces; property: "opacity"; duration: priv.animationDuration }
505525 },
506526 Transition {
507527 to: "spread"
508528 PropertyAction { target: spreadItem; property: "highlightedIndex"; value: appRepeater.count > 1 ? 1 : 0 }
529+ PropertyAction { target: floatingFlickable; property: "contentX"; value: 0 }
530+ UbuntuNumberAnimation { target: screensAndWorkspaces; property: "opacity"; duration: priv.animationDuration }
509531 },
510532 Transition {
511533 from: "spread"
@@ -563,10 +585,21 @@ FocusScope {
563585 visible: false
564586 }
565587
588+ ScreensAndWorkspaces {
589+ id: screensAndWorkspaces
590+ anchors { left: parent.left; top: parent.top; right: parent.right; leftMargin: root.leftMargin }
591+ height: Math.max(units.gu(30), parent.height * .3)
592+ background: root.background
593+ opacity: 0
594+ visible: opacity > 0
595+
596+ onCloseSpread: priv.goneToSpread = false;
597+ }
598+
566599 Spread {
567600 id: spreadItem
568601 objectName: "spreadItem"
569− anchors.fill: appContainer
602+ anchors { left: parent.left; bottom: parent.bottom; right: parent.right; top: screensAndWorkspaces.bottom }
570603 leftMargin: root.leftMargin
571604 model: root.topLevelSurfaceList
572605 spreadFlickable: floatingFlickable
@@ -581,6 +614,83 @@ FocusScope {
581614 appRepeater.itemAt(highlightedIndex).close();
582615 }
583616 }
617+
618+ FloatingFlickable {
619+ id: floatingFlickable
620+ objectName: "spreadFlickable"
621+ anchors.fill: parent
622+ enabled: false
623+ contentWidth: spreadItem.spreadTotalWidth
624+
625+ function snap(toIndex) {
626+ var delegate = appRepeater.itemAt(toIndex)
627+ var targetContentX = floatingFlickable.contentWidth / spreadItem.totalItemCount * toIndex;
628+ if (targetContentX - floatingFlickable.contentX > spreadItem.rightStackXPos - (spreadItem.spreadItemWidth / 2)) {
629+ var offset = (spreadItem.rightStackXPos - (spreadItem.spreadItemWidth / 2)) - (targetContentX - floatingFlickable.contentX)
630+ snapAnimation.to = floatingFlickable.contentX - offset;
631+ snapAnimation.start();
632+ } else if (targetContentX - floatingFlickable.contentX < spreadItem.leftStackXPos + units.gu(1)) {
633+ var offset = (spreadItem.leftStackXPos + units.gu(1)) - (targetContentX - floatingFlickable.contentX);
634+ snapAnimation.to = floatingFlickable.contentX - offset;
635+ snapAnimation.start();
636+ }
637+ }
638+ UbuntuNumberAnimation {id: snapAnimation; target: floatingFlickable; property: "contentX"}
639+ }
640+
641+ MouseArea {
642+ id: hoverMouseArea
643+ objectName: "hoverMouseArea"
644+ anchors.fill: parent
645+ propagateComposedEvents: true
646+ hoverEnabled: true
647+ enabled: false
648+ visible: enabled
649+
650+ property int scrollAreaWidth: width / 3
651+ property bool progressiveScrollingEnabled: false
652+
653+ onPressed: mouse.accepted = false
654+
655+ onMouseXChanged: {
656+ mouse.accepted = false
657+
658+ if (hoverMouseArea.pressed) {
659+ return;
660+ }
661+
662+ // Find the hovered item and mark it active
663+ for (var i = appRepeater.count - 1; i >= 0; i--) {
664+ var appDelegate = appRepeater.itemAt(i);
665+ var mapped = mapToItem(appDelegate, hoverMouseArea.mouseX, hoverMouseArea.mouseY)
666+ var itemUnder = appDelegate.childAt(mapped.x, mapped.y);
667+ if (itemUnder && (itemUnder.objectName === "dragArea" || itemUnder.objectName === "windowInfoItem" || itemUnder.objectName == "closeMouseArea")) {
668+ spreadItem.highlightedIndex = i;
669+ break;
670+ }
671+ }
672+
673+ if (floatingFlickable.contentWidth > floatingFlickable.width) {
674+ var margins = floatingFlickable.width * 0.05;
675+
676+ if (!progressiveScrollingEnabled && mouseX < floatingFlickable.width - scrollAreaWidth) {
677+ progressiveScrollingEnabled = true
678+ }
679+
680+ // do we need to scroll?
681+ if (mouseX < scrollAreaWidth + margins) {
682+ var progress = Math.min(1, (scrollAreaWidth + margins - mouseX) / (scrollAreaWidth - margins));
683+ var contentX = (1 - progress) * (floatingFlickable.contentWidth - floatingFlickable.width)
684+ floatingFlickable.contentX = Math.max(0, Math.min(floatingFlickable.contentX, contentX))
685+ }
686+ if (mouseX > floatingFlickable.width - scrollAreaWidth && progressiveScrollingEnabled) {
687+ var progress = Math.min(1, (mouseX - (floatingFlickable.width - scrollAreaWidth)) / (scrollAreaWidth - margins))
688+ var contentX = progress * (floatingFlickable.contentWidth - floatingFlickable.width)
689+ floatingFlickable.contentX = Math.min(floatingFlickable.contentWidth - floatingFlickable.width, Math.max(floatingFlickable.contentX, contentX))
690+ }
691+ }
692+ }
693+ }
584694 }
585695
586696 Connections {
@@ -675,10 +785,28 @@ FocusScope {
675785 }
676786 }
677787
788+ MirSurfaceItem {
789+ id: fakeDragItem
790+ property real previewScale: .5
791+ height: (screensAndWorkspaces.height - units.gu(8)) / 2
792+ // w : h = iw : ih
793+ width: implicitWidth * height / implicitHeight
794+ surfaceWidth: -1
795+ surfaceHeight: -1
796+ opacity: surface != null ? 1 : 0
797+ Behavior on opacity { UbuntuNumberAnimation {} }
798+ visible: opacity > 0
799+
800+ Drag.active: surface != null
801+ Drag.keys: ["application"]
802+
803+ z: 1000
804+ }
805+
678806 Item {
679807 id: boundariesForWindowPlacement
680808 anchors.fill: parent
681− anchors.topMargin: PanelState.panelHeight
809+ anchors.topMargin: panelState.panelHeight
682810 visible: false
683811 }
684812
@@ -710,6 +838,9 @@ FocusScope {
710838 }
711839 z: normalZ
712840
841+ opacity: fakeDragItem.surface == model.window.surface && fakeDragItem.Drag.active ? 0 : 1
842+ Behavior on opacity { UbuntuNumberAnimation {} }
843+
713844 // Normally we want x/y where the surface thinks it is. Width/height of our delegate will
714845 // match what the actual surface size is.
715846 // Don't write to those, they will be set by states
@@ -779,7 +910,7 @@ FocusScope {
779910 target: appDelegate
780911 property: "y"
781912 value: appDelegate.requestedY -
782− Math.min(appDelegate.requestedY - PanelState.panelHeight,
913+ Math.min(appDelegate.requestedY - panelState.panelHeight,
783914 Math.max(0, priv.virtualKeyboardHeight - (appContainer.height - (appDelegate.requestedY + appDelegate.height))))
784915 when: root.oskEnabled && appDelegate.focus && (appDelegate.state == "normal" || appDelegate.state == "restored")
785916 && root.inputMethodRect.height > 0
@@ -890,7 +1021,6 @@ FocusScope {
8901021 function claimFocus() {
8911022 if (root.state == "spread") {
8921023 spreadItem.highlightedIndex = index
893− priv.goneToSpread = false;
8941024 }
8951025 if (root.mode == "stagedWithSideStage") {
8961026 if (appDelegate.stage == ApplicationInfoInterface.SideStage && !sideStage.shown) {
@@ -1177,7 +1307,7 @@ FocusScope {
11771307 progress: 0
11781308 targetHeight: spreadItem.stackHeight
11791309 targetX: spreadMaths.targetX
1180− startY: appDelegate.fullscreen ? 0 : PanelState.panelHeight
1310+ startY: appDelegate.fullscreen ? 0 : panelState.panelHeight
11811311 targetY: spreadMaths.targetY
11821312 targetAngle: spreadMaths.targetAngle
11831313 targetScale: spreadMaths.targetScale
@@ -1223,8 +1353,6 @@ FocusScope {
12231353 y: spreadMaths.targetY
12241354 z: index
12251355 height: spreadItem.spreadItemHeight
1226− requestedWidth: decoratedWindow.oldRequestedWidth
1227− requestedHeight: decoratedWindow.oldRequestedHeight
12281356 visible: spreadMaths.itemVisible
12291357 }
12301358 PropertyChanges { target: dragArea; enabled: true }
@@ -1244,8 +1372,6 @@ FocusScope {
12441372 y: stagedRightEdgeMaths.animatedY
12451373 z: stagedRightEdgeMaths.animatedZ
12461374 height: stagedRightEdgeMaths.animatedHeight
1247− requestedWidth: decoratedWindow.oldRequestedWidth
1248− requestedHeight: decoratedWindow.oldRequestedHeight
12491375 visible: appDelegate.x < root.width
12501376 }
12511377 PropertyChanges {
@@ -1275,8 +1401,6 @@ FocusScope {
12751401 y: windowedRightEdgeMaths.animatedY
12761402 z: windowedRightEdgeMaths.animatedZ
12771403 height: stagedRightEdgeMaths.animatedHeight
1278− requestedWidth: decoratedWindow.oldRequestedWidth
1279− requestedHeight: decoratedWindow.oldRequestedHeight
12801404 }
12811405 PropertyChanges {
12821406 target: decoratedWindow
@@ -1298,12 +1422,16 @@ FocusScope {
12981422 PropertyChanges {
12991423 target: appDelegate
13001424 x: stageMaths.itemX
1301− y: appDelegate.fullscreen ? 0 : PanelState.panelHeight
1302− requestedWidth: appContainer.width
1303− requestedHeight: appDelegate.fullscreen ? appContainer.height : appContainer.height - PanelState.panelHeight
1425+ y: appDelegate.fullscreen ? 0 : panelState.panelHeight
13041426 visuallyMaximized: true
13051427 visible: appDelegate.x < root.width
13061428 }
1429+ PropertyChanges {
1430+ target: appDelegate
1431+ requestedWidth: appContainer.width
1432+ requestedHeight: appDelegate.fullscreen ? appContainer.height : appContainer.height - panelState.panelHeight
1433+ restoreEntryValues: false
1434+ }
13071435 PropertyChanges {
13081436 target: decoratedWindow
13091437 hasDecoration: false
@@ -1330,13 +1458,17 @@ FocusScope {
13301458 PropertyChanges {
13311459 target: appDelegate
13321460 x: stageMaths.itemX
1333− y: appDelegate.fullscreen ? 0 : PanelState.panelHeight
1461+ y: appDelegate.fullscreen ? 0 : panelState.panelHeight
13341462 z: stageMaths.itemZ
1335− requestedWidth: stageMaths.itemWidth
1336− requestedHeight: appDelegate.fullscreen ? appContainer.height : appContainer.height - PanelState.panelHeight
13371463 visuallyMaximized: true
13381464 visible: appDelegate.x < root.width
13391465 }
1466+ PropertyChanges {
1467+ target: appDelegate
1468+ requestedWidth: stageMaths.itemWidth
1469+ requestedHeight: appDelegate.fullscreen ? appContainer.height : appContainer.height - panelState.panelHeight
1470+ restoreEntryValues: false
1471+ }
13401472 PropertyChanges {
13411473 target: decoratedWindow
13421474 hasDecoration: false
@@ -1358,8 +1490,12 @@ FocusScope {
13581490 requestedY: 0;
13591491 visuallyMinimized: false;
13601492 visuallyMaximized: true
1361− requestedWidth: appContainer.width - root.leftMargin;
1362− requestedHeight: appContainer.height;
1493+ }
1494+ PropertyChanges {
1495+ target: appDelegate
1496+ requestedWidth: appContainer.width - root.leftMargin
1497+ requestedHeight: appContainer.height
1498+ restoreEntryValues: false
13631499 }
13641500 PropertyChanges { target: touchControls; enabled: true }
13651501 },
@@ -1369,8 +1505,12 @@ FocusScope {
13691505 target: appDelegate;
13701506 requestedX: 0
13711507 requestedY: 0
1372− requestedWidth: appContainer.width;
1373− requestedHeight: appContainer.height;
1508+ }
1509+ PropertyChanges {
1510+ target: appDelegate
1511+ requestedWidth: appContainer.width
1512+ requestedHeight: appContainer.height
1513+ restoreEntryValues: false
13741514 }
13751515 PropertyChanges { target: decoratedWindow; hasDecoration: false }
13761516 },
@@ -1385,6 +1525,12 @@ FocusScope {
13851525 PropertyChanges { target: touchControls; enabled: true }
13861526 PropertyChanges { target: resizeArea; enabled: true }
13871527 PropertyChanges { target: decoratedWindow; shadowOpacity: .3}
1528+ PropertyChanges {
1529+ target: appDelegate
1530+ requestedWidth: windowedWidth
1531+ requestedHeight: windowedHeight
1532+ restoreEntryValues: false
1533+ }
13881534 },
13891535 State {
13901536 name: "restored";
@@ -1402,9 +1548,9 @@ FocusScope {
14021548 PropertyChanges {
14031549 target: appDelegate
14041550 windowedX: root.leftMargin
1405− windowedY: PanelState.panelHeight
1551+ windowedY: panelState.panelHeight
14061552 windowedWidth: (appContainer.width - root.leftMargin)/2
1407− windowedHeight: appContainer.height - PanelState.panelHeight
1553+ windowedHeight: appContainer.height - panelState.panelHeight
14081554 }
14091555 },
14101556 State {
@@ -1421,9 +1567,9 @@ FocusScope {
14211567 PropertyChanges {
14221568 target: appDelegate
14231569 windowedX: root.leftMargin
1424− windowedY: PanelState.panelHeight
1570+ windowedY: panelState.panelHeight
14251571 windowedWidth: (appContainer.width - root.leftMargin)/2
1426− windowedHeight: (appContainer.height - PanelState.panelHeight)/2
1572+ windowedHeight: (appContainer.height - panelState.panelHeight)/2
14271573 }
14281574 },
14291575 State {
@@ -1440,7 +1586,7 @@ FocusScope {
14401586 PropertyChanges {
14411587 target: appDelegate
14421588 windowedX: root.leftMargin
1443− windowedY: (appContainer.height + PanelState.panelHeight)/2
1589+ windowedY: (appContainer.height + panelState.panelHeight)/2
14441590 windowedWidth: (appContainer.width - root.leftMargin)/2
14451591 windowedHeight: appContainer.height/2
14461592 }
@@ -1462,8 +1608,8 @@ FocusScope {
14621608 State {
14631609 name: "maximizedVertically"; when: appDelegate.maximizedVertically && !appDelegate.minimized
14641610 extend: "normal"
1465− PropertyChanges { target: appDelegate; windowedX: windowedX; windowedY: PanelState.panelHeight;
1466− windowedWidth: windowedWidth; windowedHeight: appContainer.height - PanelState.panelHeight }
1611+ PropertyChanges { target: appDelegate; windowedX: windowedX; windowedY: panelState.panelHeight;
1612+ windowedWidth: windowedWidth; windowedHeight: appContainer.height - panelState.panelHeight }
14671613 },
14681614 State {
14691615 name: "minimized"; when: appDelegate.minimized
@@ -1478,6 +1624,10 @@ FocusScope {
14781624 }
14791625 }
14801626 ]
1627+ onStateChanged: {
1628+ print("item", index, "state changed", state)
1629+ }
1630+
14811631 transitions: [
14821632 Transition {
14831633 from: "staged,stagedWithSideStage"
@@ -1491,6 +1641,7 @@ FocusScope {
14911641 UbuntuNumberAnimation { target: appDelegate; properties: "x,y,requestedX,requestedY,requestedWidth,requestedHeight"; duration: priv.animationDuration}
14921642 },
14931643 Transition {
1644+ from: "normal,restored,maximized,maximizedHorizontally,maximizedVertically,maximizedLeft,maximizedRight,maximizedTopLeft,maximizedBottomLeft,maximizedTopRight,maximizedBottomRight,staged,stagedWithSideStage,windowedRightEdge,stagedRightEdge";
14941645 to: "spread"
14951646 // DecoratedWindow wants the scaleToPreviewSize set before enabling scaleToPreview
14961647 PropertyAction { target: appDelegate; properties: "z,visible" }
@@ -1576,7 +1727,7 @@ FocusScope {
15761727 ]
15771728
15781729 Binding {
1579− target: PanelState
1730+ target: panelState
15801731 property: "decorationsAlwaysVisible"
15811732 value: appDelegate && appDelegate.maximized && touchControls.overlayShown
15821733 }
@@ -1597,6 +1748,7 @@ FocusScope {
15971748 borderThickness: units.gu(2)
15981749 enabled: false
15991750 visible: enabled
1751+ readyToAssesBounds: !appDelegate._constructing
16001752
16011753 onPressed: {
16021754 appDelegate.activate();
@@ -1620,17 +1772,12 @@ FocusScope {
16201772 height: implicitHeight
16211773 highlightSize: windowInfoItem.iconMargin / 2
16221774 boundsItem: boundariesForWindowPlacement
1775+ panelState: root.panelState
16231776 altDragEnabled: root.mode == "windowed"
16241777
16251778 requestedWidth: appDelegate.requestedWidth
16261779 requestedHeight: appDelegate.requestedHeight
16271780
1628− property int oldRequestedWidth: -1
1629− property int oldRequestedHeight: -1
1630−
1631− onRequestedWidthChanged: oldRequestedWidth = requestedWidth
1632− onRequestedHeightChanged: oldRequestedHeight = requestedHeight
1633−
16341781 onCloseClicked: { appDelegate.close(); }
16351782 onMaximizeClicked: {
16361783 if (appDelegate.canBeMaximized) {
@@ -1711,6 +1858,8 @@ FocusScope {
17111858 anchors.fill: decoratedWindow
17121859 enabled: false
17131860 closeable: !appDelegate.isDash
1861+ stage: root
1862+ dragDelegate: fakeDragItem
17141863
17151864 onClicked: {
17161865 spreadItem.highlightedIndex = index;
@@ -1753,12 +1902,15 @@ FocusScope {
17531902 objectName: "closeMouseArea"
17541903 anchors { left: parent.left; top: parent.top; leftMargin: -height / 2; topMargin: -height / 2 + spreadMaths.closeIconOffset }
17551904 readonly property var mousePos: hoverMouseArea.mapToItem(appDelegate, hoverMouseArea.mouseX, hoverMouseArea.mouseY)
1756− visible: !appDelegate.isDash && dragArea.distance == 0
1905+ readonly property bool shown: !appDelegate.isDash && dragArea.distance == 0
17571906 && index == spreadItem.highlightedIndex
17581907 && mousePos.y < (decoratedWindow.height / 3)
17591908 && mousePos.y > -units.gu(4)
17601909 && mousePos.x > -units.gu(4)
17611910 && mousePos.x < (decoratedWindow.width * 2 / 3)
1911+ opacity: shown ? 1 : 0
1912+ visible: opacity > 0
1913+ Behavior on opacity { UbuntuNumberAnimation { duration: UbuntuAnimation.SnapDuration } }
17621914 height: units.gu(6)
17631915 width: height
17641916
@@ -1820,83 +1972,19 @@ FocusScope {
18201972 leftMargin: root.leftMargin
18211973 appContainerWidth: appContainer.width
18221974 appContainerHeight: appContainer.height
1975+ panelState: root.panelState
18231976 }
18241977
1825− MouseArea {
1826− id: hoverMouseArea
1827− objectName: "hoverMouseArea"
1828− anchors.fill: appContainer
1829− propagateComposedEvents: true
1830− hoverEnabled: true
1831− enabled: false
1832− visible: enabled
1833−
1834− property int scrollAreaWidth: width / 3
1835− property bool progressiveScrollingEnabled: false
1836−
1837− onMouseXChanged: {
1838− mouse.accepted = false
1839−
1840− if (hoverMouseArea.pressed) {
1841− return;
1842− }
1843−
1844− // Find the hovered item and mark it active
1845− for (var i = appRepeater.count - 1; i >= 0; i--) {
1846− var appDelegate = appRepeater.itemAt(i);
1847− var mapped = mapToItem(appDelegate, hoverMouseArea.mouseX, hoverMouseArea.mouseY)
1848− var itemUnder = appDelegate.childAt(mapped.x, mapped.y);
1849− if (itemUnder && (itemUnder.objectName === "dragArea" || itemUnder.objectName === "windowInfoItem" || itemUnder.objectName == "closeMouseArea")) {
1850− spreadItem.highlightedIndex = i;
1851− break;
1852− }
1853− }
1854−
1855− if (floatingFlickable.contentWidth > floatingFlickable.width) {
1856− var margins = floatingFlickable.width * 0.05;
1857−
1858− if (!progressiveScrollingEnabled && mouseX < floatingFlickable.width - scrollAreaWidth) {
1859− progressiveScrollingEnabled = true
1860− }
1861−
1862− // do we need to scroll?
1863− if (mouseX < scrollAreaWidth + margins) {
1864− var progress = Math.min(1, (scrollAreaWidth + margins - mouseX) / (scrollAreaWidth - margins));
1865− var contentX = (1 - progress) * (floatingFlickable.contentWidth - floatingFlickable.width)
1866− floatingFlickable.contentX = Math.max(0, Math.min(floatingFlickable.contentX, contentX))
1867− }
1868− if (mouseX > floatingFlickable.width - scrollAreaWidth && progressiveScrollingEnabled) {
1869− var progress = Math.min(1, (mouseX - (floatingFlickable.width - scrollAreaWidth)) / (scrollAreaWidth - margins))
1870− var contentX = progress * (floatingFlickable.contentWidth - floatingFlickable.width)
1871− floatingFlickable.contentX = Math.min(floatingFlickable.contentWidth - floatingFlickable.width, Math.max(floatingFlickable.contentX, contentX))
1872− }
1873− }
1874− }
1875−
1876− onPressed: mouse.accepted = false
1877− }
1878−
1879− FloatingFlickable {
1880− id: floatingFlickable
1881− objectName: "spreadFlickable"
1882− anchors.fill: appContainer
1883− enabled: false
1884− contentWidth: spreadItem.spreadTotalWidth
1885−
1886− function snap(toIndex) {
1887− var delegate = appRepeater.itemAt(toIndex)
1888− var targetContentX = floatingFlickable.contentWidth / spreadItem.totalItemCount * toIndex;
1889− if (targetContentX - floatingFlickable.contentX > spreadItem.rightStackXPos - (spreadItem.spreadItemWidth / 2)) {
1890− var offset = (spreadItem.rightStackXPos - (spreadItem.spreadItemWidth / 2)) - (targetContentX - floatingFlickable.contentX)
1891− snapAnimation.to = Math.max(0, floatingFlickable.contentX - offset);
1892− snapAnimation.start();
1893− } else if (targetContentX - floatingFlickable.contentX < spreadItem.leftStackXPos + units.gu(1)) {
1894− var offset = (spreadItem.leftStackXPos + units.gu(1)) - (targetContentX - floatingFlickable.contentX);
1895− snapAnimation.to = Math.max(0, floatingFlickable.contentX - offset);
1896− snapAnimation.start();
1978+ WorkspaceSwitcher {
1979+ id: workspaceSwitcher
1980+ anchors.centerIn: parent
1981+ height: units.gu(20)
1982+ background: root.background
1983+ onActiveChanged: {
1984+ if (!active) {
1985+ appContainer.focus = true;
18971986 }
18981987 }
1899− UbuntuNumberAnimation {id: snapAnimation; target: floatingFlickable; property: "contentX"}
19001988 }
19011989
19021990 PropertyAnimation {