@@ -1,5 +1,5 @@
11/*
2− * Copyright (C) 2014-2016 Canonical, Ltd.
2+ * Copyright (C) 2014-2017 Canonical, Ltd.
33 *
44 * This program is free software; you can redistribute it and/or modify
55 * it under the terms of the GNU General Public License as published by
@@ -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
@@ -43,10 +44,10 @@ FocusScope {
4344 property int shellOrientationAngle
4445 property bool spreadEnabled: true // If false, animations and right edge will be disabled
4546 property bool suspended
46− property int leftMargin: 0
4747 property bool oskEnabled: false
4848 property rect inputMethodRect
4949 property real rightEdgePushProgress: 0
50+ property Item availableDesktopArea
5051
5152 // Configuration
5253 property string mode: "staged"
@@ -120,6 +121,12 @@ FocusScope {
120121 }
121122 }
122123
124+ // For MirAL window management
125+ WindowMargins {
126+ normal: Qt.rect(0, root.mode === "windowed" ? priv.windowDecorationHeight : 0, 0, 0)
127+ dialog: normal
128+ }
129+
123130 property Item itemConfiningMouseCursor: !spreadShown && priv.focusedAppDelegate && priv.focusedAppDelegate.window.confinesMousePointer ?
124131 priv.focusedAppDelegate.clientAreaItem : null;
125132
@@ -347,6 +354,8 @@ FocusScope {
347354 }
348355
349356 readonly property real virtualKeyboardHeight: root.inputMethodRect.height
357+
358+ readonly property real windowDecorationHeight: units.gu(3)
350359 }
351360
352361 Component.onCompleted: priv.updateMainAndSideStageIndexes();
@@ -567,7 +576,7 @@ FocusScope {
567576 id: spreadItem
568577 objectName: "spreadItem"
569578 anchors.fill: appContainer
570− leftMargin: root.leftMargin
579+ leftMargin: root.availableDesktopArea.x
571580 model: root.topLevelSurfaceList
572581 spreadFlickable: floatingFlickable
573582 z: 10
@@ -675,13 +684,6 @@ FocusScope {
675684 }
676685 }
677686
678− Item {
679− id: boundariesForWindowPlacement
680− anchors.fill: parent
681− anchors.topMargin: PanelState.panelHeight
682− visible: false
683− }
684−
685687 Repeater {
686688 id: appRepeater
687689 model: topLevelSurfaceList
@@ -779,7 +781,7 @@ FocusScope {
779781 target: appDelegate
780782 property: "y"
781783 value: appDelegate.requestedY -
782− Math.min(appDelegate.requestedY - PanelState.panelHeight,
784+ Math.min(appDelegate.requestedY - root.availableDesktopArea.y,
783785 Math.max(0, priv.virtualKeyboardHeight - (appContainer.height - (appDelegate.requestedY + appDelegate.height))))
784786 when: root.oskEnabled && appDelegate.focus && (appDelegate.state == "normal" || appDelegate.state == "restored")
785787 && root.inputMethodRect.height > 0
@@ -797,8 +799,8 @@ FocusScope {
797799 angleDiff = (360 + angleDiff) % 360;
798800 if (angleDiff === 90 || angleDiff === 270) {
799801 var aux = decoratedWindow.requestedHeight;
800− decoratedWindow.requestedHeight = decoratedWindow.requestedWidth + decoratedWindow.decorationHeight;
801− decoratedWindow.requestedWidth = aux - decoratedWindow.decorationHeight;
802+ decoratedWindow.requestedHeight = decoratedWindow.requestedWidth + decoratedWindow.actualDecorationHeight;
803+ decoratedWindow.requestedWidth = aux - decoratedWindow.actualDecorationHeight;
802804 }
803805 }
804806 decoratedWindow.surfaceOrientationAngle = shellOrientationAngle;
@@ -914,8 +916,8 @@ FocusScope {
914916 target: appDelegate
915917 screenWidth: appContainer.width
916918 screenHeight: appContainer.height
917− leftMargin: root.leftMargin
918− minimumY: boundariesForWindowPlacement.y
919+ leftMargin: root.availableDesktopArea.x
920+ minimumY: root.availableDesktopArea.y
919921 }
920922
921923 Connections {
@@ -1167,7 +1169,7 @@ FocusScope {
11671169
11681170 StagedRightEdgeMaths {
11691171 id: stagedRightEdgeMaths
1170− sceneWidth: appContainer.width - root.leftMargin
1172+ sceneWidth: root.availableDesktopArea.width
11711173 sceneHeight: appContainer.height
11721174 isMainStageApp: priv.mainStageDelegate == appDelegate
11731175 isSideStageApp: priv.sideStageDelegate == appDelegate
@@ -1178,7 +1180,7 @@ FocusScope {
11781180 progress: 0
11791181 targetHeight: spreadItem.stackHeight
11801182 targetX: spreadMaths.targetX
1181− startY: appDelegate.fullscreen ? 0 : PanelState.panelHeight
1183+ startY: appDelegate.fullscreen ? 0 : root.availableDesktopArea.y
11821184 targetY: spreadMaths.targetY
11831185 targetAngle: spreadMaths.targetAngle
11841186 targetScale: spreadMaths.targetScale
@@ -1299,9 +1301,9 @@ FocusScope {
12991301 PropertyChanges {
13001302 target: appDelegate
13011303 x: stageMaths.itemX
1302− y: appDelegate.fullscreen ? 0 : PanelState.panelHeight
1304+ y: root.availableDesktopArea.y
13031305 requestedWidth: appContainer.width
1304− requestedHeight: appDelegate.fullscreen ? appContainer.height : appContainer.height - PanelState.panelHeight
1306+ requestedHeight: root.availableDesktopArea.height
13051307 visuallyMaximized: true
13061308 visible: appDelegate.x < root.width
13071309 }
@@ -1331,10 +1333,10 @@ FocusScope {
13311333 PropertyChanges {
13321334 target: appDelegate
13331335 x: stageMaths.itemX
1334− y: appDelegate.fullscreen ? 0 : PanelState.panelHeight
1336+ y: root.availableDesktopArea.y
13351337 z: stageMaths.itemZ
13361338 requestedWidth: stageMaths.itemWidth
1337− requestedHeight: appDelegate.fullscreen ? appContainer.height : appContainer.height - PanelState.panelHeight
1339+ requestedHeight: root.availableDesktopArea.height
13381340 visuallyMaximized: true
13391341 visible: appDelegate.x < root.width
13401342 }
@@ -1355,11 +1357,11 @@ FocusScope {
13551357 name: "maximized"; when: appDelegate.maximized && !appDelegate.minimized
13561358 PropertyChanges {
13571359 target: appDelegate;
1358− requestedX: root.leftMargin;
1360+ requestedX: root.availableDesktopArea.x;
13591361 requestedY: 0;
13601362 visuallyMinimized: false;
13611363 visuallyMaximized: true
1362− requestedWidth: appContainer.width - root.leftMargin;
1364+ requestedWidth: root.availableDesktopArea.width;
13631365 requestedHeight: appContainer.height;
13641366 }
13651367 PropertyChanges { target: touchControls; enabled: true }
@@ -1402,10 +1404,10 @@ FocusScope {
14021404 extend: "normal"
14031405 PropertyChanges {
14041406 target: appDelegate
1405− windowedX: root.leftMargin
1406− windowedY: PanelState.panelHeight
1407− windowedWidth: (appContainer.width - root.leftMargin)/2
1408− windowedHeight: appContainer.height - PanelState.panelHeight
1407+ windowedX: root.availableDesktopArea.x
1408+ windowedY: root.availableDesktopArea.y
1409+ windowedWidth: root.availableDesktopArea.width / 2
1410+ windowedHeight: root.availableDesktopArea.height
14091411 }
14101412 },
14111413 State {
@@ -1413,7 +1415,7 @@ FocusScope {
14131415 extend: "maximizedLeft"
14141416 PropertyChanges {
14151417 target: appDelegate;
1416− windowedX: (appContainer.width + root.leftMargin)/2
1418+ windowedX: root.availableDesktopArea.x + (root.availableDesktopArea.width / 2)
14171419 }
14181420 },
14191421 State {
@@ -1421,10 +1423,10 @@ FocusScope {
14211423 extend: "normal"
14221424 PropertyChanges {
14231425 target: appDelegate
1424− windowedX: root.leftMargin
1425− windowedY: PanelState.panelHeight
1426− windowedWidth: (appContainer.width - root.leftMargin)/2
1427− windowedHeight: (appContainer.height - PanelState.panelHeight)/2
1426+ windowedX: root.availableDesktopArea.x
1427+ windowedY: root.availableDesktopArea.y
1428+ windowedWidth: root.availableDesktopArea.width / 2
1429+ windowedHeight: root.availableDesktopArea.height / 2
14281430 }
14291431 },
14301432 State {
@@ -1432,7 +1434,7 @@ FocusScope {
14321434 extend: "maximizedTopLeft"
14331435 PropertyChanges {
14341436 target: appDelegate
1435− windowedX: (appContainer.width + root.leftMargin)/2
1437+ windowedX: root.availableDesktopArea.x + (root.availableDesktopArea.width / 2)
14361438 }
14371439 },
14381440 State {
@@ -1440,10 +1442,10 @@ FocusScope {
14401442 extend: "normal"
14411443 PropertyChanges {
14421444 target: appDelegate
1443− windowedX: root.leftMargin
1444− windowedY: (appContainer.height + PanelState.panelHeight)/2
1445− windowedWidth: (appContainer.width - root.leftMargin)/2
1446− windowedHeight: appContainer.height/2
1445+ windowedX: root.availableDesktopArea.x
1446+ windowedY: root.availableDesktopArea.y + (root.availableDesktopArea.height / 2)
1447+ windowedWidth: root.availableDesktopArea.width / 2
1448+ windowedHeight: root.availableDesktopArea.height / 2
14471449 }
14481450 },
14491451 State {
@@ -1451,20 +1453,26 @@ FocusScope {
14511453 extend: "maximizedBottomLeft"
14521454 PropertyChanges {
14531455 target: appDelegate
1454− windowedX: (appContainer.width + root.leftMargin)/2
1456+ windowedX: root.availableDesktopArea.x + (root.availableDesktopArea.width / 2)
14551457 }
14561458 },
14571459 State {
14581460 name: "maximizedHorizontally"; when: appDelegate.maximizedHorizontally && !appDelegate.minimized
14591461 extend: "normal"
1460− PropertyChanges { target: appDelegate; windowedX: root.leftMargin; windowedY: windowedY;
1461− windowedWidth: appContainer.width - root.leftMargin; windowedHeight: windowedHeight }
1462+ PropertyChanges {
1463+ target: appDelegate
1464+ windowedX: root.availableDesktopArea.x; windowedY: windowedY
1465+ windowedWidth: root.availableDesktopArea.width; windowedHeight: windowedHeight
1466+ }
14621467 },
14631468 State {
14641469 name: "maximizedVertically"; when: appDelegate.maximizedVertically && !appDelegate.minimized
14651470 extend: "normal"
1466− PropertyChanges { target: appDelegate; windowedX: windowedX; windowedY: PanelState.panelHeight;
1467− windowedWidth: windowedWidth; windowedHeight: appContainer.height - PanelState.panelHeight }
1471+ PropertyChanges {
1472+ target: appDelegate
1473+ windowedX: windowedX; windowedY: root.availableDesktopArea.y
1474+ windowedWidth: windowedWidth; windowedHeight: root.availableDesktopArea.height
1475+ }
14681476 },
14691477 State {
14701478 name: "minimized"; when: appDelegate.minimized
@@ -1592,7 +1600,7 @@ FocusScope {
15921600 anchors.margins: touchControls.overlayShown ? borderThickness/2 : -borderThickness
15931601
15941602 target: appDelegate
1595− boundsItem: boundariesForWindowPlacement
1603+ boundsItem: root.availableDesktopArea
15961604 minWidth: units.gu(10)
15971605 minHeight: units.gu(10)
15981606 borderThickness: units.gu(2)
@@ -1615,13 +1623,14 @@ FocusScope {
16151623 focus: true
16161624 interactive: root.interactive
16171625 showDecoration: 1
1626+ decorationHeight: priv.windowDecorationHeight
16181627 maximizeButtonShown: appDelegate.canBeMaximized
16191628 overlayShown: touchControls.overlayShown
16201629 width: implicitWidth
16211630 height: implicitHeight
16221631 highlightSize: windowInfoItem.iconMargin / 2
1623− boundsItem: boundariesForWindowPlacement
16241632 altDragEnabled: root.mode == "windowed"
1633+ boundsItem: root.availableDesktopArea
16251634
16261635 requestedWidth: appDelegate.requestedWidth
16271636 requestedHeight: appDelegate.requestedHeight
@@ -1684,7 +1693,7 @@ FocusScope {
16841693 resizeArea: resizeArea
16851694 enabled: false
16861695 visible: enabled
1687− boundsItem: boundariesForWindowPlacement
1696+ boundsItem: root.availableDesktopArea
16881697
16891698 onFakeMaximizeAnimationRequested: if (!appDelegate.maximized) fakeRectangle.maximize(amount, true)
16901699 onFakeMaximizeLeftAnimationRequested: if (!appDelegate.maximizedLeft) fakeRectangle.maximizeLeft(amount, true)
@@ -1805,7 +1814,8 @@ FocusScope {
18051814 displacementX: appDelegate.clientAreaItem.x
18061815 displacementY: appDelegate.clientAreaItem.y
18071816
1808− boundsItem: boundariesForWindowPlacement
1817+ boundsItem: root.availableDesktopArea
1818+ decorationHeight: priv.windowDecorationHeight
18091819
18101820 z: childWindowRepeater.count - model.index
18111821
@@ -1826,7 +1836,7 @@ FocusScope {
18261836 FakeMaximizeDelegate {
18271837 id: fakeRectangle
18281838 target: priv.focusedAppDelegate
1829− leftMargin: root.leftMargin
1839+ leftMargin: root.availableDesktopArea.x
18301840 appContainerWidth: appContainer.width
18311841 appContainerHeight: appContainer.height
18321842 }