@@ -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;
@@ -224,10 +231,30 @@ FocusScope {
224 active: priv.focusedAppDelegate !== null
231 active: priv.focusedAppDelegate !== null
235+ shortcut: Qt.ControlModifier|Qt.AltModifier|Qt.Key_T
237+ // try in this order: snap pkg, new deb name, old deb name
238+ var candidates = ["ubuntu-terminal-app_ubuntu-terminal-app", "ubuntu-terminal-app", "com.ubuntu.terminal"];
239+ for (var i = 0; i < candidates.length; i++) {
240+ if (priv.startApp(candidates[i]))
227 QtObject {
246 QtObject {
229 objectName: "DesktopStagePrivate"
248 objectName: "DesktopStagePrivate"
250+ function startApp(appId) {
251+ if (root.applicationManager.findApplication(appId)) {
252+ return root.applicationManager.requestFocusApplication(appId);
254+ return root.applicationManager.startApplication(appId) !== null;
231 property var focusedAppDelegate: null
258 property var focusedAppDelegate: null
232 property var foregroundMaximizedAppDelegate: null // for stuff like drop shadow and focusing maximized app by clicking panel
259 property var foregroundMaximizedAppDelegate: null // for stuff like drop shadow and focusing maximized app by clicking panel
@@ -347,6 +374,8 @@ FocusScope {
349 readonly property real virtualKeyboardHeight: root.inputMethodRect.height
376 readonly property real virtualKeyboardHeight: root.inputMethodRect.height
378+ readonly property real windowDecorationHeight: units.gu(3)
352 Component.onCompleted: priv.updateMainAndSideStageIndexes();
381 Component.onCompleted: priv.updateMainAndSideStageIndexes();
@@ -567,7 +596,7 @@ FocusScope {
567 id: spreadItem
596 id: spreadItem
568 objectName: "spreadItem"
597 objectName: "spreadItem"
569 anchors.fill: appContainer
598 anchors.fill: appContainer
570− leftMargin: root.leftMargin
599+ leftMargin: root.availableDesktopArea.x
571 model: root.topLevelSurfaceList
600 model: root.topLevelSurfaceList
572 spreadFlickable: floatingFlickable
601 spreadFlickable: floatingFlickable
@@ -675,13 +704,6 @@ FocusScope {
679− id: boundariesForWindowPlacement
680− anchors.fill: parent
681− anchors.topMargin: PanelState.panelHeight
685 Repeater {
707 Repeater {
686 id: appRepeater
708 id: appRepeater
687 model: topLevelSurfaceList
709 model: topLevelSurfaceList
@@ -779,7 +801,7 @@ FocusScope {
779 target: appDelegate
801 target: appDelegate
780 property: "y"
802 property: "y"
781 value: appDelegate.requestedY -
803 value: appDelegate.requestedY -
782− Math.min(appDelegate.requestedY - PanelState.panelHeight,
804+ Math.min(appDelegate.requestedY - root.availableDesktopArea.y,
783 Math.max(0, priv.virtualKeyboardHeight - (appContainer.height - (appDelegate.requestedY + appDelegate.height))))
805 Math.max(0, priv.virtualKeyboardHeight - (appContainer.height - (appDelegate.requestedY + appDelegate.height))))
784 when: root.oskEnabled && appDelegate.focus && (appDelegate.state == "normal" || appDelegate.state == "restored")
806 when: root.oskEnabled && appDelegate.focus && (appDelegate.state == "normal" || appDelegate.state == "restored")
785 && root.inputMethodRect.height > 0
807 && root.inputMethodRect.height > 0
@@ -797,8 +819,8 @@ FocusScope {
797 angleDiff = (360 + angleDiff) % 360;
819 angleDiff = (360 + angleDiff) % 360;
798 if (angleDiff === 90 || angleDiff === 270) {
820 if (angleDiff === 90 || angleDiff === 270) {
799 var aux = decoratedWindow.requestedHeight;
821 var aux = decoratedWindow.requestedHeight;
800− decoratedWindow.requestedHeight = decoratedWindow.requestedWidth + decoratedWindow.decorationHeight;
822+ decoratedWindow.requestedHeight = decoratedWindow.requestedWidth + decoratedWindow.actualDecorationHeight;
801− decoratedWindow.requestedWidth = aux - decoratedWindow.decorationHeight;
823+ decoratedWindow.requestedWidth = aux - decoratedWindow.actualDecorationHeight;
804 decoratedWindow.surfaceOrientationAngle = shellOrientationAngle;
826 decoratedWindow.surfaceOrientationAngle = shellOrientationAngle;
@@ -914,8 +936,8 @@ FocusScope {
914 target: appDelegate
936 target: appDelegate
915 screenWidth: appContainer.width
937 screenWidth: appContainer.width
916 screenHeight: appContainer.height
938 screenHeight: appContainer.height
917− leftMargin: root.leftMargin
939+ leftMargin: root.availableDesktopArea.x
918− minimumY: boundariesForWindowPlacement.y
940+ minimumY: root.availableDesktopArea.y
921 Connections {
943 Connections {
@@ -1167,7 +1189,7 @@ FocusScope {
1168 StagedRightEdgeMaths {
1190 StagedRightEdgeMaths {
1169 id: stagedRightEdgeMaths
1191 id: stagedRightEdgeMaths
1170− sceneWidth: appContainer.width - root.leftMargin
1192+ sceneWidth: root.availableDesktopArea.width
1171 sceneHeight: appContainer.height
1193 sceneHeight: appContainer.height
1172 isMainStageApp: priv.mainStageDelegate == appDelegate
1194 isMainStageApp: priv.mainStageDelegate == appDelegate
1173 isSideStageApp: priv.sideStageDelegate == appDelegate
1195 isSideStageApp: priv.sideStageDelegate == appDelegate
@@ -1178,7 +1200,7 @@ FocusScope {
1178 progress: 0
1200 progress: 0
1179 targetHeight: spreadItem.stackHeight
1201 targetHeight: spreadItem.stackHeight
1180 targetX: spreadMaths.targetX
1202 targetX: spreadMaths.targetX
1181− startY: appDelegate.fullscreen ? 0 : PanelState.panelHeight
1203+ startY: appDelegate.fullscreen ? 0 : root.availableDesktopArea.y
1182 targetY: spreadMaths.targetY
1204 targetY: spreadMaths.targetY
1183 targetAngle: spreadMaths.targetAngle
1205 targetAngle: spreadMaths.targetAngle
1184 targetScale: spreadMaths.targetScale
1206 targetScale: spreadMaths.targetScale
@@ -1299,9 +1321,9 @@ FocusScope {
1299 PropertyChanges {
1321 PropertyChanges {
1300 target: appDelegate
1322 target: appDelegate
1301 x: stageMaths.itemX
1323 x: stageMaths.itemX
1302− y: appDelegate.fullscreen ? 0 : PanelState.panelHeight
1324+ y: root.availableDesktopArea.y
1303 requestedWidth: appContainer.width
1325 requestedWidth: appContainer.width
1304− requestedHeight: appDelegate.fullscreen ? appContainer.height : appContainer.height - PanelState.panelHeight
1326+ requestedHeight: root.availableDesktopArea.height
1305 visuallyMaximized: true
1327 visuallyMaximized: true
1306 visible: appDelegate.x < root.width
1328 visible: appDelegate.x < root.width
@@ -1331,10 +1353,10 @@ FocusScope {
1331 PropertyChanges {
1353 PropertyChanges {
1332 target: appDelegate
1354 target: appDelegate
1333 x: stageMaths.itemX
1355 x: stageMaths.itemX
1334− y: appDelegate.fullscreen ? 0 : PanelState.panelHeight
1356+ y: root.availableDesktopArea.y
1335 z: stageMaths.itemZ
1357 z: stageMaths.itemZ
1336 requestedWidth: stageMaths.itemWidth
1358 requestedWidth: stageMaths.itemWidth
1337− requestedHeight: appDelegate.fullscreen ? appContainer.height : appContainer.height - PanelState.panelHeight
1359+ requestedHeight: root.availableDesktopArea.height
1338 visuallyMaximized: true
1360 visuallyMaximized: true
1339 visible: appDelegate.x < root.width
1361 visible: appDelegate.x < root.width
@@ -1355,11 +1377,11 @@ FocusScope {
1355 name: "maximized"; when: appDelegate.maximized && !appDelegate.minimized
1377 name: "maximized"; when: appDelegate.maximized && !appDelegate.minimized
1356 PropertyChanges {
1378 PropertyChanges {
1357 target: appDelegate;
1379 target: appDelegate;
1358− requestedX: root.leftMargin;
1380+ requestedX: root.availableDesktopArea.x;
1359 requestedY: 0;
1381 requestedY: 0;
1360 visuallyMinimized: false;
1382 visuallyMinimized: false;
1361 visuallyMaximized: true
1383 visuallyMaximized: true
1362− requestedWidth: appContainer.width - root.leftMargin;
1384+ requestedWidth: root.availableDesktopArea.width;
1363 requestedHeight: appContainer.height;
1385 requestedHeight: appContainer.height;
1365 PropertyChanges { target: touchControls; enabled: true }
1387 PropertyChanges { target: touchControls; enabled: true }
@@ -1392,6 +1414,7 @@ FocusScope {
1392 when: appDelegate.windowState == WindowStateStorage.WindowStateRestored
1414 when: appDelegate.windowState == WindowStateStorage.WindowStateRestored
1393 extend: "normal"
1415 extend: "normal"
1394 PropertyChanges {
1416 PropertyChanges {
1417+ restoreEntryValues: false
1395 target: appDelegate;
1418 target: appDelegate;
1396 windowedX: restoredX;
1419 windowedX: restoredX;
1397 windowedY: restoredY;
1420 windowedY: restoredY;
@@ -1402,10 +1425,10 @@ FocusScope {
1402 extend: "normal"
1425 extend: "normal"
1403 PropertyChanges {
1426 PropertyChanges {
1404 target: appDelegate
1427 target: appDelegate
1405− windowedX: root.leftMargin
1428+ windowedX: root.availableDesktopArea.x
1406− windowedY: PanelState.panelHeight
1429+ windowedY: root.availableDesktopArea.y
1407− windowedWidth: (appContainer.width - root.leftMargin)/2
1430+ windowedWidth: root.availableDesktopArea.width / 2
1408− windowedHeight: appContainer.height - PanelState.panelHeight
1431+ windowedHeight: root.availableDesktopArea.height
@@ -1413,7 +1436,7 @@ FocusScope {
1413 extend: "maximizedLeft"
1436 extend: "maximizedLeft"
1414 PropertyChanges {
1437 PropertyChanges {
1415 target: appDelegate;
1438 target: appDelegate;
1416− windowedX: (appContainer.width + root.leftMargin)/2
1439+ windowedX: root.availableDesktopArea.x + (root.availableDesktopArea.width / 2)
@@ -1421,10 +1444,10 @@ FocusScope {
1421 extend: "normal"
1444 extend: "normal"
1422 PropertyChanges {
1445 PropertyChanges {
1423 target: appDelegate
1446 target: appDelegate
1424− windowedX: root.leftMargin
1447+ windowedX: root.availableDesktopArea.x
1425− windowedY: PanelState.panelHeight
1448+ windowedY: root.availableDesktopArea.y
1426− windowedWidth: (appContainer.width - root.leftMargin)/2
1449+ windowedWidth: root.availableDesktopArea.width / 2
1427− windowedHeight: (appContainer.height - PanelState.panelHeight)/2
1450+ windowedHeight: root.availableDesktopArea.height / 2
@@ -1432,7 +1455,7 @@ FocusScope {
1432 extend: "maximizedTopLeft"
1455 extend: "maximizedTopLeft"
1433 PropertyChanges {
1456 PropertyChanges {
1434 target: appDelegate
1457 target: appDelegate
1435− windowedX: (appContainer.width + root.leftMargin)/2
1458+ windowedX: root.availableDesktopArea.x + (root.availableDesktopArea.width / 2)
@@ -1440,10 +1463,10 @@ FocusScope {
1440 extend: "normal"
1463 extend: "normal"
1441 PropertyChanges {
1464 PropertyChanges {
1442 target: appDelegate
1465 target: appDelegate
1443− windowedX: root.leftMargin
1466+ windowedX: root.availableDesktopArea.x
1444− windowedY: (appContainer.height + PanelState.panelHeight)/2
1467+ windowedY: root.availableDesktopArea.y + (root.availableDesktopArea.height / 2)
1445− windowedWidth: (appContainer.width - root.leftMargin)/2
1468+ windowedWidth: root.availableDesktopArea.width / 2
1446− windowedHeight: appContainer.height/2
1469+ windowedHeight: root.availableDesktopArea.height / 2
@@ -1451,20 +1474,26 @@ FocusScope {
1451 extend: "maximizedBottomLeft"
1474 extend: "maximizedBottomLeft"
1452 PropertyChanges {
1475 PropertyChanges {
1453 target: appDelegate
1476 target: appDelegate
1454− windowedX: (appContainer.width + root.leftMargin)/2
1477+ windowedX: root.availableDesktopArea.x + (root.availableDesktopArea.width / 2)
1458 name: "maximizedHorizontally"; when: appDelegate.maximizedHorizontally && !appDelegate.minimized
1481 name: "maximizedHorizontally"; when: appDelegate.maximizedHorizontally && !appDelegate.minimized
1459 extend: "normal"
1482 extend: "normal"
1484+ target: appDelegate
1460− PropertyChanges { target: appDelegate; windowedX: root.leftMargin; windowedY: windowedY;
1485+ windowedX: root.availableDesktopArea.x; windowedY: windowedY
1461− windowedWidth: appContainer.width - root.leftMargin; windowedHeight: windowedHeight }
1486+ windowedWidth: root.availableDesktopArea.width; windowedHeight: windowedHeight
1464 name: "maximizedVertically"; when: appDelegate.maximizedVertically && !appDelegate.minimized
1490 name: "maximizedVertically"; when: appDelegate.maximizedVertically && !appDelegate.minimized
1465 extend: "normal"
1491 extend: "normal"
1493+ target: appDelegate
1466− PropertyChanges { target: appDelegate; windowedX: windowedX; windowedY: PanelState.panelHeight;
1494+ windowedX: windowedX; windowedY: root.availableDesktopArea.y
1467− windowedWidth: windowedWidth; windowedHeight: appContainer.height - PanelState.panelHeight }
1495+ windowedWidth: windowedWidth; windowedHeight: root.availableDesktopArea.height
1470 name: "minimized"; when: appDelegate.minimized
1499 name: "minimized"; when: appDelegate.minimized
@@ -1592,7 +1621,7 @@ FocusScope {
1592 anchors.margins: touchControls.overlayShown ? borderThickness/2 : -borderThickness
1621 anchors.margins: touchControls.overlayShown ? borderThickness/2 : -borderThickness
1594 target: appDelegate
1623 target: appDelegate
1595− boundsItem: boundariesForWindowPlacement
1624+ boundsItem: root.availableDesktopArea
1596 minWidth: units.gu(10)
1625 minWidth: units.gu(10)
1597 minHeight: units.gu(10)
1626 minHeight: units.gu(10)
1598 borderThickness: units.gu(2)
1627 borderThickness: units.gu(2)
@@ -1615,13 +1644,14 @@ FocusScope {
1615 focus: true
1644 focus: true
1616 interactive: root.interactive
1645 interactive: root.interactive
1617 showDecoration: 1
1646 showDecoration: 1
1647+ decorationHeight: priv.windowDecorationHeight
1618 maximizeButtonShown: appDelegate.canBeMaximized
1648 maximizeButtonShown: appDelegate.canBeMaximized
1619 overlayShown: touchControls.overlayShown
1649 overlayShown: touchControls.overlayShown
1620 width: implicitWidth
1650 width: implicitWidth
1621 height: implicitHeight
1651 height: implicitHeight
1622 highlightSize: windowInfoItem.iconMargin / 2
1652 highlightSize: windowInfoItem.iconMargin / 2
1623− boundsItem: boundariesForWindowPlacement
1624 altDragEnabled: root.mode == "windowed"
1653 altDragEnabled: root.mode == "windowed"
1654+ boundsItem: root.availableDesktopArea
1626 requestedWidth: appDelegate.requestedWidth
1656 requestedWidth: appDelegate.requestedWidth
1627 requestedHeight: appDelegate.requestedHeight
1657 requestedHeight: appDelegate.requestedHeight
@@ -1684,7 +1714,7 @@ FocusScope {
1684 resizeArea: resizeArea
1714 resizeArea: resizeArea
1685 enabled: false
1715 enabled: false
1686 visible: enabled
1716 visible: enabled
1687− boundsItem: boundariesForWindowPlacement
1717+ boundsItem: root.availableDesktopArea
1689 onFakeMaximizeAnimationRequested: if (!appDelegate.maximized) fakeRectangle.maximize(amount, true)
1719 onFakeMaximizeAnimationRequested: if (!appDelegate.maximized) fakeRectangle.maximize(amount, true)
1690 onFakeMaximizeLeftAnimationRequested: if (!appDelegate.maximizedLeft) fakeRectangle.maximizeLeft(amount, true)
1720 onFakeMaximizeLeftAnimationRequested: if (!appDelegate.maximizedLeft) fakeRectangle.maximizeLeft(amount, true)
@@ -1805,7 +1835,8 @@ FocusScope {
1805 displacementX: appDelegate.clientAreaItem.x
1835 displacementX: appDelegate.clientAreaItem.x
1806 displacementY: appDelegate.clientAreaItem.y
1836 displacementY: appDelegate.clientAreaItem.y
1808− boundsItem: boundariesForWindowPlacement
1838+ boundsItem: root.availableDesktopArea
1839+ decorationHeight: priv.windowDecorationHeight
1810 z: childWindowRepeater.count - model.index
1841 z: childWindowRepeater.count - model.index
@@ -1826,7 +1857,7 @@ FocusScope {
1826 FakeMaximizeDelegate {
1857 FakeMaximizeDelegate {
1827 id: fakeRectangle
1858 id: fakeRectangle
1828 target: priv.focusedAppDelegate
1859 target: priv.focusedAppDelegate
1829− leftMargin: root.leftMargin
1860+ leftMargin: root.availableDesktopArea.x
1830 appContainerWidth: appContainer.width
1861 appContainerWidth: appContainer.width
1831 appContainerHeight: appContainer.height
1862 appContainerHeight: appContainer.height