@@ -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;
@@ -899,12 +921,13 @@ FocusScope {
899 priv.updateMainAndSideStageIndexes();
921 priv.updateMainAndSideStageIndexes();
901 appDelegate.focus = true;
923 appDelegate.focus = true;
924+ priv.focusedAppDelegate = appDelegate;
904 function updateQmlFocusFromMirSurfaceFocus() {
927 function updateQmlFocusFromMirSurfaceFocus() {
905 if (model.window.focused) {
928 if (model.window.focused) {
906 claimFocus();
929 claimFocus();
907− priv.focusedAppDelegate = appDelegate;
930+ decoratedWindow.focus = true;
@@ -913,8 +936,8 @@ FocusScope {
913 target: appDelegate
936 target: appDelegate
914 screenWidth: appContainer.width
937 screenWidth: appContainer.width
915 screenHeight: appContainer.height
938 screenHeight: appContainer.height
916− leftMargin: root.leftMargin
939+ leftMargin: root.availableDesktopArea.x
917− minimumY: boundariesForWindowPlacement.y
940+ minimumY: root.availableDesktopArea.y
920 Connections {
943 Connections {
@@ -1166,7 +1189,7 @@ FocusScope {
1167 StagedRightEdgeMaths {
1190 StagedRightEdgeMaths {
1168 id: stagedRightEdgeMaths
1191 id: stagedRightEdgeMaths
1169− sceneWidth: appContainer.width - root.leftMargin
1192+ sceneWidth: root.availableDesktopArea.width
1170 sceneHeight: appContainer.height
1193 sceneHeight: appContainer.height
1171 isMainStageApp: priv.mainStageDelegate == appDelegate
1194 isMainStageApp: priv.mainStageDelegate == appDelegate
1172 isSideStageApp: priv.sideStageDelegate == appDelegate
1195 isSideStageApp: priv.sideStageDelegate == appDelegate
@@ -1177,7 +1200,7 @@ FocusScope {
1177 progress: 0
1200 progress: 0
1178 targetHeight: spreadItem.stackHeight
1201 targetHeight: spreadItem.stackHeight
1179 targetX: spreadMaths.targetX
1202 targetX: spreadMaths.targetX
1180− startY: appDelegate.fullscreen ? 0 : PanelState.panelHeight
1203+ startY: appDelegate.fullscreen ? 0 : root.availableDesktopArea.y
1181 targetY: spreadMaths.targetY
1204 targetY: spreadMaths.targetY
1182 targetAngle: spreadMaths.targetAngle
1205 targetAngle: spreadMaths.targetAngle
1183 targetScale: spreadMaths.targetScale
1206 targetScale: spreadMaths.targetScale
@@ -1298,9 +1321,9 @@ FocusScope {
1298 PropertyChanges {
1321 PropertyChanges {
1299 target: appDelegate
1322 target: appDelegate
1300 x: stageMaths.itemX
1323 x: stageMaths.itemX
1301− y: appDelegate.fullscreen ? 0 : PanelState.panelHeight
1324+ y: root.availableDesktopArea.y
1302 requestedWidth: appContainer.width
1325 requestedWidth: appContainer.width
1303− requestedHeight: appDelegate.fullscreen ? appContainer.height : appContainer.height - PanelState.panelHeight
1326+ requestedHeight: root.availableDesktopArea.height
1304 visuallyMaximized: true
1327 visuallyMaximized: true
1305 visible: appDelegate.x < root.width
1328 visible: appDelegate.x < root.width
@@ -1330,10 +1353,10 @@ FocusScope {
1330 PropertyChanges {
1353 PropertyChanges {
1331 target: appDelegate
1354 target: appDelegate
1332 x: stageMaths.itemX
1355 x: stageMaths.itemX
1333− y: appDelegate.fullscreen ? 0 : PanelState.panelHeight
1356+ y: root.availableDesktopArea.y
1334 z: stageMaths.itemZ
1357 z: stageMaths.itemZ
1335 requestedWidth: stageMaths.itemWidth
1358 requestedWidth: stageMaths.itemWidth
1336− requestedHeight: appDelegate.fullscreen ? appContainer.height : appContainer.height - PanelState.panelHeight
1359+ requestedHeight: root.availableDesktopArea.height
1337 visuallyMaximized: true
1360 visuallyMaximized: true
1338 visible: appDelegate.x < root.width
1361 visible: appDelegate.x < root.width
@@ -1354,11 +1377,11 @@ FocusScope {
1354 name: "maximized"; when: appDelegate.maximized && !appDelegate.minimized
1377 name: "maximized"; when: appDelegate.maximized && !appDelegate.minimized
1355 PropertyChanges {
1378 PropertyChanges {
1356 target: appDelegate;
1379 target: appDelegate;
1357− requestedX: root.leftMargin;
1380+ requestedX: root.availableDesktopArea.x;
1358 requestedY: 0;
1381 requestedY: 0;
1359 visuallyMinimized: false;
1382 visuallyMinimized: false;
1360 visuallyMaximized: true
1383 visuallyMaximized: true
1361− requestedWidth: appContainer.width - root.leftMargin;
1384+ requestedWidth: root.availableDesktopArea.width;
1362 requestedHeight: appContainer.height;
1385 requestedHeight: appContainer.height;
1364 PropertyChanges { target: touchControls; enabled: true }
1387 PropertyChanges { target: touchControls; enabled: true }
@@ -1391,6 +1414,7 @@ FocusScope {
1391 when: appDelegate.windowState == WindowStateStorage.WindowStateRestored
1414 when: appDelegate.windowState == WindowStateStorage.WindowStateRestored
1392 extend: "normal"
1415 extend: "normal"
1393 PropertyChanges {
1416 PropertyChanges {
1417+ restoreEntryValues: false
1394 target: appDelegate;
1418 target: appDelegate;
1395 windowedX: restoredX;
1419 windowedX: restoredX;
1396 windowedY: restoredY;
1420 windowedY: restoredY;
@@ -1401,10 +1425,10 @@ FocusScope {
1401 extend: "normal"
1425 extend: "normal"
1402 PropertyChanges {
1426 PropertyChanges {
1403 target: appDelegate
1427 target: appDelegate
1404− windowedX: root.leftMargin
1428+ windowedX: root.availableDesktopArea.x
1405− windowedY: PanelState.panelHeight
1429+ windowedY: root.availableDesktopArea.y
1406− windowedWidth: (appContainer.width - root.leftMargin)/2
1430+ windowedWidth: root.availableDesktopArea.width / 2
1407− windowedHeight: appContainer.height - PanelState.panelHeight
1431+ windowedHeight: root.availableDesktopArea.height
@@ -1412,7 +1436,7 @@ FocusScope {
1412 extend: "maximizedLeft"
1436 extend: "maximizedLeft"
1413 PropertyChanges {
1437 PropertyChanges {
1414 target: appDelegate;
1438 target: appDelegate;
1415− windowedX: (appContainer.width + root.leftMargin)/2
1439+ windowedX: root.availableDesktopArea.x + (root.availableDesktopArea.width / 2)
@@ -1420,10 +1444,10 @@ FocusScope {
1420 extend: "normal"
1444 extend: "normal"
1421 PropertyChanges {
1445 PropertyChanges {
1422 target: appDelegate
1446 target: appDelegate
1423− windowedX: root.leftMargin
1447+ windowedX: root.availableDesktopArea.x
1424− windowedY: PanelState.panelHeight
1448+ windowedY: root.availableDesktopArea.y
1425− windowedWidth: (appContainer.width - root.leftMargin)/2
1449+ windowedWidth: root.availableDesktopArea.width / 2
1426− windowedHeight: (appContainer.height - PanelState.panelHeight)/2
1450+ windowedHeight: root.availableDesktopArea.height / 2
@@ -1431,7 +1455,7 @@ FocusScope {
1431 extend: "maximizedTopLeft"
1455 extend: "maximizedTopLeft"
1432 PropertyChanges {
1456 PropertyChanges {
1433 target: appDelegate
1457 target: appDelegate
1434− windowedX: (appContainer.width + root.leftMargin)/2
1458+ windowedX: root.availableDesktopArea.x + (root.availableDesktopArea.width / 2)
@@ -1439,10 +1463,10 @@ FocusScope {
1439 extend: "normal"
1463 extend: "normal"
1440 PropertyChanges {
1464 PropertyChanges {
1441 target: appDelegate
1465 target: appDelegate
1442− windowedX: root.leftMargin
1466+ windowedX: root.availableDesktopArea.x
1443− windowedY: (appContainer.height + PanelState.panelHeight)/2
1467+ windowedY: root.availableDesktopArea.y + (root.availableDesktopArea.height / 2)
1444− windowedWidth: (appContainer.width - root.leftMargin)/2
1468+ windowedWidth: root.availableDesktopArea.width / 2
1445− windowedHeight: appContainer.height/2
1469+ windowedHeight: root.availableDesktopArea.height / 2
@@ -1450,20 +1474,26 @@ FocusScope {
1450 extend: "maximizedBottomLeft"
1474 extend: "maximizedBottomLeft"
1451 PropertyChanges {
1475 PropertyChanges {
1452 target: appDelegate
1476 target: appDelegate
1453− windowedX: (appContainer.width + root.leftMargin)/2
1477+ windowedX: root.availableDesktopArea.x + (root.availableDesktopArea.width / 2)
1457 name: "maximizedHorizontally"; when: appDelegate.maximizedHorizontally && !appDelegate.minimized
1481 name: "maximizedHorizontally"; when: appDelegate.maximizedHorizontally && !appDelegate.minimized
1458 extend: "normal"
1482 extend: "normal"
1484+ target: appDelegate
1459− PropertyChanges { target: appDelegate; windowedX: root.leftMargin; windowedY: windowedY;
1485+ windowedX: root.availableDesktopArea.x; windowedY: windowedY
1460− windowedWidth: appContainer.width - root.leftMargin; windowedHeight: windowedHeight }
1486+ windowedWidth: root.availableDesktopArea.width; windowedHeight: windowedHeight
1463 name: "maximizedVertically"; when: appDelegate.maximizedVertically && !appDelegate.minimized
1490 name: "maximizedVertically"; when: appDelegate.maximizedVertically && !appDelegate.minimized
1464 extend: "normal"
1491 extend: "normal"
1493+ target: appDelegate
1465− PropertyChanges { target: appDelegate; windowedX: windowedX; windowedY: PanelState.panelHeight;
1494+ windowedX: windowedX; windowedY: root.availableDesktopArea.y
1466− windowedWidth: windowedWidth; windowedHeight: appContainer.height - PanelState.panelHeight }
1495+ windowedWidth: windowedWidth; windowedHeight: root.availableDesktopArea.height
1469 name: "minimized"; when: appDelegate.minimized
1499 name: "minimized"; when: appDelegate.minimized
@@ -1591,7 +1621,7 @@ FocusScope {
1591 anchors.margins: touchControls.overlayShown ? borderThickness/2 : -borderThickness
1621 anchors.margins: touchControls.overlayShown ? borderThickness/2 : -borderThickness
1593 target: appDelegate
1623 target: appDelegate
1594− boundsItem: boundariesForWindowPlacement
1624+ boundsItem: root.availableDesktopArea
1595 minWidth: units.gu(10)
1625 minWidth: units.gu(10)
1596 minHeight: units.gu(10)
1626 minHeight: units.gu(10)
1597 borderThickness: units.gu(2)
1627 borderThickness: units.gu(2)
@@ -1614,13 +1644,14 @@ FocusScope {
1614 focus: true
1644 focus: true
1615 interactive: root.interactive
1645 interactive: root.interactive
1616 showDecoration: 1
1646 showDecoration: 1
1647+ decorationHeight: priv.windowDecorationHeight
1617 maximizeButtonShown: appDelegate.canBeMaximized
1648 maximizeButtonShown: appDelegate.canBeMaximized
1618 overlayShown: touchControls.overlayShown
1649 overlayShown: touchControls.overlayShown
1619 width: implicitWidth
1650 width: implicitWidth
1620 height: implicitHeight
1651 height: implicitHeight
1621 highlightSize: windowInfoItem.iconMargin / 2
1652 highlightSize: windowInfoItem.iconMargin / 2
1622− boundsItem: boundariesForWindowPlacement
1623 altDragEnabled: root.mode == "windowed"
1653 altDragEnabled: root.mode == "windowed"
1654+ boundsItem: root.availableDesktopArea
1625 requestedWidth: appDelegate.requestedWidth
1656 requestedWidth: appDelegate.requestedWidth
1626 requestedHeight: appDelegate.requestedHeight
1657 requestedHeight: appDelegate.requestedHeight
@@ -1683,7 +1714,7 @@ FocusScope {
1683 resizeArea: resizeArea
1714 resizeArea: resizeArea
1684 enabled: false
1715 enabled: false
1685 visible: enabled
1716 visible: enabled
1686− boundsItem: boundariesForWindowPlacement
1717+ boundsItem: root.availableDesktopArea
1688 onFakeMaximizeAnimationRequested: if (!appDelegate.maximized) fakeRectangle.maximize(amount, true)
1719 onFakeMaximizeAnimationRequested: if (!appDelegate.maximized) fakeRectangle.maximize(amount, true)
1689 onFakeMaximizeLeftAnimationRequested: if (!appDelegate.maximizedLeft) fakeRectangle.maximizeLeft(amount, true)
1720 onFakeMaximizeLeftAnimationRequested: if (!appDelegate.maximizedLeft) fakeRectangle.maximizeLeft(amount, true)
@@ -1804,9 +1835,18 @@ FocusScope {
1804 displacementX: appDelegate.clientAreaItem.x
1835 displacementX: appDelegate.clientAreaItem.x
1805 displacementY: appDelegate.clientAreaItem.y
1836 displacementY: appDelegate.clientAreaItem.y
1807− boundsItem: boundariesForWindowPlacement
1838+ boundsItem: root.availableDesktopArea
1839+ decorationHeight: priv.windowDecorationHeight
1809 z: childWindowRepeater.count - model.index
1841 z: childWindowRepeater.count - model.index
1845+ // some child surface in this tree got focus.
1846+ // Ensure we also have it at the top-level hierarchy
1847+ appDelegate.claimFocus();
@@ -1817,7 +1857,7 @@ FocusScope {
1817 FakeMaximizeDelegate {
1857 FakeMaximizeDelegate {
1818 id: fakeRectangle
1858 id: fakeRectangle
1819 target: priv.focusedAppDelegate
1859 target: priv.focusedAppDelegate
1820− leftMargin: root.leftMargin
1860+ leftMargin: root.availableDesktopArea.x
1821 appContainerWidth: appContainer.width
1861 appContainerWidth: appContainer.width
1822 appContainerHeight: appContainer.height
1862 appContainerHeight: appContainer.height