on xenial help sign in
update QtMir mock to behave more like the real QtMir
4547ec1Michael Zanetti
qml/Stages/DesktopStage.qml+5
@@ -606,6 +606,11 @@ AbstractStage {
606 visuallyMinimized: false;
606 visuallyMinimized: false;
607 visuallyMaximized: false
607 visuallyMaximized: false
608 }
608 }
609+ PropertyChanges {
610+ target: decoratedWindow
611+ width: appDelegate.width
612+ height: appDelegate.height
613+ }
609 },
614 },
610 State {
615 State {
611 name: "maximizedLeft"; when: appDelegate.maximizedLeft && !appDelegate.minimized
616 name: "maximizedLeft"; when: appDelegate.maximizedLeft && !appDelegate.minimized
qml/Stages/SurfaceContainer.qml+39−27
@@ -23,6 +23,8 @@ import Unity.Application 0.1 // for MirSurfaceItem
23FocusScope {
23FocusScope {
24 id: root
24 id: root
25 objectName: "surfaceContainer"
25 objectName: "surfaceContainer"
26+ implicitWidth: surfaceItem.implicitWidth
27+ implicitHeight: surfaceItem.implicitHeight
26
28
27 // Must be set from outside
29 // Must be set from outside
28 property var surface: null
30 property var surface: null
@@ -42,6 +44,16 @@ FocusScope {
42 surfaceItem.surface = surface;
44 surfaceItem.surface = surface;
43 }
45 }
44
46
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+
45 InputWatcher {
57 InputWatcher {
46 target: surfaceItem
58 target: surfaceItem
47 onTargetPressedChanged: {
59 onTargetPressedChanged: {
@@ -101,33 +113,33 @@ FocusScope {
101 enabled: surfaceItem.enabled
113 enabled: surfaceItem.enabled
102 }
114 }
103
115
104− // MirSurface size drives SurfaceContainer size
116+// // MirSurface size drives SurfaceContainer size
105− Binding {
117+// Binding {
106− target: surfaceItem; property: "width"; value: root.surface ? root.surface.size.width : 0
118+// target: surfaceItem; property: "width"; value: root.surface ? root.surface.size.width : 0
107− when: root.requestedWidth >= 0 && root.surface
119+// when: root.requestedWidth >= 0 && root.surface
108− }
120+// }
109− Binding {
121+// Binding {
110− target: surfaceItem; property: "height"; value: root.surface ? root.surface.size.height : 0
122+// target: surfaceItem; property: "height"; value: root.surface ? root.surface.size.height : 0
111− when: root.requestedHeight >= 0 && root.surface
123+// when: root.requestedHeight >= 0 && root.surface
112− }
124+// }
113− Binding {
125+// Binding {
114− target: root; property: "implicitWidth"; value: surfaceItem.width
126+// target: root; property: "implicitWidth"; value: surfaceItem.width
115− when: root.requestedWidth >= 0
127+// when: root.requestedWidth >= 0
116− }
128+// }
117− Binding {
129+// Binding {
118− target: root; property: "implicitHeight"; value: surfaceItem.height
130+// target: root; property: "implicitHeight"; value: surfaceItem.height
119− when: root.requestedHeight >= 0
131+// when: root.requestedHeight >= 0
120− }
132+// }
121−
133+
122− // SurfaceContainer size drives MirSurface size
134+// // SurfaceContainer size drives MirSurface size
123− Binding {
135+// Binding {
124− target: surfaceItem; property: "width"; value: root.width
136+// target: surfaceItem; property: "width"; value: root.width
125− when: root.requestedWidth < 0
137+// when: root.requestedWidth < 0
126− }
138+// }
127− Binding {
139+// Binding {
128− target: surfaceItem; property: "height"; value: root.height
140+// target: surfaceItem; property: "height"; value: root.height
129− when: root.requestedHeight < 0
141+// when: root.requestedHeight < 0
130− }
142+// }
131
143
132 Loader {
144 Loader {
133 id: animationsLoader
145 id: animationsLoader
tests/mocks/Unity/Application/MirSurfaceItem.cpp+7
@@ -57,6 +57,9 @@ MirSurfaceItem::MirSurfaceItem(QQuickItem *parent)
57 Qt::ExtraButton12 | Qt::ExtraButton13);
57 Qt::ExtraButton12 | Qt::ExtraButton13);
58
58
59 connect(this, &QQuickItem::visibleChanged, this, &MirSurfaceItem::updateMirSurfaceVisibility);
59 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);
60}
63}
61
64
62MirSurfaceItem::~MirSurfaceItem()
65MirSurfaceItem::~MirSurfaceItem()
@@ -163,6 +166,9 @@ void MirSurfaceItem::createQmlContentItem()
163 m_qmlItem = qobject_cast<QQuickItem*>(m_qmlContentComponent->create());
166 m_qmlItem = qobject_cast<QQuickItem*>(m_qmlContentComponent->create());
164 m_qmlItem->setParentItem(this);
167 m_qmlItem->setParentItem(this);
165
168
169+ m_qmlItem->setWidth(m_surfaceWidth);
170+ m_qmlItem->setHeight(m_surfaceHeight);
171+
166 setImplicitWidth(m_qmlItem->implicitWidth());
172 setImplicitWidth(m_qmlItem->implicitWidth());
167 setImplicitHeight(m_qmlItem->implicitHeight());
173 setImplicitHeight(m_qmlItem->implicitHeight());
168
174
@@ -338,6 +344,7 @@ void MirSurfaceItem::updateSurfaceSize()
338{
344{
339 if (m_qmlSurface && m_surfaceWidth > 0 && m_surfaceHeight > 0) {
345 if (m_qmlSurface && m_surfaceWidth > 0 && m_surfaceHeight > 0) {
340 m_qmlSurface->resize(m_surfaceWidth, m_surfaceHeight);
346 m_qmlSurface->resize(m_surfaceWidth, m_surfaceHeight);
347+ setImplicitSize(m_surfaceWidth, m_surfaceHeight);
341 }
348 }
342}
349}
343
350
tests/mocks/Unity/Application/resources/MirSurfaceItem.qml−3
@@ -23,9 +23,6 @@ Rectangle {
23 implicitWidth: units.gu(40)
23 implicitWidth: units.gu(40)
24 implicitHeight: units.gu(70)
24 implicitHeight: units.gu(70)
25
25
26− width: parent ? parent.width : implicitWidth
27− height: parent ? parent.height : implicitHeight
28−
29 property alias screenshotSource: screenshotImage.source
26 property alias screenshotSource: screenshotImage.source
30 property int orientationAngle
27 property int orientationAngle
31
28