2 * Copyright (C) 2016-2017 Canonical Ltd.
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
6 * the Free Software Foundation; version 3.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19import Lomiri.Components 1.3
20import QtMir.Application 0.1
25 property alias surface: childWindow.surface
26 property real displacementX: 0
27 property real displacementY: 0
28 property alias boundsItem: childWindow.boundsItem
29 property alias decorationHeight: childWindow.decorationHeight
31 x: surface ? surface.position.x + displacementX : 0
32 y: surface ? surface.position.y + displacementY : 0
33 width: childWindow.width
34 height: childWindow.height
37 // API expected by MoveHandler (and some by WindowResizeArea as well)
38 readonly property bool maximized: false
39 readonly property bool maximizedLeft: false
40 readonly property bool maximizedRight: false
41 readonly property bool maximizedHorizontally: false
42 readonly property bool maximizedVertically: false
43 readonly property bool maximizedTopLeft: false
44 readonly property bool maximizedTopRight: false
45 readonly property bool maximizedBottomLeft: false
46 readonly property bool maximizedBottomRight: false
47 readonly property bool anyMaximized: maximized || maximizedLeft || maximizedRight || maximizedHorizontally || maximizedVertically ||
48 maximizedTopLeft || maximizedTopRight || maximizedBottomLeft || maximizedBottomRight
50 readonly property bool canBeCornerMaximized: false
51 readonly property bool canBeMaximizedLeftRight: false
52 readonly property bool canBeMaximized: false
54 readonly property var resizeArea: QtObject {
55 property real normalWidth: units.gu(1)
56 property real normalHeight: units.gu(1)
59 readonly property bool windowedTransitionRunning: false
61 // NB: those bindings will be overwritten by MoveHandler when you first move the window
62 property real windowedX: x
63 property real windowedY: y
66 // end of API expected by MoveHandler
70 // API expected by WindowResizeArea
71 property real windowedWidth: childWindow.width
72 property real windowedHeight: childWindow.height
73 // end of API expected by WindowResizeArea
77 // API expected by WindowControlsOverlay
81 // end of API expected by WindowControlsOverlay
86 restoreMode: Binding.RestoreBinding
87 when: childWindow.dragging
88 property: "requestedPosition"
89 value: Qt.point(root.windowedX - root.displacementX,
90 root.windowedY - root.displacementY);
93 // It's a separate Item so that a window can be hid independently of its children
97 requestedWidth: root.windowedWidth
98 requestedHeight: root.windowedHeight
103 function onFocusRequested() {
104 root.surface.activate();
106 function onFocusedChanged() {
107 if (root.surface.focused) {
108 childWindow.focus = true;
115 // Using a loader here mainly to circunvent the "ChildWindowTree is instantiated recursively" error from the QML engine
117 id: childRepeaterLoader
118 source: "ChildWindowRepeater.qml"
119 active: root.surface && root.surface.childSurfaceList.count > 0
121 target: childRepeaterLoader.item
122 restoreMode: Binding.RestoreBinding
123 when: childRepeaterLoader.item
125 value: root.surface ? root.surface.childSurfaceList : null
128 target: childRepeaterLoader.item
129 restoreMode: Binding.RestoreBinding
130 when: childRepeaterLoader.item
131 property: "boundsItem"
132 value: root.boundsItem
136 // A surface in some ChildWindowTree got focused.