on xenial help sign in
added test
3bf02b2Nick Dedekind
tests/mocks/Unity/Application/MirSurfaceItem.cpp+9−3
@@ -234,6 +234,10 @@ void MirSurfaceItem::setSurface(MirSurfaceInterface* surface)
234 delete m_qmlContentComponent;
234 delete m_qmlContentComponent;
235 m_qmlContentComponent = nullptr;
235 m_qmlContentComponent = nullptr;
236
236
237+ if (hasActiveFocus() && m_consumesInput && m_qmlSurface->live()) {
238+ m_qmlSurface->setActiveFocus(false);
239+ }
240+
237 disconnect(m_qmlSurface, nullptr, this, nullptr);
241 disconnect(m_qmlSurface, nullptr, this, nullptr);
238 m_qmlSurface->unregisterView((qintptr)this);
242 m_qmlSurface->unregisterView((qintptr)this);
239 }
243 }
@@ -243,8 +247,6 @@ void MirSurfaceItem::setSurface(MirSurfaceInterface* surface)
243 if (m_qmlSurface) {
247 if (m_qmlSurface) {
244 m_qmlSurface->registerView((qintptr)this);
248 m_qmlSurface->registerView((qintptr)this);
245
249
246− m_qmlSurface->setActiveFocus(hasActiveFocus());
247−
248 updateSurfaceSize();
250 updateSurfaceSize();
249 updateMirSurfaceVisibility();
251 updateMirSurfaceVisibility();
250
252
@@ -277,6 +279,10 @@ void MirSurfaceItem::setSurface(MirSurfaceInterface* surface)
277 default:
279 default:
278 qFatal("MirSurfaceItem: Unhandled component status");
280 qFatal("MirSurfaceItem: Unhandled component status");
279 }
281 }
282+
283+ if (m_consumesInput) {
284+ m_qmlSurface->setActiveFocus(hasActiveFocus());
285+ }
280 }
286 }
281
287
282 Q_EMIT surfaceChanged(m_qmlSurface);
288 Q_EMIT surfaceChanged(m_qmlSurface);
@@ -285,7 +291,7 @@ void MirSurfaceItem::setSurface(MirSurfaceInterface* surface)
285void MirSurfaceItem::itemChange(ItemChange change, const ItemChangeData & value)
291void MirSurfaceItem::itemChange(ItemChange change, const ItemChangeData & value)
286{
292{
287 if (change == QQuickItem::ItemActiveFocusHasChanged) {
293 if (change == QQuickItem::ItemActiveFocusHasChanged) {
288− if (m_qmlSurface) {
294+ if (m_qmlSurface && m_consumesInput && m_qmlSurface->live()) {
289 m_qmlSurface->setActiveFocus(value.boolValue);
295 m_qmlSurface->setActiveFocus(value.boolValue);
290 }
296 }
291 }
297 }
tests/qmltests/Stages/tst_TabletStage.qml+29
@@ -725,5 +725,34 @@ Rectangle {
725 // only unity8-dash surface is left
725 // only unity8-dash surface is left
726 compare(topSurfaceList.count, 1);
726 compare(topSurfaceList.count, 1);
727 }
727 }
728+
729+ function test_draggingSurfaceKeepsSurfaceFocus() {
730+ var webbrowserSurfaceId = topSurfaceList.nextId;
731+ webbrowserCheckBox.checked = true;
732+ waitUntilAppSurfaceShowsUp(webbrowserSurfaceId);
733+
734+ var appDelegate = findChild(tabletStage, "spreadDelegate_" + webbrowserSurfaceId);
735+ verify(appDelegate);
736+ compare(appDelegate.stage, ApplicationInfoInterface.MainStage);
737+
738+ tryCompare(appDelegate.surface, "activeFocus", true);
739+
740+ var pos = tabletStage.width - sideStage.width - (tabletStage.width - sideStage.width) / 2;
741+ var end_pos = tabletStage.width - sideStage.width / 2;
742+
743+ multiTouchDragUntil([0,1,2],
744+ tabletStage,
745+ pos,
746+ tabletStage.height / 2,
747+ units.gu(3),
748+ 0,
749+ function() {
750+ pos += units.gu(3);
751+ return sideStage.shown && !sideStage.showAnimation.running &&
752+ pos >= end_pos;
753+ });
754+
755+ tryCompare(appDelegate.surface, "activeFocus", true);
756+ }
728 }
757 }
729}
758}