winrt: Fix initialization of input context
f104e43a72
moved QWinRTInputContext to the
gui thread. However, IInputPane needs to be queried from Xaml itself.
Otherwise it might cause unhandled exceptions.
Change-Id: I43848c796e7ff163e6befa7c58f0ad68445b9865
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
This commit is contained in:
parent
6320ca79e9
commit
60da6313cf
@ -86,30 +86,31 @@ QWinRTInputContext::QWinRTInputContext(QWinRTScreen *screen)
|
||||
{
|
||||
qCDebug(lcQpaInputMethods) << __FUNCTION__ << screen;
|
||||
|
||||
ComPtr<IInputPaneStatics> 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<IInputPaneStatics> statics;
|
||||
if (FAILED(GetActivationFactory(HString::MakeReference(RuntimeClass_Windows_UI_ViewManagement_InputPane).Get(),
|
||||
&statics))) {
|
||||
qWarning("failed to retrieve input pane statics.");
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
ComPtr<IInputPane> inputPane;
|
||||
statics->GetForCurrentView(&inputPane);
|
||||
if (inputPane) {
|
||||
QEventDispatcherWinRT::runOnXamlThread([this, inputPane]() {
|
||||
ComPtr<IInputPane> inputPane;
|
||||
statics->GetForCurrentView(&inputPane);
|
||||
if (inputPane) {
|
||||
EventRegistrationToken showToken, hideToken;
|
||||
inputPane->add_Showing(Callback<InputPaneVisibilityHandler>(
|
||||
this, &QWinRTInputContext::onShowing).Get(), &showToken);
|
||||
inputPane->add_Hiding(Callback<InputPaneVisibilityHandler>(
|
||||
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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user