on xenial help sign in
Don't stretch application surfaces when resizing
b71b294Daniel d'Andrada
qml/Stages/ApplicationWindow.qml+27−1
@@ -32,6 +32,8 @@ FocusScope {
32 property QtObject application
32 property QtObject application
33 property int surfaceOrientationAngle
33 property int surfaceOrientationAngle
34 property alias resizeSurface: sessionContainer.resizeSurface
34 property alias resizeSurface: sessionContainer.resizeSurface
35+ property int requestedWidth: -1
36+ property int requestedHeight: -1
35
37
36 QtObject {
38 QtObject {
37 id: d
39 id: d
@@ -133,7 +135,9 @@ FocusScope {
133 id: sessionContainer
135 id: sessionContainer
134 // A fake application might not even have a session property.
136 // A fake application might not even have a session property.
135 session: application && application.session ? application.session : null
137 session: application && application.session ? application.session : null
136− anchors.fill: parent
138+
139+ requestedWidth: root.requestedWidth
140+ requestedHeight: root.requestedHeight
137
141
138 surfaceOrientationAngle: application && application.rotatesWindowContents ? root.surfaceOrientationAngle : 0
142 surfaceOrientationAngle: application && application.rotatesWindowContents ? root.surfaceOrientationAngle : 0
139
143
@@ -148,6 +152,28 @@ FocusScope {
148 focus: true
152 focus: true
149 }
153 }
150
154
155+ // SessionContainer size drives ApplicationWindow size
156+ Binding {
157+ target: root; property: "width"
158+ value: stateGroup.state === "surface" ? sessionContainer.width : root.requestedWidth
159+ when: root.requestedWidth >= 0
160+ }
161+ Binding {
162+ target: root; property: "height"
163+ value: stateGroup.state === "surface" ? sessionContainer.height : root.requestedHeight
164+ when: root.requestedHeight >= 0
165+ }
166+
167+ // ApplicationWindow size drives SessionContainer size
168+ Binding {
169+ target: sessionContainer; property: "width"; value: root.width
170+ when: root.requestedWidth < 0
171+ }
172+ Binding {
173+ target: sessionContainer; property: "height"; value: root.height
174+ when: root.requestedHeight < 0
175+ }
176+
151 StateGroup {
177 StateGroup {
152 id: stateGroup
178 id: stateGroup
153 objectName: "applicationWindowStateGroup"
179 objectName: "applicationWindowStateGroup"
qml/Stages/DecoratedWindow.qml+7−2
@@ -23,6 +23,9 @@ import Unity.Application 0.1
23FocusScope {
23FocusScope {
24 id: root
24 id: root
25
25
26+ width: applicationWindow.width
27+ height: (root.decorationShown ? decoration.height : 0) + applicationWindow.height
28+
26 property alias window: applicationWindow
29 property alias window: applicationWindow
27 property alias application: applicationWindow.application
30 property alias application: applicationWindow.application
28 property alias active: decoration.active
31 property alias active: decoration.active
@@ -31,6 +34,9 @@ FocusScope {
31 property bool highlightShown: false
34 property bool highlightShown: false
32 property real shadowOpacity: 1
35 property real shadowOpacity: 1
33
36
37+ property alias requestedWidth: applicationWindow.requestedWidth
38+ property real requestedHeight
39+
34 signal close()
40 signal close()
35 signal maximize()
41 signal maximize()
36 signal minimize()
42 signal minimize()
@@ -80,8 +86,7 @@ FocusScope {
80 anchors.top: parent.top
86 anchors.top: parent.top
81 anchors.topMargin: decoration.height
87 anchors.topMargin: decoration.height
82 anchors.left: parent.left
88 anchors.left: parent.left
83− width: root.width
89+ requestedHeight: root.requestedHeight - (root.decorationShown ? decoration.height : 0)
84− height: root.height - decoration.height
85 interactive: true
90 interactive: true
86 focus: true
91 focus: true
87 }
92 }
qml/Stages/DesktopStage.qml+6−6
@@ -134,8 +134,10 @@ Rectangle {
134 id: appDelegate
134 id: appDelegate
135 z: ApplicationManager.count - index
135 z: ApplicationManager.count - index
136 y: units.gu(3)
136 y: units.gu(3)
137− width: units.gu(60)
137+ width: decoratedWindow.width
138− height: units.gu(50)
138+ height: decoratedWindow.height
139+ property alias requestedWidth: decoratedWindow.requestedWidth
140+ property alias requestedHeight: decoratedWindow.requestedHeight
139 focus: model.appId === priv.focusedAppId
141 focus: model.appId === priv.focusedAppId
140
142
141 property bool maximized: false
143 property bool maximized: false
@@ -177,7 +179,7 @@ Rectangle {
177 },
179 },
178 State {
180 State {
179 name: "maximized"; when: appDelegate.maximized
181 name: "maximized"; when: appDelegate.maximized
180− PropertyChanges { target: appDelegate; x: 0; y: 0; width: root.width; height: root.height }
182+ PropertyChanges { target: appDelegate; x: 0; y: 0; requestedWidth: root.width; requestedHeight: root.height }
181 },
183 },
182 State {
184 State {
183 name: "minimized"; when: appDelegate.minimized
185 name: "minimized"; when: appDelegate.minimized
@@ -188,7 +190,7 @@ Rectangle {
188 Transition {
190 Transition {
189 from: "maximized,minimized,normal,"
191 from: "maximized,minimized,normal,"
190 to: "maximized,minimized,normal,"
192 to: "maximized,minimized,normal,"
191− PropertyAnimation { target: appDelegate; properties: "x,y,opacity,width,height,scale" }
193+ PropertyAnimation { target: appDelegate; properties: "x,y,opacity,requestedWidth,requestedHeight,scale" }
192 },
194 },
193 Transition {
195 Transition {
194 from: ""
196 from: ""
@@ -227,8 +229,6 @@ Rectangle {
227 objectName: "decoratedWindow"
229 objectName: "decoratedWindow"
228 anchors.left: appDelegate.left
230 anchors.left: appDelegate.left
229 anchors.top: appDelegate.top
231 anchors.top: appDelegate.top
230− width: appDelegate.width
231− height: appDelegate.height
232 application: ApplicationManager.get(index)
232 application: ApplicationManager.get(index)
233 active: ApplicationManager.focusedApplicationId === model.appId
233 active: ApplicationManager.focusedApplicationId === model.appId
234 focus: true
234 focus: true
qml/Stages/SessionContainer.qml+25−1
@@ -29,13 +29,37 @@ FocusScope {
29 property alias surfaceOrientationAngle: _surfaceContainer.surfaceOrientationAngle
29 property alias surfaceOrientationAngle: _surfaceContainer.surfaceOrientationAngle
30 property alias resizeSurface: _surfaceContainer.resizeSurface
30 property alias resizeSurface: _surfaceContainer.resizeSurface
31
31
32+ property int requestedWidth: -1
33+ property int requestedHeight: -1
34+
32 readonly property alias surfaceContainer: _surfaceContainer
35 readonly property alias surfaceContainer: _surfaceContainer
33 SurfaceContainer {
36 SurfaceContainer {
34 id: _surfaceContainer
37 id: _surfaceContainer
35− anchors.fill: parent
38+ requestedWidth: root.requestedWidth
39+ requestedHeight: root.requestedHeight
36 surface: session ? session.surface : null
40 surface: session ? session.surface : null
37 }
41 }
38
42
43+ // SurfaceContainer size drives SessionContainer size
44+ Binding {
45+ target: root; property: "width"; value: _surfaceContainer.width
46+ when: root.requestedWidth >= 0
47+ }
48+ Binding {
49+ target: root; property: "height"; value: _surfaceContainer.height
50+ when: root.requestedHeight >= 0
51+ }
52+
53+ // SessionContainer size drives SurfaceContainer size
54+ Binding {
55+ target: _surfaceContainer; property: "width"; value: root.width
56+ when: root.requestedWidth < 0
57+ }
58+ Binding {
59+ target: _surfaceContainer; property: "height"; value: root.height
60+ when: root.requestedHeight < 0
61+ }
62+
39 Repeater {
63 Repeater {
40 id: childSessionsRepeater
64 id: childSessionsRepeater
41 model: root.childSessions
65 model: root.childSessions
qml/Stages/SurfaceContainer.qml+56−3
@@ -30,6 +30,9 @@ FocusScope {
30 property int surfaceOrientationAngle: 0
30 property int surfaceOrientationAngle: 0
31 property bool resizeSurface: true
31 property bool resizeSurface: true
32
32
33+ property int requestedWidth: -1
34+ property int requestedHeight: -1
35+
33 onSurfaceChanged: {
36 onSurfaceChanged: {
34 if (surface) {
37 if (surface) {
35 surfaceItem.surface = surface;
38 surfaceItem.surface = surface;
@@ -53,16 +56,66 @@ FocusScope {
53
56
54 consumesInput: true
57 consumesInput: true
55
58
59+ surfaceWidth: {
56− surfaceWidth: root.resizeSurface ? width : -1
60+ if (root.resizeSurface) {
57− surfaceHeight: root.resizeSurface ? height : -1
61+ if (root.requestedWidth >= 0) {
62+ return root.requestedWidth;
63+ } else {
64+ return width;
65+ }
66+ } else {
67+ return -1;
68+ }
69+ }
58
70
59− anchors.fill: root
71+ surfaceHeight: {
72+ if (root.resizeSurface) {
73+ if (root.requestedHeight >= 0) {
74+ return root.requestedHeight;
75+ } else {
76+ return height;
77+ }
78+ } else {
79+ return -1;
80+ }
81+ }
82+
83+ fillMode: root.resizeSurface ? MirSurfaceItem.PadOrCrop : MirSurfaceItem.Stretch
60 enabled: root.interactive
84 enabled: root.interactive
61 focus: true
85 focus: true
62 antialiasing: !root.interactive
86 antialiasing: !root.interactive
63 orientationAngle: root.surfaceOrientationAngle
87 orientationAngle: root.surfaceOrientationAngle
64 }
88 }
65
89
90+ // MirSurface size drives SurfaceContainer size
91+ Binding {
92+ target: surfaceItem; property: "width"; value: root.surface ? root.surface.size.width : 0
93+ when: root.requestedWidth >= 0 && root.surface
94+ }
95+ Binding {
96+ target: surfaceItem; property: "height"; value: root.surface ? root.surface.size.height : 0
97+ when: root.requestedHeight >= 0 && root.surface
98+ }
99+ Binding {
100+ target: root; property: "width"; value: surfaceItem.width
101+ when: root.requestedWidth >= 0
102+ }
103+ Binding {
104+ target: root; property: "height"; value: surfaceItem.height
105+ when: root.requestedHeight >= 0
106+ }
107+
108+ // SurfaceContainer size drives MirSurface size
109+ Binding {
110+ target: surfaceItem; property: "width"; value: root.width
111+ when: root.requestedWidth < 0
112+ }
113+ Binding {
114+ target: surfaceItem; property: "height"; value: root.height
115+ when: root.requestedHeight < 0
116+ }
117+
118+
66 TouchGate {
119 TouchGate {
67 targetItem: surfaceItem
120 targetItem: surfaceItem
68 anchors.fill: root
121 anchors.fill: root
qml/Stages/WindowResizeArea.qml+46−18
@@ -35,14 +35,26 @@ MouseArea {
35 property int borderThickness: 0
35 property int borderThickness: 0
36 property int minWidth: 0
36 property int minWidth: 0
37 property int minHeight: 0
37 property int minHeight: 0
38+ property int defaultWidth: units.gu(60)
39+ property int defaultHeight: units.gu(50)
38
40
39 Component.onCompleted: {
41 Component.onCompleted: {
40− var windowState = windowStateStorage.getGeometry(root.windowId, Qt.rect(target.x, target.y, target.width, target.height))
42+ var windowState = windowStateStorage.getGeometry(root.windowId,
43+ Qt.rect(target.x, target.y, defaultWidth, defaultHeight) /* default geometry */);
44+
45+ target.x = windowState.x;
46+ target.y = windowState.y;
47+
41− if (windowState !== undefined) {
48+ if (windowState.width >= minWidth) {
42− target.x = windowState.x
49+ target.requestedWidth = windowState.width;
50+ } else {
51+ target.requestedWidth = minWidth;
52+ }
53+
43− target.y = windowState.y
54+ if (windowState.height >= minHeight) {
44− target.width = windowState.width
55+ target.requestedHeight = windowState.height;
45− target.height = windowState.height
56+ } else {
57+ target.requestedHeight = minHeight;
46 }
58 }
47 }
59 }
48
60
@@ -64,6 +76,8 @@ MouseArea {
64 property real startY
76 property real startY
65 property real startWidth
77 property real startWidth
66 property real startHeight
78 property real startHeight
79+ property real currentWidth
80+ property real currentHeight
67
81
68 property string cursorName: {
82 property string cursorName: {
69 if (root.containsMouse || root.pressed) {
83 if (root.containsMouse || root.pressed) {
@@ -114,6 +128,8 @@ MouseArea {
114 d.startY = target.y;
128 d.startY = target.y;
115 d.startWidth = target.width;
129 d.startWidth = target.width;
116 d.startHeight = target.height;
130 d.startHeight = target.height;
131+ d.currentWidth = target.width;
132+ d.currentHeight = target.height;
117 d.dragging = true;
133 d.dragging = true;
118 } else {
134 } else {
119 d.dragging = false;
135 d.dragging = false;
@@ -146,37 +162,49 @@ MouseArea {
146 if (d.leftBorder) {
162 if (d.leftBorder) {
147 var newTargetX = d.startX + deltaX;
163 var newTargetX = d.startX + deltaX;
148 if (target.x + target.width > newTargetX + minWidth) {
164 if (target.x + target.width > newTargetX + minWidth) {
149− target.width = target.x + target.width - newTargetX;
165+ target.requestedWidth = target.x + target.width - newTargetX;
150− target.x = newTargetX;
151 } else {
166 } else {
152− target.x = target.x + target.width - minWidth;
167+ target.requestedWidth = minWidth;
153− target.width = minWidth;
154 }
168 }
155
169
156 } else if (d.rightBorder) {
170 } else if (d.rightBorder) {
157 if (d.startWidth + deltaX >= minWidth) {
171 if (d.startWidth + deltaX >= minWidth) {
158− target.width = d.startWidth + deltaX;
172+ target.requestedWidth = d.startWidth + deltaX;
159 } else {
173 } else {
160− target.width = minWidth;
174+ target.requestedWidth = minWidth;
161 }
175 }
162 }
176 }
163
177
164 if (d.topBorder) {
178 if (d.topBorder) {
165 var newTargetY = d.startY + deltaY;
179 var newTargetY = d.startY + deltaY;
166 if (target.y + target.height > newTargetY + minHeight) {
180 if (target.y + target.height > newTargetY + minHeight) {
167− target.height = target.y + target.height - newTargetY;
181+ target.requestedHeight = target.y + target.height - newTargetY;
168− target.y = newTargetY;
169 } else {
182 } else {
170− target.y = target.y + target.height - minHeight;
183+ target.requestedHeight = minHeight;
171− target.height = minHeight;
172 }
184 }
173
185
174 } else if (d.bottomBorder) {
186 } else if (d.bottomBorder) {
175 if (d.startHeight + deltaY >= minHeight) {
187 if (d.startHeight + deltaY >= minHeight) {
176− target.height = d.startHeight + deltaY;
188+ target.requestedHeight = d.startHeight + deltaY;
177 } else {
189 } else {
178− target.height = minHeight;
190+ target.requestedHeight = minHeight;
191+ }
192+ }
193+ }
194+
195+ Connections {
196+ target: root.target
197+ onWidthChanged: {
198+ if (root.pressed && d.leftBorder) {
199+ target.x += d.currentWidth - target.width;
200+ }
201+ d.currentWidth = target.width;
202+ }
203+ onHeightChanged: {
204+ if (root.pressed && d.topBorder) {
205+ target.y += d.currentHeight - target.height;
179 }
206 }
207+ d.currentHeight = target.height;
180 }
208 }
181 }
209 }
182}
210}
tests/mocks/Unity/Application/MirSurface.cpp+52
@@ -35,8 +35,12 @@ MirSurface::MirSurface(const QString& name,
35 , m_activeFocus(false)
35 , m_activeFocus(false)
36 , m_width(-1)
36 , m_width(-1)
37 , m_height(-1)
37 , m_height(-1)
38+ , m_slowToResize(false)
38{
39{
39// qDebug() << "MirSurface::MirSurface() " << name;
40// qDebug() << "MirSurface::MirSurface() " << name;
41+ m_delayedResizeTimer.setInterval(600);
42+ m_delayedResizeTimer.setSingleShot(true);
43+ connect(&m_delayedResizeTimer, &QTimer::timeout, this, &MirSurface::applyDelayedResize);
40}
44}
41
45
42MirSurface::~MirSurface()
46MirSurface::~MirSurface()
@@ -169,8 +173,39 @@ int MirSurface::height() const
169}
173}
170
174
171void MirSurface::resize(int width, int height)
175void MirSurface::resize(int width, int height)
176+{
177+ if (m_slowToResize) {
178+ if (!m_delayedResizeTimer.isActive()) {
179+ m_delayedResize.setWidth(width);
180+ m_delayedResize.setHeight(height);
181+ m_delayedResizeTimer.start();
182+ } else {
183+ m_pendingResize.setWidth(width);
184+ m_pendingResize.setHeight(height);
185+ }
186+ } else {
187+ doResize(width, height);
188+ }
189+}
190+
191+void MirSurface::applyDelayedResize()
192+{
193+ doResize(m_delayedResize.width(), m_delayedResize.height());
194+ m_delayedResize.setWidth(-1);
195+ m_delayedResize.setHeight(-1);
196+
197+ if (m_pendingResize.isValid()) {
198+ QSize size = m_pendingResize;
199+ m_pendingResize.setWidth(-1);
200+ m_pendingResize.setHeight(-1);
201+ resize(size.width(), size.height());
202+ }
203+}
204+
205+void MirSurface::doResize(int width, int height)
172{
206{
173 bool changed = false;
207 bool changed = false;
208+
174 if (width != m_width) {
209 if (width != m_width) {
175 m_width = width;
210 m_width = width;
176 Q_EMIT widthChanged();
211 Q_EMIT widthChanged();
@@ -187,3 +222,20 @@ void MirSurface::resize(int width, int height)
187 Q_EMIT sizeChanged(QSize(width, height));
222 Q_EMIT sizeChanged(QSize(width, height));
188 }
223 }
189}
224}
225+
226+bool MirSurface::isSlowToResize() const
227+{
228+ return m_slowToResize;
229+}
230+
231+void MirSurface::setSlowToResize(bool value)
232+{
233+ if (m_slowToResize != value) {
234+ m_slowToResize = value;
235+ Q_EMIT slowToResizeChanged();
236+ if (!m_slowToResize && m_delayedResizeTimer.isActive()) {
237+ m_delayedResizeTimer.stop();
238+ applyDelayedResize();
239+ }
240+ }
241+}
tests/mocks/Unity/Application/MirSurface.h+16
@@ -18,6 +18,7 @@
18#define MOCK_MIR_SURFACE_H
18#define MOCK_MIR_SURFACE_H
19
19
20#include <QObject>
20#include <QObject>
21+#include <QTimer>
21#include <QUrl>
22#include <QUrl>
22
23
23// unity-api
24// unity-api
@@ -32,6 +33,7 @@ class MirSurface : public unity::shell::application::MirSurfaceInterface
32 Q_PROPERTY(int width READ width NOTIFY widthChanged)
33 Q_PROPERTY(int width READ width NOTIFY widthChanged)
33 Q_PROPERTY(int height READ height NOTIFY heightChanged)
34 Q_PROPERTY(int height READ height NOTIFY heightChanged)
34 Q_PROPERTY(bool activeFocus READ activeFocus NOTIFY activeFocusChanged)
35 Q_PROPERTY(bool activeFocus READ activeFocus NOTIFY activeFocusChanged)
36+ Q_PROPERTY(bool slowToResize READ isSlowToResize WRITE setSlowToResize NOTIFY slowToResizeChanged)
35
37
36public:
38public:
37 MirSurface(const QString& name,
39 MirSurface(const QString& name,
@@ -73,6 +75,9 @@ public:
73 int width() const;
75 int width() const;
74 int height() const;
76 int height() const;
75
77
78+ bool isSlowToResize() const;
79+ void setSlowToResize(bool value);
80+
76 /////
81 /////
77 // internal mock stuff
82 // internal mock stuff
78
83
@@ -90,13 +95,19 @@ Q_SIGNALS:
90 void orientationAngleChanged(Mir::OrientationAngle angle);
95 void orientationAngleChanged(Mir::OrientationAngle angle);
91 void widthChanged();
96 void widthChanged();
92 void heightChanged();
97 void heightChanged();
98+ void slowToResizeChanged();
93
99
94 ////
100 ////
95 // internal mock stuff
101 // internal mock stuff
96 void screenshotUrlChanged(QUrl);
102 void screenshotUrlChanged(QUrl);
97 void activeFocusChanged(bool);
103 void activeFocusChanged(bool);
98
104
105+private Q_SLOTS:
106+ void applyDelayedResize();
107+
99private:
108private:
109+ void doResize(int width, int height);
110+
100 const QString m_name;
111 const QString m_name;
101 const Mir::Type m_type;
112 const Mir::Type m_type;
102 Mir::State m_state;
113 Mir::State m_state;
@@ -108,6 +119,11 @@ private:
108 bool m_activeFocus;
119 bool m_activeFocus;
109 int m_width;
120 int m_width;
110 int m_height;
121 int m_height;
122+
123+ bool m_slowToResize;
124+ QTimer m_delayedResizeTimer;
125+ QSize m_delayedResize;
126+ QSize m_pendingResize;
111};
127};
112
128
113#endif // MOCK_MIR_SURFACE_H
129#endif // MOCK_MIR_SURFACE_H
tests/mocks/Unity/Application/MirSurfaceItem.cpp+14
@@ -37,6 +37,7 @@ MirSurfaceItem::MirSurfaceItem(QQuickItem *parent)
37 , m_surfaceHeight(0)
37 , m_surfaceHeight(0)
38 , m_touchPressCount(0)
38 , m_touchPressCount(0)
39 , m_touchReleaseCount(0)
39 , m_touchReleaseCount(0)
40+ , m_fillMode(Stretch)
40{
41{
41// qDebug() << "MirSurfaceItem::MirSurfaceItem() " << (void*)(this) << name();
42// qDebug() << "MirSurfaceItem::MirSurfaceItem() " << (void*)(this) << name();
42 setAcceptedMouseButtons(Qt::LeftButton | Qt::MiddleButton | Qt::RightButton |
43 setAcceptedMouseButtons(Qt::LeftButton | Qt::MiddleButton | Qt::RightButton |
@@ -295,3 +296,16 @@ void MirSurfaceItem::updateSurfaceSize()
295 m_qmlSurface->resize(m_surfaceWidth, m_surfaceHeight);
296 m_qmlSurface->resize(m_surfaceWidth, m_surfaceHeight);
296 }
297 }
297}
298}
299+
300+MirSurfaceItem::FillMode MirSurfaceItem::fillMode() const
301+{
302+ return m_fillMode;
303+}
304+
305+void MirSurfaceItem::setFillMode(FillMode value)
306+{
307+ if (m_fillMode != value) {
308+ m_fillMode = value;
309+ Q_EMIT fillModeChanged(m_fillMode);
310+ }
311+}
tests/mocks/Unity/Application/MirSurfaceItem.h+5
@@ -62,6 +62,9 @@ public:
62 int surfaceHeight() const override;
62 int surfaceHeight() const override;
63 void setSurfaceHeight(int value) override;
63 void setSurfaceHeight(int value) override;
64
64
65+ FillMode fillMode() const override;
66+ void setFillMode(FillMode value) override;
67+
65 /////
68 /////
66 // For use in qml tests
69 // For use in qml tests
67
70
@@ -106,6 +109,8 @@ private:
106 int m_touchPressCount;
109 int m_touchPressCount;
107 int m_touchReleaseCount;
110 int m_touchReleaseCount;
108
111
112+ FillMode m_fillMode;
113+
109 friend class SurfaceManager;
114 friend class SurfaceManager;
110};
115};
111
116
tests/qmltests/Stages/tst_DesktopStage.qml+18−2
@@ -15,9 +15,10 @@
15 */
15 */
16
16
17import QtQuick 2.0
17import QtQuick 2.0
18+import QtQuick.Layouts 1.1
18import QtTest 1.0
19import QtTest 1.0
19−import Ubuntu.Components 1.1
20+import Ubuntu.Components 1.3
20−import Ubuntu.Components.ListItems 1.0 as ListItem
21+import Ubuntu.Components.ListItems 1.3
21import Unity.Application 0.1
22import Unity.Application 0.1
22import Unity.Test 0.1
23import Unity.Test 0.1
23import Utils 0.1
24import Utils 0.1
@@ -78,6 +79,21 @@ Item {
78 Column {
79 Column {
79 anchors { left: parent.left; right: parent.right; top: parent.top; margins: units.gu(1) }
80 anchors { left: parent.left; right: parent.right; top: parent.top; margins: units.gu(1) }
80 spacing: units.gu(1)
81 spacing: units.gu(1)
82+
83+ Button {
84+ color: "white"
85+ text: "Make surface slow to resize"
86+ activeFocusOnPress: false
87+ onClicked: {
88+ if (ApplicationManager.focusedApplicationId) {
89+ var surface = ApplicationManager.findApplication(ApplicationManager.focusedApplicationId).session.surface;
90+ surface.slowToResize = true;
91+ }
92+ }
93+ }
94+
95+ Divider {}
96+
81 Repeater {
97 Repeater {
82 model: ApplicationManager.availableApplications
98 model: ApplicationManager.availableApplications
83 ApplicationCheckBox {
99 ApplicationCheckBox {
tests/qmltests/Stages/tst_WindowResizeArea.qml+32−14
@@ -29,8 +29,6 @@ Item {
29 height: units.gu(60)
29 height: units.gu(60)
30 width: units.gu(60)
30 width: units.gu(60)
31
31
32− property var fakeWindow: windowLoader.item
33−
34 Component {
32 Component {
35 id: fakeWindowComponent
33 id: fakeWindowComponent
36
34
@@ -40,12 +38,10 @@ Item {
40 property alias minHeight: windowResizeArea.minHeight
38 property alias minHeight: windowResizeArea.minHeight
41 x: units.gu(20)
39 x: units.gu(20)
42 y: units.gu(20)
40 y: units.gu(20)
43− height: units.gu(20)
41+ width: requestedWidth
44− width: units.gu(20)
42+ height: requestedHeight
45− property int windowHeight: height
43+ property real requestedWidth
46− property int windowWidth: width
44+ property real requestedHeight
47− onWindowHeightChanged: height = windowHeight
48− onWindowWidthChanged: width = windowWidth
49
45
50 WindowResizeArea {
46 WindowResizeArea {
51 id: windowResizeArea
47 id: windowResizeArea
@@ -53,6 +49,8 @@ Item {
53 borderThickness: units.gu(2)
49 borderThickness: units.gu(2)
54 minWidth: units.gu(15)
50 minWidth: units.gu(15)
55 minHeight: units.gu(10)
51 minHeight: units.gu(10)
52+ defaultWidth: units.gu(20)
53+ defaultHeight: units.gu(20)
56 windowId: "test-window-id"
54 windowId: "test-window-id"
57 }
55 }
58
56
@@ -75,22 +73,41 @@ Item {
75 Loader {
73 Loader {
76 id: windowLoader
74 id: windowLoader
77 sourceComponent: fakeWindowComponent
75 sourceComponent: fakeWindowComponent
76+ active: windowLoaderCheckbox.checked
78 }
77 }
79
78
79+ Column {
80− MouseTouchEmulationCheckbox {
80+ MouseTouchEmulationCheckbox {
81− checked: false
81+ checked: false
82+ color: "black"
83+ }
84+ RowLayout {
85+ Layout.fillWidth: true
86+ CheckBox {
87+ id: windowLoaderCheckbox
88+ checked: true
89+ activeFocusOnPress: false
90+ }
91+ Label {
92+ id: label
82− color: "black"
93+ color: "black"
94+ text: "Window loader active"
95+ anchors.verticalCenter: parent.verticalCenter
96+ }
97+ }
83 }
98 }
84
99
85 UnityTestCase {
100 UnityTestCase {
86 name: "WindowResizeArea"
101 name: "WindowResizeArea"
87 when: windowShown
102 when: windowShown
88
103
104+ property var fakeWindow: windowLoader.item
105+
89 function init() {
106 function init() {
90 fakeWindow.x = units.gu(20)
107 fakeWindow.x = units.gu(20)
91 fakeWindow.y = units.gu(20)
108 fakeWindow.y = units.gu(20)
92− fakeWindow.width = units.gu(20)
109+ fakeWindow.requestedWidth = units.gu(20)
93− fakeWindow.height = units.gu(20)
110+ fakeWindow.requestedHeight = units.gu(20)
94 }
111 }
95
112
96 function test_resizeWindowRightBottom_data() {
113 function test_resizeWindowRightBottom_data() {
@@ -176,11 +193,12 @@ Item {
176 function test_resizeSmallerAndLarger_data() {
193 function test_resizeSmallerAndLarger_data() {
177 return [
194 return [
178 { tag: "topLeft", startX: -1, startY: -1, dx: units.gu(15), dy: units.gu(15) },
195 { tag: "topLeft", startX: -1, startY: -1, dx: units.gu(15), dy: units.gu(15) },
179− { tag: "bottomRight", startX: fakeWindow.width + 1, startY: fakeWindow.height + 1, dx: -units.gu(15), dy: -units.gu(15) }
196+ { tag: "bottomRight", startX: units.gu(20) + 1, startY: units.gu(20) + 1, dx: -units.gu(15), dy: -units.gu(15) }
180 ]
197 ]
181 }
198 }
182
199
183 function test_resizeSmallerAndLarger(data) {
200 function test_resizeSmallerAndLarger(data) {
201+ console.log("windowLoader="+windowLoader + ", windowLoader.item="+windowLoader.item + ", windowLoader.active="+windowLoader.active);
184 var initialWindowX = fakeWindow.x;
202 var initialWindowX = fakeWindow.x;
185 var initialWindowY = fakeWindow.y;
203 var initialWindowY = fakeWindow.y;
186 var initialWindowWidth = fakeWindow.width
204 var initialWindowWidth = fakeWindow.width