on xenial help sign in
Stage: don't signal mainAppChanged unnecessarily
dc3a20dRatchanan Srirattanamet
qml/Stage/Stage.qml+5−1
@@ -962,7 +962,11 @@ FocusScope {
962 priv.updateMainAndSideStageIndexes();
962 priv.updateMainAndSideStageIndexes();
963 }
963 }
964 appDelegate.focus = true;
964 appDelegate.focus = true;
965+
966+ // Don't set focusedAppDelegate (and signal mainAppChanged) unnecessarily
967+ // which can happen after getting interactive again.
968+ if (priv.focusedAppDelegate !== appDelegate)
965− priv.focusedAppDelegate = appDelegate;
969+ priv.focusedAppDelegate = appDelegate;
966 }
970 }
967
971
968 function updateQmlFocusFromMirSurfaceFocus() {
972 function updateQmlFocusFromMirSurfaceFocus() {
tests/qmltests/Stage/tst_PhoneStage.qml+22
@@ -86,6 +86,12 @@ Item {
86 }
86 }
87 }
87 }
88
88
89+ SignalSpy {
90+ id: mainAppChangedSpy
91+ target: stage
92+ signalName: "mainAppChanged"
93+ }
94+
89 UT.UnityTestCase {
95 UT.UnityTestCase {
90 id: testCase
96 id: testCase
91 name: "PhoneStage"
97 name: "PhoneStage"
@@ -583,5 +589,21 @@ Item {
583 compare(topLevelSurfaceList.idAt(0), webbrowserSurfaceId);
589 compare(topLevelSurfaceList.idAt(0), webbrowserSurfaceId);
584 compare(webbrowserApp.focused, true);
590 compare(webbrowserApp.focused, true);
585 }
591 }
592+
593+ /*
594+ Check that set & unset allowInteractivity won't change main app.
595+ */
596+ function test_interactivityShouldNotChangeMainApp()
597+ {
598+ // Have something to focus
599+ var webbrowserSurfaceId = topLevelSurfaceList.nextId;
600+ var webbrowserApp = ApplicationManager.startApplication("morph-browser");
601+ waitUntilAppSurfaceShowsUp(webbrowserSurfaceId);
602+
603+ mainAppChangedSpy.clear();
604+ stage.allowInteractivity = false;
605+ stage.allowInteractivity = true;
606+ compare(mainAppChangedSpy.count, 0);
607+ }
586 }
608 }
587}
609}