on xenial help sign in
update QtMir mock to behave more like the real QtMir
commit4547ec11431859606c7abed38209479b516f8893 authorMichael Zanetti <michael.zanetti@canonical.com> dateThu 2 Jun 2016, 14:06 (10 years ago) parent067f4e1
4 files changed+51−30
qml/Stages/DesktopStage.qml+5 qml/Stages/SurfaceContainer.qml+39−27 tests/mocks/Unity/Application/MirSurfaceItem.cpp+7 tests/mocks/Unity/Application/resources/MirSurfaceItem.qml−3
qml/Stages/DesktopStage.qml+5
@@ -606,6 +606,11 @@ AbstractStage {
606606 visuallyMinimized: false;
607607 visuallyMaximized: false
608608 }
609+ PropertyChanges {
610+ target: decoratedWindow
611+ width: appDelegate.width
612+ height: appDelegate.height
613+ }
609614 },
610615 State {
611616 name: "maximizedLeft"; when: appDelegate.maximizedLeft && !appDelegate.minimized
qml/Stages/SurfaceContainer.qml+39−27
@@ -23,6 +23,8 @@ import Unity.Application 0.1 // for MirSurfaceItem
2323FocusScope {
2424 id: root
2525 objectName: "surfaceContainer"
26+ implicitWidth: surfaceItem.implicitWidth
27+ implicitHeight: surfaceItem.implicitHeight
2628
2729 // Must be set from outside
2830 property var surface: null
@@ -42,6 +44,16 @@ FocusScope {
4244 surfaceItem.surface = surface;
4345 }
4446
47+ onImplicitWidthChanged: print("implicit width changed", implicitWidth)
48+ onImplicitHeightChanged: print("implicit height changed", implicitHeight)
49+
50+ Timer {
51+ interval: 1000
52+ repeat: true
53+ running: true
54+ onTriggered: print("implicit size:", root.implicitWidth, root.implicitHeight)
55+ }
56+
4557 InputWatcher {
4658 target: surfaceItem
4759 onTargetPressedChanged: {
@@ -101,33 +113,33 @@ FocusScope {
101113 enabled: surfaceItem.enabled
102114 }
103115
104− // MirSurface size drives SurfaceContainer size
105− Binding {
106− target: surfaceItem; property: "width"; value: root.surface ? root.surface.size.width : 0
107− when: root.requestedWidth >= 0 && root.surface
108− }
109− Binding {
110− target: surfaceItem; property: "height"; value: root.surface ? root.surface.size.height : 0
111− when: root.requestedHeight >= 0 && root.surface
112− }
113− Binding {
114− target: root; property: "implicitWidth"; value: surfaceItem.width
115− when: root.requestedWidth >= 0
116− }
117− Binding {
118− target: root; property: "implicitHeight"; value: surfaceItem.height
119− when: root.requestedHeight >= 0
120− }
121−
122− // SurfaceContainer size drives MirSurface size
123− Binding {
124− target: surfaceItem; property: "width"; value: root.width
125− when: root.requestedWidth < 0
126− }
127− Binding {
128− target: surfaceItem; property: "height"; value: root.height
129− when: root.requestedHeight < 0
130− }
116+// // MirSurface size drives SurfaceContainer size
117+// Binding {
118+// target: surfaceItem; property: "width"; value: root.surface ? root.surface.size.width : 0
119+// when: root.requestedWidth >= 0 && root.surface
120+// }
121+// Binding {
122+// target: surfaceItem; property: "height"; value: root.surface ? root.surface.size.height : 0
123+// when: root.requestedHeight >= 0 && root.surface
124+// }
125+// Binding {
126+// target: root; property: "implicitWidth"; value: surfaceItem.width
127+// when: root.requestedWidth >= 0
128+// }
129+// Binding {
130+// target: root; property: "implicitHeight"; value: surfaceItem.height
131+// when: root.requestedHeight >= 0
132+// }
133+
134+// // SurfaceContainer size drives MirSurface size
135+// Binding {
136+// target: surfaceItem; property: "width"; value: root.width
137+// when: root.requestedWidth < 0
138+// }
139+// Binding {
140+// target: surfaceItem; property: "height"; value: root.height
141+// when: root.requestedHeight < 0
142+// }
131143
132144 Loader {
133145 id: animationsLoader
tests/mocks/Unity/Application/MirSurfaceItem.cpp+7
@@ -57,6 +57,9 @@ MirSurfaceItem::MirSurfaceItem(QQuickItem *parent)
5757 Qt::ExtraButton12 | Qt::ExtraButton13);
5858
5959 connect(this, &QQuickItem::visibleChanged, this, &MirSurfaceItem::updateMirSurfaceVisibility);
60+
61+ // We're just clipping contents in the mock. The real QtMir would copy only relevant buffer instead
62+ setClip(true);
6063}
6164
6265MirSurfaceItem::~MirSurfaceItem()
@@ -163,6 +166,9 @@ void MirSurfaceItem::createQmlContentItem()
163166 m_qmlItem = qobject_cast<QQuickItem*>(m_qmlContentComponent->create());
164167 m_qmlItem->setParentItem(this);
165168
169+ m_qmlItem->setWidth(m_surfaceWidth);
170+ m_qmlItem->setHeight(m_surfaceHeight);
171+
166172 setImplicitWidth(m_qmlItem->implicitWidth());
167173 setImplicitHeight(m_qmlItem->implicitHeight());
168174
@@ -338,6 +344,7 @@ void MirSurfaceItem::updateSurfaceSize()
338344{
339345 if (m_qmlSurface && m_surfaceWidth > 0 && m_surfaceHeight > 0) {
340346 m_qmlSurface->resize(m_surfaceWidth, m_surfaceHeight);
347+ setImplicitSize(m_surfaceWidth, m_surfaceHeight);
341348 }
342349}
343350
tests/mocks/Unity/Application/resources/MirSurfaceItem.qml−3
@@ -23,9 +23,6 @@ Rectangle {
2323 implicitWidth: units.gu(40)
2424 implicitHeight: units.gu(70)
2525
26− width: parent ? parent.width : implicitWidth
27− height: parent ? parent.height : implicitHeight
28−
2926 property alias screenshotSource: screenshotImage.source
3027 property int orientationAngle
3128