@@ -1,5 +1,5 @@
2− * Copyright (C) 2014-2016 Canonical, Ltd.
2+ * Copyright (C) 2014-2017 Canonical, Ltd.
4 * This program is free software; you can redistribute it and/or modify
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
5 * it under the terms of the GNU General Public License as published by
@@ -25,6 +25,7 @@ import GlobalShortcut 1.0
25import GSettings 1.0
25import GSettings 1.0
26import "Spread"
26import "Spread"
27import "Spread/MathUtils.js" as MathUtils
27import "Spread/MathUtils.js" as MathUtils
28+import WindowManager 1.0
29FocusScope {
30FocusScope {
@@ -43,10 +44,10 @@ FocusScope {
43 property int shellOrientationAngle
44 property int shellOrientationAngle
44 property bool spreadEnabled: true // If false, animations and right edge will be disabled
45 property bool spreadEnabled: true // If false, animations and right edge will be disabled
45 property bool suspended
46 property bool suspended
46− property int leftMargin: 0
47 property bool oskEnabled: false
47 property bool oskEnabled: false
48 property rect inputMethodRect
48 property rect inputMethodRect
49 property real rightEdgePushProgress: 0
49 property real rightEdgePushProgress: 0
50+ property Item availableDesktopArea
51 // Configuration
52 // Configuration
52 property string mode: "staged"
53 property string mode: "staged"
@@ -120,6 +121,12 @@ FocusScope {
124+ // For MirAL window management
126+ normal: Qt.rect(0, root.mode === "windowed" ? priv.windowDecorationHeight : 0, 0, 0)
123 property Item itemConfiningMouseCursor: !spreadShown && priv.focusedAppDelegate && priv.focusedAppDelegate.window.confinesMousePointer ?
130 property Item itemConfiningMouseCursor: !spreadShown && priv.focusedAppDelegate && priv.focusedAppDelegate.window.confinesMousePointer ?
124 priv.focusedAppDelegate.clientAreaItem : null;
131 priv.focusedAppDelegate.clientAreaItem : null;
@@ -367,6 +374,8 @@ FocusScope {
369 readonly property real virtualKeyboardHeight: root.inputMethodRect.height
376 readonly property real virtualKeyboardHeight: root.inputMethodRect.height
378+ readonly property real windowDecorationHeight: units.gu(3)
372 Component.onCompleted: priv.updateMainAndSideStageIndexes();
381 Component.onCompleted: priv.updateMainAndSideStageIndexes();
@@ -587,7 +596,7 @@ FocusScope {
587 id: spreadItem
596 id: spreadItem
588 objectName: "spreadItem"
597 objectName: "spreadItem"
589 anchors.fill: appContainer
598 anchors.fill: appContainer
590− leftMargin: root.leftMargin
599+ leftMargin: root.availableDesktopArea.x
591 model: root.topLevelSurfaceList
600 model: root.topLevelSurfaceList
592 spreadFlickable: floatingFlickable
601 spreadFlickable: floatingFlickable
@@ -695,13 +704,6 @@ FocusScope {
699− id: boundariesForWindowPlacement
700− anchors.fill: parent
701− anchors.topMargin: PanelState.panelHeight
705 Repeater {
707 Repeater {
706 id: appRepeater
708 id: appRepeater
707 model: topLevelSurfaceList
709 model: topLevelSurfaceList
@@ -799,7 +801,7 @@ FocusScope {
799 target: appDelegate
801 target: appDelegate
800 property: "y"
802 property: "y"
801 value: appDelegate.requestedY -
803 value: appDelegate.requestedY -
802− Math.min(appDelegate.requestedY - PanelState.panelHeight,
804+ Math.min(appDelegate.requestedY - root.availableDesktopArea.y,
803 Math.max(0, priv.virtualKeyboardHeight - (appContainer.height - (appDelegate.requestedY + appDelegate.height))))
805 Math.max(0, priv.virtualKeyboardHeight - (appContainer.height - (appDelegate.requestedY + appDelegate.height))))
804 when: root.oskEnabled && appDelegate.focus && (appDelegate.state == "normal" || appDelegate.state == "restored")
806 when: root.oskEnabled && appDelegate.focus && (appDelegate.state == "normal" || appDelegate.state == "restored")
805 && root.inputMethodRect.height > 0
807 && root.inputMethodRect.height > 0
@@ -817,8 +819,8 @@ FocusScope {
817 angleDiff = (360 + angleDiff) % 360;
819 angleDiff = (360 + angleDiff) % 360;
818 if (angleDiff === 90 || angleDiff === 270) {
820 if (angleDiff === 90 || angleDiff === 270) {
819 var aux = decoratedWindow.requestedHeight;
821 var aux = decoratedWindow.requestedHeight;
820− decoratedWindow.requestedHeight = decoratedWindow.requestedWidth + decoratedWindow.decorationHeight;
822+ decoratedWindow.requestedHeight = decoratedWindow.requestedWidth + decoratedWindow.actualDecorationHeight;
821− decoratedWindow.requestedWidth = aux - decoratedWindow.decorationHeight;
823+ decoratedWindow.requestedWidth = aux - decoratedWindow.actualDecorationHeight;
824 decoratedWindow.surfaceOrientationAngle = shellOrientationAngle;
826 decoratedWindow.surfaceOrientationAngle = shellOrientationAngle;
@@ -934,8 +936,8 @@ FocusScope {
934 target: appDelegate
936 target: appDelegate
935 screenWidth: appContainer.width
937 screenWidth: appContainer.width
936 screenHeight: appContainer.height
938 screenHeight: appContainer.height
937− leftMargin: root.leftMargin
939+ leftMargin: root.availableDesktopArea.x
938− minimumY: boundariesForWindowPlacement.y
940+ minimumY: root.availableDesktopArea.y
941 Connections {
943 Connections {
@@ -1187,7 +1189,7 @@ FocusScope {
1188 StagedRightEdgeMaths {
1190 StagedRightEdgeMaths {
1189 id: stagedRightEdgeMaths
1191 id: stagedRightEdgeMaths
1190− sceneWidth: appContainer.width - root.leftMargin
1192+ sceneWidth: root.availableDesktopArea.width
1191 sceneHeight: appContainer.height
1193 sceneHeight: appContainer.height
1192 isMainStageApp: priv.mainStageDelegate == appDelegate
1194 isMainStageApp: priv.mainStageDelegate == appDelegate
1193 isSideStageApp: priv.sideStageDelegate == appDelegate
1195 isSideStageApp: priv.sideStageDelegate == appDelegate
@@ -1198,7 +1200,7 @@ FocusScope {
1198 progress: 0
1200 progress: 0
1199 targetHeight: spreadItem.stackHeight
1201 targetHeight: spreadItem.stackHeight
1200 targetX: spreadMaths.targetX
1202 targetX: spreadMaths.targetX
1201− startY: appDelegate.fullscreen ? 0 : PanelState.panelHeight
1203+ startY: appDelegate.fullscreen ? 0 : root.availableDesktopArea.y
1202 targetY: spreadMaths.targetY
1204 targetY: spreadMaths.targetY
1203 targetAngle: spreadMaths.targetAngle
1205 targetAngle: spreadMaths.targetAngle
1204 targetScale: spreadMaths.targetScale
1206 targetScale: spreadMaths.targetScale
@@ -1319,9 +1321,9 @@ FocusScope {
1319 PropertyChanges {
1321 PropertyChanges {
1320 target: appDelegate
1322 target: appDelegate
1321 x: stageMaths.itemX
1323 x: stageMaths.itemX
1322− y: appDelegate.fullscreen ? 0 : PanelState.panelHeight
1324+ y: root.availableDesktopArea.y
1323 requestedWidth: appContainer.width
1325 requestedWidth: appContainer.width
1324− requestedHeight: appDelegate.fullscreen ? appContainer.height : appContainer.height - PanelState.panelHeight
1326+ requestedHeight: root.availableDesktopArea.height
1325 visuallyMaximized: true
1327 visuallyMaximized: true
1326 visible: appDelegate.x < root.width
1328 visible: appDelegate.x < root.width
@@ -1351,10 +1353,10 @@ FocusScope {
1351 PropertyChanges {
1353 PropertyChanges {
1352 target: appDelegate
1354 target: appDelegate
1353 x: stageMaths.itemX
1355 x: stageMaths.itemX
1354− y: appDelegate.fullscreen ? 0 : PanelState.panelHeight
1356+ y: root.availableDesktopArea.y
1355 z: stageMaths.itemZ
1357 z: stageMaths.itemZ
1356 requestedWidth: stageMaths.itemWidth
1358 requestedWidth: stageMaths.itemWidth
1357− requestedHeight: appDelegate.fullscreen ? appContainer.height : appContainer.height - PanelState.panelHeight
1359+ requestedHeight: root.availableDesktopArea.height
1358 visuallyMaximized: true
1360 visuallyMaximized: true
1359 visible: appDelegate.x < root.width
1361 visible: appDelegate.x < root.width
@@ -1375,11 +1377,11 @@ FocusScope {
1375 name: "maximized"; when: appDelegate.maximized && !appDelegate.minimized
1377 name: "maximized"; when: appDelegate.maximized && !appDelegate.minimized
1376 PropertyChanges {
1378 PropertyChanges {
1377 target: appDelegate;
1379 target: appDelegate;
1378− requestedX: root.leftMargin;
1380+ requestedX: root.availableDesktopArea.x;
1379 requestedY: 0;
1381 requestedY: 0;
1380 visuallyMinimized: false;
1382 visuallyMinimized: false;
1381 visuallyMaximized: true
1383 visuallyMaximized: true
1382− requestedWidth: appContainer.width - root.leftMargin;
1384+ requestedWidth: root.availableDesktopArea.width;
1383 requestedHeight: appContainer.height;
1385 requestedHeight: appContainer.height;
1385 PropertyChanges { target: touchControls; enabled: true }
1387 PropertyChanges { target: touchControls; enabled: true }
@@ -1423,10 +1425,10 @@ FocusScope {
1423 extend: "normal"
1425 extend: "normal"
1424 PropertyChanges {
1426 PropertyChanges {
1425 target: appDelegate
1427 target: appDelegate
1426− windowedX: root.leftMargin
1428+ windowedX: root.availableDesktopArea.x
1427− windowedY: PanelState.panelHeight
1429+ windowedY: root.availableDesktopArea.y
1428− windowedWidth: (appContainer.width - root.leftMargin)/2
1430+ windowedWidth: root.availableDesktopArea.width / 2
1429− windowedHeight: appContainer.height - PanelState.panelHeight
1431+ windowedHeight: root.availableDesktopArea.height
@@ -1434,7 +1436,7 @@ FocusScope {
1434 extend: "maximizedLeft"
1436 extend: "maximizedLeft"
1435 PropertyChanges {
1437 PropertyChanges {
1436 target: appDelegate;
1438 target: appDelegate;
1437− windowedX: (appContainer.width + root.leftMargin)/2
1439+ windowedX: root.availableDesktopArea.x + (root.availableDesktopArea.width / 2)
@@ -1442,10 +1444,10 @@ FocusScope {
1442 extend: "normal"
1444 extend: "normal"
1443 PropertyChanges {
1445 PropertyChanges {
1444 target: appDelegate
1446 target: appDelegate
1445− windowedX: root.leftMargin
1447+ windowedX: root.availableDesktopArea.x
1446− windowedY: PanelState.panelHeight
1448+ windowedY: root.availableDesktopArea.y
1447− windowedWidth: (appContainer.width - root.leftMargin)/2
1449+ windowedWidth: root.availableDesktopArea.width / 2
1448− windowedHeight: (appContainer.height - PanelState.panelHeight)/2
1450+ windowedHeight: root.availableDesktopArea.height / 2
@@ -1453,7 +1455,7 @@ FocusScope {
1453 extend: "maximizedTopLeft"
1455 extend: "maximizedTopLeft"
1454 PropertyChanges {
1456 PropertyChanges {
1455 target: appDelegate
1457 target: appDelegate
1456− windowedX: (appContainer.width + root.leftMargin)/2
1458+ windowedX: root.availableDesktopArea.x + (root.availableDesktopArea.width / 2)
@@ -1461,10 +1463,10 @@ FocusScope {
1461 extend: "normal"
1463 extend: "normal"
1462 PropertyChanges {
1464 PropertyChanges {
1463 target: appDelegate
1465 target: appDelegate
1464− windowedX: root.leftMargin
1466+ windowedX: root.availableDesktopArea.x
1465− windowedY: (appContainer.height + PanelState.panelHeight)/2
1467+ windowedY: root.availableDesktopArea.y + (root.availableDesktopArea.height / 2)
1466− windowedWidth: (appContainer.width - root.leftMargin)/2
1468+ windowedWidth: root.availableDesktopArea.width / 2
1467− windowedHeight: appContainer.height/2
1469+ windowedHeight: root.availableDesktopArea.height / 2
@@ -1472,20 +1474,26 @@ FocusScope {
1472 extend: "maximizedBottomLeft"
1474 extend: "maximizedBottomLeft"
1473 PropertyChanges {
1475 PropertyChanges {
1474 target: appDelegate
1476 target: appDelegate
1475− windowedX: (appContainer.width + root.leftMargin)/2
1477+ windowedX: root.availableDesktopArea.x + (root.availableDesktopArea.width / 2)
1479 name: "maximizedHorizontally"; when: appDelegate.maximizedHorizontally && !appDelegate.minimized
1481 name: "maximizedHorizontally"; when: appDelegate.maximizedHorizontally && !appDelegate.minimized
1480 extend: "normal"
1482 extend: "normal"
1484+ target: appDelegate
1481− PropertyChanges { target: appDelegate; windowedX: root.leftMargin; windowedY: windowedY;
1485+ windowedX: root.availableDesktopArea.x; windowedY: windowedY
1482− windowedWidth: appContainer.width - root.leftMargin; windowedHeight: windowedHeight }
1486+ windowedWidth: root.availableDesktopArea.width; windowedHeight: windowedHeight
1485 name: "maximizedVertically"; when: appDelegate.maximizedVertically && !appDelegate.minimized
1490 name: "maximizedVertically"; when: appDelegate.maximizedVertically && !appDelegate.minimized
1486 extend: "normal"
1491 extend: "normal"
1493+ target: appDelegate
1487− PropertyChanges { target: appDelegate; windowedX: windowedX; windowedY: PanelState.panelHeight;
1494+ windowedX: windowedX; windowedY: root.availableDesktopArea.y
1488− windowedWidth: windowedWidth; windowedHeight: appContainer.height - PanelState.panelHeight }
1495+ windowedWidth: windowedWidth; windowedHeight: root.availableDesktopArea.height
1491 name: "minimized"; when: appDelegate.minimized
1499 name: "minimized"; when: appDelegate.minimized
@@ -1613,7 +1621,7 @@ FocusScope {
1613 anchors.margins: touchControls.overlayShown ? borderThickness/2 : -borderThickness
1621 anchors.margins: touchControls.overlayShown ? borderThickness/2 : -borderThickness
1615 target: appDelegate
1623 target: appDelegate
1616− boundsItem: boundariesForWindowPlacement
1624+ boundsItem: root.availableDesktopArea
1617 minWidth: units.gu(10)
1625 minWidth: units.gu(10)
1618 minHeight: units.gu(10)
1626 minHeight: units.gu(10)
1619 borderThickness: units.gu(2)
1627 borderThickness: units.gu(2)
@@ -1636,13 +1644,14 @@ FocusScope {
1636 focus: true
1644 focus: true
1637 interactive: root.interactive
1645 interactive: root.interactive
1638 showDecoration: 1
1646 showDecoration: 1
1647+ decorationHeight: priv.windowDecorationHeight
1639 maximizeButtonShown: appDelegate.canBeMaximized
1648 maximizeButtonShown: appDelegate.canBeMaximized
1640 overlayShown: touchControls.overlayShown
1649 overlayShown: touchControls.overlayShown
1641 width: implicitWidth
1650 width: implicitWidth
1642 height: implicitHeight
1651 height: implicitHeight
1643 highlightSize: windowInfoItem.iconMargin / 2
1652 highlightSize: windowInfoItem.iconMargin / 2
1644− boundsItem: boundariesForWindowPlacement
1645 altDragEnabled: root.mode == "windowed"
1653 altDragEnabled: root.mode == "windowed"
1654+ boundsItem: root.availableDesktopArea
1647 requestedWidth: appDelegate.requestedWidth
1656 requestedWidth: appDelegate.requestedWidth
1648 requestedHeight: appDelegate.requestedHeight
1657 requestedHeight: appDelegate.requestedHeight
@@ -1705,7 +1714,7 @@ FocusScope {
1705 resizeArea: resizeArea
1714 resizeArea: resizeArea
1706 enabled: false
1715 enabled: false
1707 visible: enabled
1716 visible: enabled
1708− boundsItem: boundariesForWindowPlacement
1717+ boundsItem: root.availableDesktopArea
1710 onFakeMaximizeAnimationRequested: if (!appDelegate.maximized) fakeRectangle.maximize(amount, true)
1719 onFakeMaximizeAnimationRequested: if (!appDelegate.maximized) fakeRectangle.maximize(amount, true)
1711 onFakeMaximizeLeftAnimationRequested: if (!appDelegate.maximizedLeft) fakeRectangle.maximizeLeft(amount, true)
1720 onFakeMaximizeLeftAnimationRequested: if (!appDelegate.maximizedLeft) fakeRectangle.maximizeLeft(amount, true)
@@ -1826,7 +1835,8 @@ FocusScope {
1826 displacementX: appDelegate.clientAreaItem.x
1835 displacementX: appDelegate.clientAreaItem.x
1827 displacementY: appDelegate.clientAreaItem.y
1836 displacementY: appDelegate.clientAreaItem.y
1829− boundsItem: boundariesForWindowPlacement
1838+ boundsItem: root.availableDesktopArea
1839+ decorationHeight: priv.windowDecorationHeight
1831 z: childWindowRepeater.count - model.index
1841 z: childWindowRepeater.count - model.index
@@ -1847,7 +1857,7 @@ FocusScope {
1847 FakeMaximizeDelegate {
1857 FakeMaximizeDelegate {
1848 id: fakeRectangle
1858 id: fakeRectangle
1849 target: priv.focusedAppDelegate
1859 target: priv.focusedAppDelegate
1850− leftMargin: root.leftMargin
1860+ leftMargin: root.availableDesktopArea.x
1851 appContainerWidth: appContainer.width
1861 appContainerWidth: appContainer.width
1852 appContainerHeight: appContainer.height
1862 appContainerHeight: appContainer.height