on xenial help sign in
Focus the shellView after creating secondaryWindow

Prior to this change, 'SecondaryWindow' was the focused window after onScreenAdded finished. By moving m_shellView->requestActivate to the end of the method, we ensure that the real shell is focused. Fixes https://github.com/ubports/keyboard-component/issues/123

commit7063709044dbb5ee2e404f5c4bbcbbec5e176ab2 authorDalton Durst <dalton@ubports.com> dateSat 18 Apr 2020, 17:13 (6 years ago) parent7013f90
1 file changed+6−3
src/ShellApplication.cpp+6−3
src/ShellApplication.cpp+6−3
@@ -183,9 +183,6 @@ void ShellApplication::onScreenAdded(QScreen * /*screen*/)
183183 if (screens().count() == 2) {
184184 m_shellView->setScreen(screens().at(1));
185185 m_qmlArgs.setDeviceName(QStringLiteral("desktop"));
186− // Changing the QScreen where a QWindow is drawn makes it also lose focus (besides having
187− // its backing QPlatformWindow recreated). So lets refocus it.
188− m_shellView->requestActivate();
189186 // QWindow::destroy() is called when it changes between screens. We have to manually make it visible again
190187 // <dandrader> This bug is supposedly fixed in Qt 5.5.1, although I can still reproduce it there. :-/
191188 m_shellView->setVisible(true);
@@ -196,6 +193,12 @@ void ShellApplication::onScreenAdded(QScreen * /*screen*/)
196193 // QWindow::showFullScreen() also calls QWindow::requestActivate() and we don't want that!
197194 m_secondaryWindow->setWindowState(Qt::WindowFullScreen);
198195 m_secondaryWindow->setVisible(true);
196+
197+ // Changing the QScreen where a QWindow is drawn makes it also lose focus (besides having
198+ // its backing QPlatformWindow recreated). So lets refocus it.
199+ // This must be done after the creation of the SecondaryWindow, else
200+ // the SecondaryWindow takes focus anyway.
201+ m_shellView->requestActivate();
199202 }
200203}
201204