From 4c9eb38390b35ee3ec0dc966e0b5036cac5ac76b Mon Sep 17 00:00:00 2001 From: Andrew Knight Date: Fri, 16 May 2014 10:22:47 +0300 Subject: Support Windows Phone 8.1 in WinRT QPA - Unsupported code paths for WP8.0 are avoided, and new APIs are used where appropriate (virtual keyboard) - DirectWrite fonts are loaded on WP8.1 - Platform dialogs are used on WP8.1 Change-Id: I721006ac943ad4e248f0f1590ce247a03e40fbc0 Reviewed-by: Oliver Wolff --- src/plugins/platforms/winrt/qwinrtinputcontext.cpp | 53 +++++++++++++++++++++- 1 file changed, 52 insertions(+), 1 deletion(-) (limited to 'src/plugins/platforms/winrt/qwinrtinputcontext.cpp') diff --git a/src/plugins/platforms/winrt/qwinrtinputcontext.cpp b/src/plugins/platforms/winrt/qwinrtinputcontext.cpp index bc15f1e448..8e1728dc04 100644 --- a/src/plugins/platforms/winrt/qwinrtinputcontext.cpp +++ b/src/plugins/platforms/winrt/qwinrtinputcontext.cpp @@ -52,7 +52,7 @@ using namespace ABI::Windows::Foundation; using namespace ABI::Windows::UI::ViewManagement; using namespace ABI::Windows::UI::Core; -#ifdef Q_OS_WINPHONE +#if defined(Q_OS_WINPHONE) && _MSC_VER==1700 #include using namespace ABI::Windows::Phone::UI::Core; #endif @@ -148,22 +148,73 @@ void QWinRTInputContext::setKeyboardRect(const QRectF rect) #ifdef Q_OS_WINPHONE +#if _MSC_VER>1700 // Windows Phone 8.1+ +static HRESULT getInputPane(ComPtr *inputPane2) +{ + ComPtr factory; + HRESULT hr = GetActivationFactory(HString::MakeReference(RuntimeClass_Windows_UI_ViewManagement_InputPane).Get(), + &factory); + if (FAILED(hr)) { + qErrnoWarning(hr, "Failed to get input pane factory."); + return hr; + } + + ComPtr inputPane; + hr = factory->GetForCurrentView(&inputPane); + if (FAILED(hr)) { + qErrnoWarning(hr, "Failed to get input pane."); + return hr; + } + + hr = inputPane.As(inputPane2); + if (FAILED(hr)) { + qErrnoWarning(hr, "Failed to get extended input pane."); + return hr; + } + return hr; +} +#endif // _MSC_VER>1700 + void QWinRTInputContext::showInputPanel() { +#if _MSC_VER<=1700 // Windows Phone 8.0 ICoreWindowKeyboardInput *input; if (SUCCEEDED(m_window->QueryInterface(IID_PPV_ARGS(&input)))) { input->put_IsKeyboardInputEnabled(true); input->Release(); } +#else // _MSC_VER<=1700 + ComPtr inputPane; + HRESULT hr = getInputPane(&inputPane); + if (FAILED(hr)) + return; + + boolean success; + hr = inputPane->TryShow(&success); + if (FAILED(hr)) + qErrnoWarning(hr, "Failed to show input panel."); +#endif // _MSC_VER>1700 } void QWinRTInputContext::hideInputPanel() { +#if _MSC_VER<=1700 // Windows Phone 8.0 ICoreWindowKeyboardInput *input; if (SUCCEEDED(m_window->QueryInterface(IID_PPV_ARGS(&input)))) { input->put_IsKeyboardInputEnabled(false); input->Release(); } +#else // _MSC_VER<=1700 + ComPtr inputPane; + HRESULT hr = getInputPane(&inputPane); + if (FAILED(hr)) + return; + + boolean success; + hr = inputPane->TryHide(&success); + if (FAILED(hr)) + qErrnoWarning(hr, "Failed to hide input panel."); +#endif // _MSC_VER>1700 } #else // Q_OS_WINPHONE -- cgit v1.2.3