Skip to content
This repository has been archived by the owner on Nov 4, 2023. It is now read-only.

Commit

Permalink
Focus the shellView after creating secondaryWindow
Browse files Browse the repository at this point in the history
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 ubports/keyboard-component#123
  • Loading branch information
UniversalSuperBox authored and peat-psuwit committed Apr 21, 2020
1 parent 7013f90 commit 7063709
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/ShellApplication.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,9 +183,6 @@ void ShellApplication::onScreenAdded(QScreen * /*screen*/)
if (screens().count() == 2) {
m_shellView->setScreen(screens().at(1));
m_qmlArgs.setDeviceName(QStringLiteral("desktop"));
// Changing the QScreen where a QWindow is drawn makes it also lose focus (besides having
// its backing QPlatformWindow recreated). So lets refocus it.
m_shellView->requestActivate();
// QWindow::destroy() is called when it changes between screens. We have to manually make it visible again
// <dandrader> This bug is supposedly fixed in Qt 5.5.1, although I can still reproduce it there. :-/
m_shellView->setVisible(true);
Expand All @@ -196,6 +193,12 @@ void ShellApplication::onScreenAdded(QScreen * /*screen*/)
// QWindow::showFullScreen() also calls QWindow::requestActivate() and we don't want that!
m_secondaryWindow->setWindowState(Qt::WindowFullScreen);
m_secondaryWindow->setVisible(true);

// Changing the QScreen where a QWindow is drawn makes it also lose focus (besides having
// its backing QPlatformWindow recreated). So lets refocus it.
// This must be done after the creation of the SecondaryWindow, else
// the SecondaryWindow takes focus anyway.
m_shellView->requestActivate();
}
}

Expand Down

0 comments on commit 7063709

Please sign in to comment.