@@ -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
@@ -44,10 +44,10 @@ FocusScope {
44 property int shellOrientationAngle
44 property int shellOrientationAngle
45 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
46 property bool suspended
46 property bool suspended
47− property int leftMargin: 0
48 property bool oskEnabled: false
47 property bool oskEnabled: false
49 property rect inputMethodRect
48 property rect inputMethodRect
50 property real rightEdgePushProgress: 0
49 property real rightEdgePushProgress: 0
50+ property Item availableDesktopArea
51 property PanelState panelState
51 property PanelState panelState
53 readonly property var temporarySelectedWorkspace: state == "spread" ? screensAndWorkspaces.lastClickedWorkspace : null
53 readonly property var temporarySelectedWorkspace: state == "spread" ? screensAndWorkspaces.lastClickedWorkspace : null
@@ -124,6 +124,12 @@ FocusScope {
127+ // For MirAL window management
129+ normal: Qt.rect(0, root.mode === "windowed" ? priv.windowDecorationHeight : 0, 0, 0)
127 property Item itemConfiningMouseCursor: !spreadShown && priv.focusedAppDelegate && priv.focusedAppDelegate.window.confinesMousePointer ?
133 property Item itemConfiningMouseCursor: !spreadShown && priv.focusedAppDelegate && priv.focusedAppDelegate.window.confinesMousePointer ?
128 priv.focusedAppDelegate.clientAreaItem : null;
134 priv.focusedAppDelegate.clientAreaItem : null;
@@ -228,6 +234,18 @@ FocusScope {
228 active: priv.focusedAppDelegate !== null
234 active: priv.focusedAppDelegate !== null
238+ shortcut: Qt.ControlModifier|Qt.AltModifier|Qt.Key_T
240+ // try in this order: snap pkg, new deb name, old deb name
241+ var candidates = ["ubuntu-terminal-app_ubuntu-terminal-app", "ubuntu-terminal-app", "com.ubuntu.terminal"];
242+ for (var i = 0; i < candidates.length; i++) {
243+ if (priv.startApp(candidates[i]))
231 GlobalShortcut {
249 GlobalShortcut {
232 id: showWorkspaceSwitcherShortcutLeft
250 id: showWorkspaceSwitcherShortcutLeft
233 shortcut: Qt.AltModifier|Qt.ControlModifier|Qt.Key_Left
251 shortcut: Qt.AltModifier|Qt.ControlModifier|Qt.Key_Left
@@ -251,6 +269,14 @@ FocusScope {
252 objectName: "DesktopStagePrivate"
270 objectName: "DesktopStagePrivate"
272+ function startApp(appId) {
273+ if (root.applicationManager.findApplication(appId)) {
274+ return root.applicationManager.requestFocusApplication(appId);
276+ return root.applicationManager.startApplication(appId) !== null;
254 property var focusedAppDelegate: null
280 property var focusedAppDelegate: null
255 property var foregroundMaximizedAppDelegate: null // for stuff like drop shadow and focusing maximized app by clicking panel
281 property var foregroundMaximizedAppDelegate: null // for stuff like drop shadow and focusing maximized app by clicking panel
@@ -370,6 +396,8 @@ FocusScope {
372 readonly property real virtualKeyboardHeight: root.inputMethodRect.height
398 readonly property real virtualKeyboardHeight: root.inputMethodRect.height
400+ readonly property real windowDecorationHeight: units.gu(3)
375 Component.onCompleted: priv.updateMainAndSideStageIndexes()
403 Component.onCompleted: priv.updateMainAndSideStageIndexes()
@@ -610,7 +638,7 @@ FocusScope {
610 id: spreadItem
638 id: spreadItem
611 objectName: "spreadItem"
639 objectName: "spreadItem"
612 anchors { left: parent.left; bottom: parent.bottom; right: parent.right; top: screensAndWorkspaces.bottom }
640 anchors { left: parent.left; bottom: parent.bottom; right: parent.right; top: screensAndWorkspaces.bottom }
613− leftMargin: root.leftMargin
641+ leftMargin: root.availableDesktopArea.x
614 model: root.topLevelSurfaceList
642 model: root.topLevelSurfaceList
615 spreadFlickable: floatingFlickable
643 spreadFlickable: floatingFlickable
@@ -813,13 +841,6 @@ FocusScope {
817− id: boundariesForWindowPlacement
818− anchors.fill: parent
819− anchors.topMargin: panelState.panelHeight
823 Repeater {
844 Repeater {
824 id: appRepeater
845 id: appRepeater
825 model: topLevelSurfaceList
846 model: topLevelSurfaceList
@@ -920,7 +941,7 @@ FocusScope {
920 target: appDelegate
941 target: appDelegate
921 property: "y"
942 property: "y"
922 value: appDelegate.requestedY -
943 value: appDelegate.requestedY -
923− Math.min(appDelegate.requestedY - panelState.panelHeight,
944+ Math.min(appDelegate.requestedY - root.availableDesktopArea.y,
924 Math.max(0, priv.virtualKeyboardHeight - (appContainer.height - (appDelegate.requestedY + appDelegate.height))))
945 Math.max(0, priv.virtualKeyboardHeight - (appContainer.height - (appDelegate.requestedY + appDelegate.height))))
925 when: root.oskEnabled && appDelegate.focus && (appDelegate.state == "normal" || appDelegate.state == "restored")
946 when: root.oskEnabled && appDelegate.focus && (appDelegate.state == "normal" || appDelegate.state == "restored")
926 && root.inputMethodRect.height > 0
947 && root.inputMethodRect.height > 0
@@ -938,8 +959,8 @@ FocusScope {
938 angleDiff = (360 + angleDiff) % 360;
959 angleDiff = (360 + angleDiff) % 360;
939 if (angleDiff === 90 || angleDiff === 270) {
960 if (angleDiff === 90 || angleDiff === 270) {
940 var aux = decoratedWindow.requestedHeight;
961 var aux = decoratedWindow.requestedHeight;
941− decoratedWindow.requestedHeight = decoratedWindow.requestedWidth + decoratedWindow.decorationHeight;
962+ decoratedWindow.requestedHeight = decoratedWindow.requestedWidth + decoratedWindow.actualDecorationHeight;
942− decoratedWindow.requestedWidth = aux - decoratedWindow.decorationHeight;
963+ decoratedWindow.requestedWidth = aux - decoratedWindow.actualDecorationHeight;
945 decoratedWindow.surfaceOrientationAngle = shellOrientationAngle;
966 decoratedWindow.surfaceOrientationAngle = shellOrientationAngle;
@@ -1039,12 +1060,13 @@ FocusScope {
1039 priv.updateMainAndSideStageIndexes();
1060 priv.updateMainAndSideStageIndexes();
1041 appDelegate.focus = true;
1062 appDelegate.focus = true;
1063+ priv.focusedAppDelegate = appDelegate;
1044 function updateQmlFocusFromMirSurfaceFocus() {
1066 function updateQmlFocusFromMirSurfaceFocus() {
1045 if (model.window.focused) {
1067 if (model.window.focused) {
1046 claimFocus();
1068 claimFocus();
1047− priv.focusedAppDelegate = appDelegate;
1069+ decoratedWindow.focus = true;
@@ -1053,8 +1075,8 @@ FocusScope {
1053 target: appDelegate
1075 target: appDelegate
1054 screenWidth: appContainer.width
1076 screenWidth: appContainer.width
1055 screenHeight: appContainer.height
1077 screenHeight: appContainer.height
1056− leftMargin: root.leftMargin
1078+ leftMargin: root.availableDesktopArea.x
1057− minimumY: boundariesForWindowPlacement.y
1079+ minimumY: root.availableDesktopArea.y
1060 Connections {
1082 Connections {
@@ -1306,7 +1328,7 @@ FocusScope {
1307 StagedRightEdgeMaths {
1329 StagedRightEdgeMaths {
1308 id: stagedRightEdgeMaths
1330 id: stagedRightEdgeMaths
1309− sceneWidth: appContainer.width - root.leftMargin
1331+ sceneWidth: root.availableDesktopArea.width
1310 sceneHeight: appContainer.height
1332 sceneHeight: appContainer.height
1311 isMainStageApp: priv.mainStageDelegate == appDelegate
1333 isMainStageApp: priv.mainStageDelegate == appDelegate
1312 isSideStageApp: priv.sideStageDelegate == appDelegate
1334 isSideStageApp: priv.sideStageDelegate == appDelegate
@@ -1317,7 +1339,7 @@ FocusScope {
1317 progress: 0
1339 progress: 0
1318 targetHeight: spreadItem.stackHeight
1340 targetHeight: spreadItem.stackHeight
1319 targetX: spreadMaths.targetX
1341 targetX: spreadMaths.targetX
1320− startY: appDelegate.fullscreen ? 0 : panelState.panelHeight
1342+ startY: appDelegate.fullscreen ? 0 : root.availableDesktopArea.y
1321 targetY: spreadMaths.targetY
1343 targetY: spreadMaths.targetY
1322 targetAngle: spreadMaths.targetAngle
1344 targetAngle: spreadMaths.targetAngle
1323 targetScale: spreadMaths.targetScale
1345 targetScale: spreadMaths.targetScale
@@ -1432,14 +1454,14 @@ FocusScope {
1432 PropertyChanges {
1454 PropertyChanges {
1433 target: appDelegate
1455 target: appDelegate
1434 x: stageMaths.itemX
1456 x: stageMaths.itemX
1435− y: appDelegate.fullscreen ? 0 : panelState.panelHeight
1457+ y: root.availableDesktopArea.y
1436 visuallyMaximized: true
1458 visuallyMaximized: true
1437 visible: appDelegate.x < root.width
1459 visible: appDelegate.x < root.width
1439 PropertyChanges {
1461 PropertyChanges {
1440 target: appDelegate
1462 target: appDelegate
1441 requestedWidth: appContainer.width
1463 requestedWidth: appContainer.width
1442− requestedHeight: appDelegate.fullscreen ? appContainer.height : appContainer.height - panelState.panelHeight
1464+ requestedHeight: root.availableDesktopArea.height
1443 restoreEntryValues: false
1465 restoreEntryValues: false
1445 PropertyChanges {
1467 PropertyChanges {
@@ -1468,7 +1490,7 @@ FocusScope {
1468 PropertyChanges {
1490 PropertyChanges {
1469 target: appDelegate
1491 target: appDelegate
1470 x: stageMaths.itemX
1492 x: stageMaths.itemX
1471− y: appDelegate.fullscreen ? 0 : panelState.panelHeight
1493+ y: root.availableDesktopArea.y
1472 z: stageMaths.itemZ
1494 z: stageMaths.itemZ
1473 visuallyMaximized: true
1495 visuallyMaximized: true
1474 visible: appDelegate.x < root.width
1496 visible: appDelegate.x < root.width
@@ -1476,7 +1498,7 @@ FocusScope {
1476 PropertyChanges {
1498 PropertyChanges {
1477 target: appDelegate
1499 target: appDelegate
1478 requestedWidth: stageMaths.itemWidth
1500 requestedWidth: stageMaths.itemWidth
1479− requestedHeight: appDelegate.fullscreen ? appContainer.height : appContainer.height - panelState.panelHeight
1501+ requestedHeight: root.availableDesktopArea.height
1480 restoreEntryValues: false
1502 restoreEntryValues: false
1482 PropertyChanges {
1504 PropertyChanges {
@@ -1496,15 +1518,15 @@ FocusScope {
1496 name: "maximized"; when: appDelegate.maximized && !appDelegate.minimized
1518 name: "maximized"; when: appDelegate.maximized && !appDelegate.minimized
1497 PropertyChanges {
1519 PropertyChanges {
1498 target: appDelegate;
1520 target: appDelegate;
1499− requestedX: root.leftMargin;
1521+ requestedX: root.availableDesktopArea.x;
1500 requestedY: 0;
1522 requestedY: 0;
1501 visuallyMinimized: false;
1523 visuallyMinimized: false;
1502 visuallyMaximized: true
1524 visuallyMaximized: true
1504 PropertyChanges {
1526 PropertyChanges {
1505 target: appDelegate
1527 target: appDelegate
1506− requestedWidth: appContainer.width - root.leftMargin
1528+ requestedWidth: root.availableDesktopArea.width;
1507− requestedHeight: appContainer.height
1529+ requestedHeight: appContainer.height;
1508 restoreEntryValues: false
1530 restoreEntryValues: false
1510 PropertyChanges { target: touchControls; enabled: true }
1532 PropertyChanges { target: touchControls; enabled: true }
@@ -1547,6 +1569,7 @@ FocusScope {
1547 when: appDelegate.windowState == WindowStateStorage.WindowStateRestored
1569 when: appDelegate.windowState == WindowStateStorage.WindowStateRestored
1548 extend: "normal"
1570 extend: "normal"
1549 PropertyChanges {
1571 PropertyChanges {
1572+ restoreEntryValues: false
1550 target: appDelegate;
1573 target: appDelegate;
1551 windowedX: restoredX;
1574 windowedX: restoredX;
1552 windowedY: restoredY;
1575 windowedY: restoredY;
@@ -1557,10 +1580,10 @@ FocusScope {
1557 extend: "normal"
1580 extend: "normal"
1558 PropertyChanges {
1581 PropertyChanges {
1559 target: appDelegate
1582 target: appDelegate
1560− windowedX: root.leftMargin
1583+ windowedX: root.availableDesktopArea.x
1561− windowedY: panelState.panelHeight
1584+ windowedY: root.availableDesktopArea.y
1562− windowedWidth: (appContainer.width - root.leftMargin)/2
1585+ windowedWidth: root.availableDesktopArea.width / 2
1563− windowedHeight: appContainer.height - panelState.panelHeight
1586+ windowedHeight: root.availableDesktopArea.height
@@ -1568,7 +1591,7 @@ FocusScope {
1568 extend: "maximizedLeft"
1591 extend: "maximizedLeft"
1569 PropertyChanges {
1592 PropertyChanges {
1570 target: appDelegate;
1593 target: appDelegate;
1571− windowedX: (appContainer.width + root.leftMargin)/2
1594+ windowedX: root.availableDesktopArea.x + (root.availableDesktopArea.width / 2)
@@ -1576,10 +1599,10 @@ FocusScope {
1576 extend: "normal"
1599 extend: "normal"
1577 PropertyChanges {
1600 PropertyChanges {
1578 target: appDelegate
1601 target: appDelegate
1579− windowedX: root.leftMargin
1602+ windowedX: root.availableDesktopArea.x
1580− windowedY: panelState.panelHeight
1603+ windowedY: root.availableDesktopArea.y
1581− windowedWidth: (appContainer.width - root.leftMargin)/2
1604+ windowedWidth: root.availableDesktopArea.width / 2
1582− windowedHeight: (appContainer.height - panelState.panelHeight)/2
1605+ windowedHeight: root.availableDesktopArea.height / 2
@@ -1587,7 +1610,7 @@ FocusScope {
1587 extend: "maximizedTopLeft"
1610 extend: "maximizedTopLeft"
1588 PropertyChanges {
1611 PropertyChanges {
1589 target: appDelegate
1612 target: appDelegate
1590− windowedX: (appContainer.width + root.leftMargin)/2
1613+ windowedX: root.availableDesktopArea.x + (root.availableDesktopArea.width / 2)
@@ -1595,10 +1618,10 @@ FocusScope {
1595 extend: "normal"
1618 extend: "normal"
1596 PropertyChanges {
1619 PropertyChanges {
1597 target: appDelegate
1620 target: appDelegate
1598− windowedX: root.leftMargin
1621+ windowedX: root.availableDesktopArea.x
1599− windowedY: (appContainer.height + panelState.panelHeight)/2
1622+ windowedY: root.availableDesktopArea.y + (root.availableDesktopArea.height / 2)
1600− windowedWidth: (appContainer.width - root.leftMargin)/2
1623+ windowedWidth: root.availableDesktopArea.width / 2
1601− windowedHeight: appContainer.height/2
1624+ windowedHeight: root.availableDesktopArea.height / 2
@@ -1606,20 +1629,26 @@ FocusScope {
1606 extend: "maximizedBottomLeft"
1629 extend: "maximizedBottomLeft"
1607 PropertyChanges {
1630 PropertyChanges {
1608 target: appDelegate
1631 target: appDelegate
1609− windowedX: (appContainer.width + root.leftMargin)/2
1632+ windowedX: root.availableDesktopArea.x + (root.availableDesktopArea.width / 2)
1613 name: "maximizedHorizontally"; when: appDelegate.maximizedHorizontally && !appDelegate.minimized
1636 name: "maximizedHorizontally"; when: appDelegate.maximizedHorizontally && !appDelegate.minimized
1614 extend: "normal"
1637 extend: "normal"
1639+ target: appDelegate
1615− PropertyChanges { target: appDelegate; windowedX: root.leftMargin; windowedY: windowedY;
1640+ windowedX: root.availableDesktopArea.x; windowedY: windowedY
1616− windowedWidth: appContainer.width - root.leftMargin; windowedHeight: windowedHeight }
1641+ windowedWidth: root.availableDesktopArea.width; windowedHeight: windowedHeight
1619 name: "maximizedVertically"; when: appDelegate.maximizedVertically && !appDelegate.minimized
1645 name: "maximizedVertically"; when: appDelegate.maximizedVertically && !appDelegate.minimized
1620 extend: "normal"
1646 extend: "normal"
1648+ target: appDelegate
1621− PropertyChanges { target: appDelegate; windowedX: windowedX; windowedY: panelState.panelHeight;
1649+ windowedX: windowedX; windowedY: root.availableDesktopArea.y
1622− windowedWidth: windowedWidth; windowedHeight: appContainer.height - panelState.panelHeight }
1650+ windowedWidth: windowedWidth; windowedHeight: root.availableDesktopArea.height
1625 name: "minimized"; when: appDelegate.minimized
1654 name: "minimized"; when: appDelegate.minimized
@@ -1752,7 +1781,7 @@ FocusScope {
1752 anchors.margins: touchControls.overlayShown ? borderThickness/2 : -borderThickness
1781 anchors.margins: touchControls.overlayShown ? borderThickness/2 : -borderThickness
1754 target: appDelegate
1783 target: appDelegate
1755− boundsItem: boundariesForWindowPlacement
1784+ boundsItem: root.availableDesktopArea
1756 minWidth: units.gu(10)
1785 minWidth: units.gu(10)
1757 minHeight: units.gu(10)
1786 minHeight: units.gu(10)
1758 borderThickness: units.gu(2)
1787 borderThickness: units.gu(2)
@@ -1776,12 +1805,13 @@ FocusScope {
1776 focus: true
1805 focus: true
1777 interactive: root.interactive
1806 interactive: root.interactive
1778 showDecoration: 1
1807 showDecoration: 1
1808+ decorationHeight: priv.windowDecorationHeight
1779 maximizeButtonShown: appDelegate.canBeMaximized
1809 maximizeButtonShown: appDelegate.canBeMaximized
1780 overlayShown: touchControls.overlayShown
1810 overlayShown: touchControls.overlayShown
1781 width: implicitWidth
1811 width: implicitWidth
1782 height: implicitHeight
1812 height: implicitHeight
1783 highlightSize: windowInfoItem.iconMargin / 2
1813 highlightSize: windowInfoItem.iconMargin / 2
1784− boundsItem: boundariesForWindowPlacement
1814+ boundsItem: root.availableDesktopArea
1785 panelState: root.panelState
1815 panelState: root.panelState
1786 altDragEnabled: root.mode == "windowed"
1816 altDragEnabled: root.mode == "windowed"
@@ -1840,7 +1870,7 @@ FocusScope {
1840 resizeArea: resizeArea
1870 resizeArea: resizeArea
1841 enabled: false
1871 enabled: false
1842 visible: enabled
1872 visible: enabled
1843− boundsItem: boundariesForWindowPlacement
1873+ boundsItem: root.availableDesktopArea
1845 onFakeMaximizeAnimationRequested: if (!appDelegate.maximized) fakeRectangle.maximize(amount, true)
1875 onFakeMaximizeAnimationRequested: if (!appDelegate.maximized) fakeRectangle.maximize(amount, true)
1846 onFakeMaximizeLeftAnimationRequested: if (!appDelegate.maximizedLeft) fakeRectangle.maximizeLeft(amount, true)
1876 onFakeMaximizeLeftAnimationRequested: if (!appDelegate.maximizedLeft) fakeRectangle.maximizeLeft(amount, true)
@@ -1966,9 +1996,18 @@ FocusScope {
1966 displacementX: appDelegate.clientAreaItem.x
1996 displacementX: appDelegate.clientAreaItem.x
1967 displacementY: appDelegate.clientAreaItem.y
1997 displacementY: appDelegate.clientAreaItem.y
1969− boundsItem: boundariesForWindowPlacement
1999+ boundsItem: root.availableDesktopArea
2000+ decorationHeight: priv.windowDecorationHeight
1971 z: childWindowRepeater.count - model.index
2002 z: childWindowRepeater.count - model.index
2006+ // some child surface in this tree got focus.
2007+ // Ensure we also have it at the top-level hierarchy
2008+ appDelegate.claimFocus();
@@ -1979,7 +2018,7 @@ FocusScope {
1979 FakeMaximizeDelegate {
2018 FakeMaximizeDelegate {
1980 id: fakeRectangle
2019 id: fakeRectangle
1981 target: priv.focusedAppDelegate
2020 target: priv.focusedAppDelegate
1982− leftMargin: root.leftMargin
2021+ leftMargin: root.availableDesktopArea.x
1983 appContainerWidth: appContainer.width
2022 appContainerWidth: appContainer.width
1984 appContainerHeight: appContainer.height
2023 appContainerHeight: appContainer.height
1985 panelState: root.panelState
2024 panelState: root.panelState