winrt: only update window title for top level widgets

Previously we always updated the window title, independently whether the
window was visible / the toplevel one. This can also cause troubles when
setting the title during initialization.

Change-Id: I02ec0f0e385fa490f641ce83a6cb27717a31620f
Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
This commit is contained in:
Maurice Kalinowski 2016-08-17 15:40:59 +02:00
parent a75cfa60d7
commit 4531ae8d69
3 changed files with 6 additions and 8 deletions

View File

@ -764,6 +764,7 @@ void QWinRTScreen::addWindow(QWindow *window)
return;
d->visibleWindows.prepend(window);
updateWindowTitle(window->title());
QWindowSystemInterface::handleWindowActivated(window, Qt::OtherFocusReason);
handleExpose();
QWindowSystemInterface::flushWindowSystemEvents();
@ -813,15 +814,10 @@ void QWinRTScreen::lower(QWindow *window)
handleExpose();
}
void QWinRTScreen::updateWindowTitle()
void QWinRTScreen::updateWindowTitle(const QString &title)
{
Q_D(QWinRTScreen);
QWindow *window = topWindow();
if (!window)
return;
const QString title = window->title();
HStringReference titleRef(reinterpret_cast<LPCWSTR>(title.utf16()), title.length());
HRESULT hr = d->view->put_Title(titleRef.Get());
RETURN_VOID_IF_FAILED("Unable to set window title");

View File

@ -106,7 +106,7 @@ public:
void raise(QWindow *window);
void lower(QWindow *window);
void updateWindowTitle();
void updateWindowTitle(const QString &title);
ABI::Windows::UI::Core::ICoreWindow *coreWindow() const;
ABI::Windows::UI::Xaml::IDependencyObject *canvas() const;

View File

@ -282,7 +282,9 @@ void QWinRTWindow::setWindowTitle(const QString &title)
{
Q_D(QWinRTWindow);
d->windowTitle = title;
d->screen->updateWindowTitle();
if (d->screen->topWindow() == window())
d->screen->updateWindowTitle(title);
}
void QWinRTWindow::raise()