on xenial help sign in
Stage: don't signal mainAppChanged unnecessarily

After un-setting rootFocus, TLWM will re-focus previously-focused window. This will eventually call claimFocus(), sets focusedAppDelegate, and signal mainAppChanged. However, in this case, the main app doesn't actually change. This cause some unwanted side effect. For example, Shell will close indicators on this. If this happens due to drawer being closed which in turn comes from trying to open the indicators, the attempt to open the indicator will not be successful. This commit fixes that by checking the object identity of the current focusedAppDelegate. Note that I didn't check the appId because single app can create multiple windows.

commitdc3a20dda0dddfec786af07f0fd2677224ea40da authorRatchanan Srirattanamet <ratchanan@ubports.com> dateThu 9 Jan 2020, 22:48 (7 years ago) parent1a9b7e1
2 files changed+27−1
qml/Stage/Stage.qml+5−1 tests/qmltests/Stage/tst_PhoneStage.qml+22
qml/Stage/Stage.qml+5−1
@@ -962,7 +962,11 @@ FocusScope {
962962 priv.updateMainAndSideStageIndexes();
963963 }
964964 appDelegate.focus = true;
965− priv.focusedAppDelegate = appDelegate;
965+
966+ // Don't set focusedAppDelegate (and signal mainAppChanged) unnecessarily
967+ // which can happen after getting interactive again.
968+ if (priv.focusedAppDelegate !== appDelegate)
969+ priv.focusedAppDelegate = appDelegate;
966970 }
967971
968972 function updateQmlFocusFromMirSurfaceFocus() {
tests/qmltests/Stage/tst_PhoneStage.qml+22
@@ -86,6 +86,12 @@ Item {
8686 }
8787 }
8888
89+ SignalSpy {
90+ id: mainAppChangedSpy
91+ target: stage
92+ signalName: "mainAppChanged"
93+ }
94+
8995 UT.UnityTestCase {
9096 id: testCase
9197 name: "PhoneStage"
@@ -583,5 +589,21 @@ Item {
583589 compare(topLevelSurfaceList.idAt(0), webbrowserSurfaceId);
584590 compare(webbrowserApp.focused, true);
585591 }
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+ }
586608 }
587609}