@@ -25,6 +25,7 @@ import GlobalShortcut 1.0
2525import GSettings 1.0
2626import "Spread"
2727import "Spread/MathUtils.js" as MathUtils
28+import WindowManager 1.0
2829
2930FocusScope {
3031 id: root
@@ -47,6 +48,9 @@ FocusScope {
4748 property bool oskEnabled: false
4849 property rect inputMethodRect
4950 property real rightEdgePushProgress: 0
51+ property PanelState panelState
52+
53+ readonly property var temporarySelectedWorkspace: state == "spread" ? screensAndWorkspaces.lastClickedWorkspace : null
5054
5155 // Configuration
5256 property string mode: "staged"
@@ -224,6 +228,25 @@ FocusScope {
224228 active: priv.focusedAppDelegate !== null
225229 }
226230
231+ GlobalShortcut {
232+ id: showWorkspaceSwitcherShortcutLeft
233+ shortcut: Qt.AltModifier|Qt.ControlModifier|Qt.Key_Left
234+ active: !workspaceSwitcher.active
235+ onTriggered: {
236+ root.focus = true;
237+ workspaceSwitcher.showLeft()
238+ }
239+ }
240+ GlobalShortcut {
241+ id: showWorkspaceSwitcherShortcutRight
242+ shortcut: Qt.AltModifier|Qt.ControlModifier|Qt.Key_Right
243+ active: !workspaceSwitcher.active
244+ onTriggered: {
245+ root.focus = true;
246+ workspaceSwitcher.showRight()
247+ }
248+ }
249+
227250 QtObject {
228251 id: priv
229252 objectName: "DesktopStagePrivate"
@@ -349,23 +372,23 @@ FocusScope {
349372 readonly property real virtualKeyboardHeight: root.inputMethodRect.height
350373 }
351374
352− Component.onCompleted: priv.updateMainAndSideStageIndexes();
375+ Component.onCompleted: priv.updateMainAndSideStageIndexes()
353376
354377 Connections {
355− target: PanelState
378+ target: panelState
356379 onCloseClicked: { if (priv.focusedAppDelegate) { priv.focusedAppDelegate.close(); } }
357380 onMinimizeClicked: { if (priv.focusedAppDelegate) { priv.focusedAppDelegate.requestMinimize(); } }
358381 onRestoreClicked: { if (priv.focusedAppDelegate) { priv.focusedAppDelegate.requestRestore(); } }
359382 }
360383
361384 Binding {
362− target: PanelState
385+ target: panelState
363386 property: "decorationsVisible"
364387 value: priv.focusedAppDelegate !== null && priv.focusedAppDelegate.maximized // FIXME for Locally integrated menus
365388 }
366389
367390 Binding {
368− target: PanelState
391+ target: panelState
369392 property: "title"
370393 value: {
371394 if (priv.focusedAppDelegate !== null) {
@@ -380,7 +403,7 @@ FocusScope {
380403 }
381404
382405 Binding {
383− target: PanelState
406+ target: panelState
384407 property: "focusedPersistentSurfaceId"
385408 value: {
386409 if (priv.focusedAppDelegate !== null) {
@@ -394,21 +417,21 @@ FocusScope {
394417 }
395418
396419 Binding {
397− target: PanelState
420+ target: panelState
398421 property: "dropShadow"
399422 value: priv.focusedAppDelegate && !priv.focusedAppDelegate.maximized && priv.foregroundMaximizedAppDelegate !== null && mode == "windowed"
400423 }
401424
402425 Binding {
403− target: PanelState
426+ target: panelState
404427 property: "closeButtonShown"
405428 value: priv.focusedAppDelegate && priv.focusedAppDelegate.maximized && !priv.focusedAppDelegate.isDash
406429 }
407430
408431 Component.onDestruction: {
409− PanelState.title = "";
410− PanelState.decorationsVisible = false;
411− PanelState.dropShadow = false;
432+ panelState.title = "";
433+ panelState.decorationsVisible = false;
434+ panelState.dropShadow = false;
412435 }
413436
414437 Instantiator {
@@ -454,6 +477,7 @@ FocusScope {
454477 PropertyChanges { target: cancelSpreadMouseArea; enabled: true }
455478 PropertyChanges { target: blurLayer; visible: true; blurRadius: 32; brightness: .65; opacity: 1 }
456479 PropertyChanges { target: wallpaper; visible: false }
480+ PropertyChanges { target: screensAndWorkspaces; opacity: 1 }
457481 },
458482 State {
459483 name: "stagedRightEdge"; when: root.spreadEnabled && (rightEdgeDragArea.dragging || rightEdgePushProgress > 0) && root.mode == "staged"
@@ -501,11 +525,18 @@ FocusScope {
501525 Transition {
502526 from: "stagedRightEdge,sideStagedRightEdge,windowedRightEdge"; to: "spread"
503527 PropertyAction { target: spreadItem; property: "highlightedIndex"; value: -1 }
528+ PropertyAction { target: screensAndWorkspaces; property: "activeWorkspace"; value: WMScreen.currentWorkspace }
529+ ScriptAction { script: { print("blabal***********************", WMScreen.currentWorkspace) } }
504530 PropertyAnimation { target: blurLayer; properties: "brightness,blurRadius"; duration: priv.animationDuration }
531+ UbuntuNumberAnimation { target: screensAndWorkspaces; property: "opacity"; duration: priv.animationDuration }
505532 },
506533 Transition {
507534 to: "spread"
535+ PropertyAction { target: screensAndWorkspaces; property: "activeWorkspace"; value: WMScreen.currentWorkspace }
536+ ScriptAction { script: { print("blabal***********************", WMScreen.currentWorkspace) } }
508537 PropertyAction { target: spreadItem; property: "highlightedIndex"; value: appRepeater.count > 1 ? 1 : 0 }
538+ PropertyAction { target: floatingFlickable; property: "contentX"; value: 0 }
539+ UbuntuNumberAnimation { target: screensAndWorkspaces; property: "opacity"; duration: priv.animationDuration }
509540 },
510541 Transition {
511542 from: "spread"
@@ -521,6 +552,7 @@ FocusScope {
521552 }
522553 PropertyAction { target: spreadItem; property: "highlightedIndex"; value: -1 }
523554 PropertyAction { target: floatingFlickable; property: "contentX"; value: 0 }
555+ PropertyAction { target: screensAndWorkspaces; property: "lastClickedWorkspace"; value: null }
524556 }
525557 },
526558 Transition {
@@ -563,10 +595,21 @@ FocusScope {
563595 visible: false
564596 }
565597
598+ ScreensAndWorkspaces {
599+ id: screensAndWorkspaces
600+ anchors { left: parent.left; top: parent.top; right: parent.right; leftMargin: root.leftMargin }
601+ height: Math.max(units.gu(30), parent.height * .3)
602+ background: root.background
603+ opacity: 0
604+ visible: opacity > 0
605+ onCloseSpread: priv.goneToSpread = false;
606+ onLastClickedWorkspaceChanged: activeWorkspace = lastClickedWorkspace
607+ }
608+
566609 Spread {
567610 id: spreadItem
568611 objectName: "spreadItem"
569− anchors.fill: appContainer
612+ anchors { left: parent.left; bottom: parent.bottom; right: parent.right; top: screensAndWorkspaces.bottom }
570613 leftMargin: root.leftMargin
571614 model: root.topLevelSurfaceList
572615 spreadFlickable: floatingFlickable
@@ -581,6 +624,83 @@ FocusScope {
581624 appRepeater.itemAt(highlightedIndex).close();
582625 }
583626 }
627+
628+ FloatingFlickable {
629+ id: floatingFlickable
630+ objectName: "spreadFlickable"
631+ anchors.fill: parent
632+ enabled: false
633+ contentWidth: spreadItem.spreadTotalWidth
634+
635+ function snap(toIndex) {
636+ var delegate = appRepeater.itemAt(toIndex)
637+ var targetContentX = floatingFlickable.contentWidth / spreadItem.totalItemCount * toIndex;
638+ if (targetContentX - floatingFlickable.contentX > spreadItem.rightStackXPos - (spreadItem.spreadItemWidth / 2)) {
639+ var offset = (spreadItem.rightStackXPos - (spreadItem.spreadItemWidth / 2)) - (targetContentX - floatingFlickable.contentX)
640+ snapAnimation.to = floatingFlickable.contentX - offset;
641+ snapAnimation.start();
642+ } else if (targetContentX - floatingFlickable.contentX < spreadItem.leftStackXPos + units.gu(1)) {
643+ var offset = (spreadItem.leftStackXPos + units.gu(1)) - (targetContentX - floatingFlickable.contentX);
644+ snapAnimation.to = floatingFlickable.contentX - offset;
645+ snapAnimation.start();
646+ }
647+ }
648+ UbuntuNumberAnimation {id: snapAnimation; target: floatingFlickable; property: "contentX"}
649+ }
650+
651+ MouseArea {
652+ id: hoverMouseArea
653+ objectName: "hoverMouseArea"
654+ anchors.fill: parent
655+ propagateComposedEvents: true
656+ hoverEnabled: true
657+ enabled: false
658+ visible: enabled
659+
660+ property int scrollAreaWidth: width / 3
661+ property bool progressiveScrollingEnabled: false
662+
663+ onPressed: mouse.accepted = false
664+
665+ onMouseXChanged: {
666+ mouse.accepted = false
667+
668+ if (hoverMouseArea.pressed) {
669+ return;
670+ }
671+
672+ // Find the hovered item and mark it active
673+ for (var i = appRepeater.count - 1; i >= 0; i--) {
674+ var appDelegate = appRepeater.itemAt(i);
675+ var mapped = mapToItem(appDelegate, hoverMouseArea.mouseX, hoverMouseArea.mouseY)
676+ var itemUnder = appDelegate.childAt(mapped.x, mapped.y);
677+ if (itemUnder && (itemUnder.objectName === "dragArea" || itemUnder.objectName === "windowInfoItem" || itemUnder.objectName == "closeMouseArea")) {
678+ spreadItem.highlightedIndex = i;
679+ break;
680+ }
681+ }
682+
683+ if (floatingFlickable.contentWidth > floatingFlickable.width) {
684+ var margins = floatingFlickable.width * 0.05;
685+
686+ if (!progressiveScrollingEnabled && mouseX < floatingFlickable.width - scrollAreaWidth) {
687+ progressiveScrollingEnabled = true
688+ }
689+
690+ // do we need to scroll?
691+ if (mouseX < scrollAreaWidth + margins) {
692+ var progress = Math.min(1, (scrollAreaWidth + margins - mouseX) / (scrollAreaWidth - margins));
693+ var contentX = (1 - progress) * (floatingFlickable.contentWidth - floatingFlickable.width)
694+ floatingFlickable.contentX = Math.max(0, Math.min(floatingFlickable.contentX, contentX))
695+ }
696+ if (mouseX > floatingFlickable.width - scrollAreaWidth && progressiveScrollingEnabled) {
697+ var progress = Math.min(1, (mouseX - (floatingFlickable.width - scrollAreaWidth)) / (scrollAreaWidth - margins))
698+ var contentX = progress * (floatingFlickable.contentWidth - floatingFlickable.width)
699+ floatingFlickable.contentX = Math.min(floatingFlickable.contentWidth - floatingFlickable.width, Math.max(floatingFlickable.contentX, contentX))
700+ }
701+ }
702+ }
703+ }
584704 }
585705
586706 Connections {
@@ -675,10 +795,28 @@ FocusScope {
675795 }
676796 }
677797
798+ MirSurfaceItem {
799+ id: fakeDragItem
800+ property real previewScale: .5
801+ height: (screensAndWorkspaces.height - units.gu(8)) / 2
802+ // w : h = iw : ih
803+ width: implicitWidth * height / implicitHeight
804+ surfaceWidth: -1
805+ surfaceHeight: -1
806+ opacity: surface != null ? 1 : 0
807+ Behavior on opacity { UbuntuNumberAnimation {} }
808+ visible: opacity > 0
809+
810+ Drag.active: surface != null
811+ Drag.keys: ["application"]
812+
813+ z: 1000
814+ }
815+
678816 Item {
679817 id: boundariesForWindowPlacement
680818 anchors.fill: parent
681− anchors.topMargin: PanelState.panelHeight
819+ anchors.topMargin: panelState.panelHeight
682820 visible: false
683821 }
684822
@@ -710,6 +848,9 @@ FocusScope {
710848 }
711849 z: normalZ
712850
851+ opacity: fakeDragItem.surface == model.window.surface && fakeDragItem.Drag.active ? 0 : 1
852+ Behavior on opacity { UbuntuNumberAnimation {} }
853+
713854 // Normally we want x/y where the surface thinks it is. Width/height of our delegate will
714855 // match what the actual surface size is.
715856 // Don't write to those, they will be set by states
@@ -779,7 +920,7 @@ FocusScope {
779920 target: appDelegate
780921 property: "y"
781922 value: appDelegate.requestedY -
782− Math.min(appDelegate.requestedY - PanelState.panelHeight,
923+ Math.min(appDelegate.requestedY - panelState.panelHeight,
783924 Math.max(0, priv.virtualKeyboardHeight - (appContainer.height - (appDelegate.requestedY + appDelegate.height))))
784925 when: root.oskEnabled && appDelegate.focus && (appDelegate.state == "normal" || appDelegate.state == "restored")
785926 && root.inputMethodRect.height > 0
@@ -890,7 +1031,6 @@ FocusScope {
8901031 function claimFocus() {
8911032 if (root.state == "spread") {
8921033 spreadItem.highlightedIndex = index
893− priv.goneToSpread = false;
8941034 }
8951035 if (root.mode == "stagedWithSideStage") {
8961036 if (appDelegate.stage == ApplicationInfoInterface.SideStage && !sideStage.shown) {
@@ -1177,7 +1317,7 @@ FocusScope {
11771317 progress: 0
11781318 targetHeight: spreadItem.stackHeight
11791319 targetX: spreadMaths.targetX
1180− startY: appDelegate.fullscreen ? 0 : PanelState.panelHeight
1320+ startY: appDelegate.fullscreen ? 0 : panelState.panelHeight
11811321 targetY: spreadMaths.targetY
11821322 targetAngle: spreadMaths.targetAngle
11831323 targetScale: spreadMaths.targetScale
@@ -1223,8 +1363,6 @@ FocusScope {
12231363 y: spreadMaths.targetY
12241364 z: index
12251365 height: spreadItem.spreadItemHeight
1226− requestedWidth: decoratedWindow.oldRequestedWidth
1227− requestedHeight: decoratedWindow.oldRequestedHeight
12281366 visible: spreadMaths.itemVisible
12291367 }
12301368 PropertyChanges { target: dragArea; enabled: true }
@@ -1244,8 +1382,6 @@ FocusScope {
12441382 y: stagedRightEdgeMaths.animatedY
12451383 z: stagedRightEdgeMaths.animatedZ
12461384 height: stagedRightEdgeMaths.animatedHeight
1247− requestedWidth: decoratedWindow.oldRequestedWidth
1248− requestedHeight: decoratedWindow.oldRequestedHeight
12491385 visible: appDelegate.x < root.width
12501386 }
12511387 PropertyChanges {
@@ -1275,8 +1411,6 @@ FocusScope {
12751411 y: windowedRightEdgeMaths.animatedY
12761412 z: windowedRightEdgeMaths.animatedZ
12771413 height: stagedRightEdgeMaths.animatedHeight
1278− requestedWidth: decoratedWindow.oldRequestedWidth
1279− requestedHeight: decoratedWindow.oldRequestedHeight
12801414 }
12811415 PropertyChanges {
12821416 target: decoratedWindow
@@ -1298,12 +1432,16 @@ FocusScope {
12981432 PropertyChanges {
12991433 target: appDelegate
13001434 x: stageMaths.itemX
1301− y: appDelegate.fullscreen ? 0 : PanelState.panelHeight
1302− requestedWidth: appContainer.width
1303− requestedHeight: appDelegate.fullscreen ? appContainer.height : appContainer.height - PanelState.panelHeight
1435+ y: appDelegate.fullscreen ? 0 : panelState.panelHeight
13041436 visuallyMaximized: true
13051437 visible: appDelegate.x < root.width
13061438 }
1439+ PropertyChanges {
1440+ target: appDelegate
1441+ requestedWidth: appContainer.width
1442+ requestedHeight: appDelegate.fullscreen ? appContainer.height : appContainer.height - panelState.panelHeight
1443+ restoreEntryValues: false
1444+ }
13071445 PropertyChanges {
13081446 target: decoratedWindow
13091447 hasDecoration: false
@@ -1330,13 +1468,17 @@ FocusScope {
13301468 PropertyChanges {
13311469 target: appDelegate
13321470 x: stageMaths.itemX
1333− y: appDelegate.fullscreen ? 0 : PanelState.panelHeight
1471+ y: appDelegate.fullscreen ? 0 : panelState.panelHeight
13341472 z: stageMaths.itemZ
1335− requestedWidth: stageMaths.itemWidth
1336− requestedHeight: appDelegate.fullscreen ? appContainer.height : appContainer.height - PanelState.panelHeight
13371473 visuallyMaximized: true
13381474 visible: appDelegate.x < root.width
13391475 }
1476+ PropertyChanges {
1477+ target: appDelegate
1478+ requestedWidth: stageMaths.itemWidth
1479+ requestedHeight: appDelegate.fullscreen ? appContainer.height : appContainer.height - panelState.panelHeight
1480+ restoreEntryValues: false
1481+ }
13401482 PropertyChanges {
13411483 target: decoratedWindow
13421484 hasDecoration: false
@@ -1358,8 +1500,12 @@ FocusScope {
13581500 requestedY: 0;
13591501 visuallyMinimized: false;
13601502 visuallyMaximized: true
1361− requestedWidth: appContainer.width - root.leftMargin;
1362− requestedHeight: appContainer.height;
1503+ }
1504+ PropertyChanges {
1505+ target: appDelegate
1506+ requestedWidth: appContainer.width - root.leftMargin
1507+ requestedHeight: appContainer.height
1508+ restoreEntryValues: false
13631509 }
13641510 PropertyChanges { target: touchControls; enabled: true }
13651511 },
@@ -1369,8 +1515,12 @@ FocusScope {
13691515 target: appDelegate;
13701516 requestedX: 0
13711517 requestedY: 0
1372− requestedWidth: appContainer.width;
1373− requestedHeight: appContainer.height;
1518+ }
1519+ PropertyChanges {
1520+ target: appDelegate
1521+ requestedWidth: appContainer.width
1522+ requestedHeight: appContainer.height
1523+ restoreEntryValues: false
13741524 }
13751525 PropertyChanges { target: decoratedWindow; hasDecoration: false }
13761526 },
@@ -1385,6 +1535,12 @@ FocusScope {
13851535 PropertyChanges { target: touchControls; enabled: true }
13861536 PropertyChanges { target: resizeArea; enabled: true }
13871537 PropertyChanges { target: decoratedWindow; shadowOpacity: .3}
1538+ PropertyChanges {
1539+ target: appDelegate
1540+ requestedWidth: windowedWidth
1541+ requestedHeight: windowedHeight
1542+ restoreEntryValues: false
1543+ }
13881544 },
13891545 State {
13901546 name: "restored";
@@ -1402,9 +1558,9 @@ FocusScope {
14021558 PropertyChanges {
14031559 target: appDelegate
14041560 windowedX: root.leftMargin
1405− windowedY: PanelState.panelHeight
1561+ windowedY: panelState.panelHeight
14061562 windowedWidth: (appContainer.width - root.leftMargin)/2
1407− windowedHeight: appContainer.height - PanelState.panelHeight
1563+ windowedHeight: appContainer.height - panelState.panelHeight
14081564 }
14091565 },
14101566 State {
@@ -1421,9 +1577,9 @@ FocusScope {
14211577 PropertyChanges {
14221578 target: appDelegate
14231579 windowedX: root.leftMargin
1424− windowedY: PanelState.panelHeight
1580+ windowedY: panelState.panelHeight
14251581 windowedWidth: (appContainer.width - root.leftMargin)/2
1426− windowedHeight: (appContainer.height - PanelState.panelHeight)/2
1582+ windowedHeight: (appContainer.height - panelState.panelHeight)/2
14271583 }
14281584 },
14291585 State {
@@ -1440,7 +1596,7 @@ FocusScope {
14401596 PropertyChanges {
14411597 target: appDelegate
14421598 windowedX: root.leftMargin
1443− windowedY: (appContainer.height + PanelState.panelHeight)/2
1599+ windowedY: (appContainer.height + panelState.panelHeight)/2
14441600 windowedWidth: (appContainer.width - root.leftMargin)/2
14451601 windowedHeight: appContainer.height/2
14461602 }
@@ -1462,8 +1618,8 @@ FocusScope {
14621618 State {
14631619 name: "maximizedVertically"; when: appDelegate.maximizedVertically && !appDelegate.minimized
14641620 extend: "normal"
1465− PropertyChanges { target: appDelegate; windowedX: windowedX; windowedY: PanelState.panelHeight;
1466− windowedWidth: windowedWidth; windowedHeight: appContainer.height - PanelState.panelHeight }
1621+ PropertyChanges { target: appDelegate; windowedX: windowedX; windowedY: panelState.panelHeight;
1622+ windowedWidth: windowedWidth; windowedHeight: appContainer.height - panelState.panelHeight }
14671623 },
14681624 State {
14691625 name: "minimized"; when: appDelegate.minimized
@@ -1478,6 +1634,10 @@ FocusScope {
14781634 }
14791635 }
14801636 ]
1637+ onStateChanged: {
1638+ print("item", index, "state changed", state)
1639+ }
1640+
14811641 transitions: [
14821642 Transition {
14831643 from: "staged,stagedWithSideStage"
@@ -1491,6 +1651,7 @@ FocusScope {
14911651 UbuntuNumberAnimation { target: appDelegate; properties: "x,y,requestedX,requestedY,requestedWidth,requestedHeight"; duration: priv.animationDuration}
14921652 },
14931653 Transition {
1654+ from: "normal,restored,maximized,maximizedHorizontally,maximizedVertically,maximizedLeft,maximizedRight,maximizedTopLeft,maximizedBottomLeft,maximizedTopRight,maximizedBottomRight,staged,stagedWithSideStage,windowedRightEdge,stagedRightEdge";
14941655 to: "spread"
14951656 // DecoratedWindow wants the scaleToPreviewSize set before enabling scaleToPreview
14961657 PropertyAction { target: appDelegate; properties: "z,visible" }
@@ -1576,7 +1737,7 @@ FocusScope {
15761737 ]
15771738
15781739 Binding {
1579− target: PanelState
1740+ target: panelState
15801741 property: "decorationsAlwaysVisible"
15811742 value: appDelegate && appDelegate.maximized && touchControls.overlayShown
15821743 }
@@ -1597,6 +1758,7 @@ FocusScope {
15971758 borderThickness: units.gu(2)
15981759 enabled: false
15991760 visible: enabled
1761+ readyToAssesBounds: !appDelegate._constructing
16001762
16011763 onPressed: {
16021764 appDelegate.activate();
@@ -1620,17 +1782,12 @@ FocusScope {
16201782 height: implicitHeight
16211783 highlightSize: windowInfoItem.iconMargin / 2
16221784 boundsItem: boundariesForWindowPlacement
1785+ panelState: root.panelState
16231786 altDragEnabled: root.mode == "windowed"
16241787
16251788 requestedWidth: appDelegate.requestedWidth
16261789 requestedHeight: appDelegate.requestedHeight
16271790
1628− property int oldRequestedWidth: -1
1629− property int oldRequestedHeight: -1
1630−
1631− onRequestedWidthChanged: oldRequestedWidth = requestedWidth
1632− onRequestedHeightChanged: oldRequestedHeight = requestedHeight
1633−
16341791 onCloseClicked: { appDelegate.close(); }
16351792 onMaximizeClicked: {
16361793 if (appDelegate.canBeMaximized) {
@@ -1711,6 +1868,8 @@ FocusScope {
17111868 anchors.fill: decoratedWindow
17121869 enabled: false
17131870 closeable: !appDelegate.isDash
1871+ stage: root
1872+ dragDelegate: fakeDragItem
17141873
17151874 onClicked: {
17161875 spreadItem.highlightedIndex = index;
@@ -1753,12 +1912,15 @@ FocusScope {
17531912 objectName: "closeMouseArea"
17541913 anchors { left: parent.left; top: parent.top; leftMargin: -height / 2; topMargin: -height / 2 + spreadMaths.closeIconOffset }
17551914 readonly property var mousePos: hoverMouseArea.mapToItem(appDelegate, hoverMouseArea.mouseX, hoverMouseArea.mouseY)
1756− visible: !appDelegate.isDash && dragArea.distance == 0
1915+ readonly property bool shown: !appDelegate.isDash && dragArea.distance == 0
17571916 && index == spreadItem.highlightedIndex
17581917 && mousePos.y < (decoratedWindow.height / 3)
17591918 && mousePos.y > -units.gu(4)
17601919 && mousePos.x > -units.gu(4)
17611920 && mousePos.x < (decoratedWindow.width * 2 / 3)
1921+ opacity: shown ? 1 : 0
1922+ visible: opacity > 0
1923+ Behavior on opacity { UbuntuNumberAnimation { duration: UbuntuAnimation.SnapDuration } }
17621924 height: units.gu(6)
17631925 width: height
17641926
@@ -1820,83 +1982,19 @@ FocusScope {
18201982 leftMargin: root.leftMargin
18211983 appContainerWidth: appContainer.width
18221984 appContainerHeight: appContainer.height
1985+ panelState: root.panelState
18231986 }
18241987
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();
1988+ WorkspaceSwitcher {
1989+ id: workspaceSwitcher
1990+ anchors.centerIn: parent
1991+ height: units.gu(20)
1992+ background: root.background
1993+ onActiveChanged: {
1994+ if (!active) {
1995+ appContainer.focus = true;
18971996 }
18981997 }
1899− UbuntuNumberAnimation {id: snapAnimation; target: floatingFlickable; property: "contentX"}
19001998 }
19011999
19022000 PropertyAnimation {