on xenial help sign in
[TLWM] always activate the newly-prepended window

After prepending a window, the window should be activated to make sure MirAL's focused window match the top window. There's no need to check if there's a surface, as Window::activate() will check that by itself. Test case: 1. Connect a keyboard. 2. Open Morph Brower. Then, create a new window. 3. Press Tab a few times. The focus inside the new window should eventually go to the address bar.

commitd58308c7ebb3d61032bd06fcf8e58071e094ed05 authorRatchanan Srirattanamet <ratchanan@ubports.com> dateThu 23 Jan 2020, 23:44 (7 years ago) parent126feff
2 files changed+21−3
plugins/WindowManager/TopLevelWindowModel.cpp+2−3 tests/qmltests/Stage/tst_QMLTopLevelWindowModel.qml+19
plugins/WindowManager/TopLevelWindowModel.cpp+2−3
@@ -195,9 +195,8 @@ void TopLevelWindowModel::prependSurfaceHelper(unityapi::MirSurfaceInterface *su
195195
196196 prependWindow(window, application);
197197
198− if (!surface) {
199− activateEmptyWindow(window);
200− }
198+ // Activate the newly-prepended window.
199+ window->activate();
201200
202201 INFO_MSG << " after " << toString();
203202}
tests/qmltests/Stage/tst_QMLTopLevelWindowModel.qml+19
@@ -168,5 +168,24 @@ Item {
168168 tlwm.rootFocus = true;
169169 compare(dialerApp.focused, true);
170170 }
171+
172+ /*
173+ Ensure that the newly-opened window from an already-opened app will
174+ be focused in addition to being on top.
175+ */
176+ function test_focusNewWindowFromOpenedApp()
177+ {
178+ var firstWindowSurfaceId = tlwm.nextId;
179+ var webbrowserApp = ApplicationManager.startApplication("morph-browser");
180+ waitUntilAppSurfaceShowsUp(firstWindowSurfaceId);
181+
182+ // Create the second window
183+ var secondWindowSurfaceId = tlwm.nextId;
184+ webbrowserApp.createSurface();
185+
186+ var topWindow = tlwm.windowAt(0);
187+ compare(topWindow.id, secondWindowSurfaceId, "The top window is not the second window.");
188+ compare(topWindow.focused, true, "The second window isn't focused.");
189+ }
171190 }
172191}