winrt: Do not emit keyboard changes in the constructor

QWinRTInputContext is created from the XAML Thread, which can cause
problems when handleVisibilityChange is invoked. Instead just query the
keyboardRect and skip the emit.

Task-number: QTBUG-49389
Change-Id: I158204a07b9e000adffdc308e68b0f1425ed7c62
Reviewed-by: Andrew Knight <andrew.knight@intopalo.com>
This commit is contained in:
Maurice Kalinowski 2015-11-13 15:02:01 +01:00
parent d2792d2ed9
commit 99d061ffd5

View File

@ -54,6 +54,14 @@ typedef ITypedEventHandler<InputPane*, InputPaneVisibilityEventArgs*> InputPaneV
QT_BEGIN_NAMESPACE
inline QRectF getInputPaneRect(IInputPane *pane, qreal scaleFactor)
{
Rect rect;
pane->get_OccludedRect(&rect);
return QRectF(qRound(rect.X * scaleFactor), qRound(rect.Y * scaleFactor),
qRound(rect.Width * scaleFactor), qRound(rect.Height * scaleFactor));
}
/*!
\class QWinRTInputContext
\brief Manages Input Method visibility
@ -87,7 +95,7 @@ QWinRTInputContext::QWinRTInputContext(QWinRTScreen *screen)
inputPane->add_Hiding(Callback<InputPaneVisibilityHandler>(
this, &QWinRTInputContext::onHiding).Get(), &hideToken);
handleVisibilityChange(inputPane);
m_keyboardRect = getInputPaneRect(inputPane, m_screen->scaleFactor());
m_isInputPanelVisible = !m_keyboardRect.isEmpty();
} else {
qWarning(Q_FUNC_INFO ": failed to retrieve InputPane.");
@ -120,10 +128,7 @@ HRESULT QWinRTInputContext::onHiding(IInputPane *pane, IInputPaneVisibilityEvent
HRESULT QWinRTInputContext::handleVisibilityChange(IInputPane *pane)
{
Rect rect;
pane->get_OccludedRect(&rect);
const QRectF keyboardRect = QRectF(qRound(rect.X * m_screen->scaleFactor()), qRound(rect.Y * m_screen->scaleFactor()),
qRound(rect.Width * m_screen->scaleFactor()), qRound(rect.Height * m_screen->scaleFactor()));
const QRectF keyboardRect = getInputPaneRect(pane, m_screen->scaleFactor());
if (m_keyboardRect != keyboardRect) {
m_keyboardRect = keyboardRect;
emitKeyboardRectChanged();