diff --git a/src/plugins/platforms/winrt/qwinrtinputcontext.cpp b/src/plugins/platforms/winrt/qwinrtinputcontext.cpp index 968c47f2c2..63e5b0cf27 100644 --- a/src/plugins/platforms/winrt/qwinrtinputcontext.cpp +++ b/src/plugins/platforms/winrt/qwinrtinputcontext.cpp @@ -86,30 +86,31 @@ QWinRTInputContext::QWinRTInputContext(QWinRTScreen *screen) { qCDebug(lcQpaInputMethods) << __FUNCTION__ << screen; - ComPtr statics; - if (FAILED(GetActivationFactory(HString::MakeReference(RuntimeClass_Windows_UI_ViewManagement_InputPane).Get(), - &statics))) { - qWarning("failed to retrieve input pane statics."); - return; - } + QEventDispatcherWinRT::runOnXamlThread([this]() { + ComPtr statics; + if (FAILED(GetActivationFactory(HString::MakeReference(RuntimeClass_Windows_UI_ViewManagement_InputPane).Get(), + &statics))) { + qWarning("failed to retrieve input pane statics."); + return S_OK; + } - ComPtr inputPane; - statics->GetForCurrentView(&inputPane); - if (inputPane) { - QEventDispatcherWinRT::runOnXamlThread([this, inputPane]() { + ComPtr inputPane; + statics->GetForCurrentView(&inputPane); + if (inputPane) { EventRegistrationToken showToken, hideToken; inputPane->add_Showing(Callback( this, &QWinRTInputContext::onShowing).Get(), &showToken); inputPane->add_Hiding(Callback( this, &QWinRTInputContext::onHiding).Get(), &hideToken); - return S_OK; - }); - m_keyboardRect = getInputPaneRect(inputPane, m_screen->scaleFactor()); - m_isInputPanelVisible = !m_keyboardRect.isEmpty(); - } else { - qWarning("failed to retrieve InputPane."); - } + m_keyboardRect = getInputPaneRect(inputPane, m_screen->scaleFactor()); + m_isInputPanelVisible = !m_keyboardRect.isEmpty(); + } else { + qWarning("failed to retrieve InputPane."); + } + return S_OK; + }); + connect(QGuiApplication::inputMethod(), &QInputMethod::cursorRectangleChanged, this, &QWinRTInputContext::updateScreenCursorRect); }