summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/winrt/qwinrtinputcontext.cpp
diff options
context:
space:
mode:
authorOliver Wolff <oliver.wolff@qt.io>2020-06-05 09:24:37 +0200
committerLiang Qi <liang.qi@qt.io>2020-06-06 20:25:49 +0200
commit45b0f1be686cfba8dcecb9be5c875cae59c69276 (patch)
tree363dfd46575d147206267d854ce14747157f432e /src/plugins/platforms/winrt/qwinrtinputcontext.cpp
parentaa81b90738ce9faee5e433617c8bd243cb238729 (diff)
Remove winrt
Macros and the await helper function from qfunctions_winrt(_p).h are needed in other Qt modules which use UWP APIs on desktop windows. Task-number: QTBUG-84434 Change-Id: Ice09c11436ad151c17bdccd2c7defadd08c13925 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Diffstat (limited to 'src/plugins/platforms/winrt/qwinrtinputcontext.cpp')
-rw-r--r--src/plugins/platforms/winrt/qwinrtinputcontext.cpp222
1 files changed, 0 insertions, 222 deletions
diff --git a/src/plugins/platforms/winrt/qwinrtinputcontext.cpp b/src/plugins/platforms/winrt/qwinrtinputcontext.cpp
deleted file mode 100644
index 5ae94ba613..0000000000
--- a/src/plugins/platforms/winrt/qwinrtinputcontext.cpp
+++ /dev/null
@@ -1,222 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qwinrtinputcontext.h"
-#include "qwinrtscreen.h"
-#include <QtGui/QGuiApplication>
-#include <QtGui/QWindow>
-#include <private/qeventdispatcher_winrt_p.h>
-
-#include <functional>
-#include <wrl.h>
-#include <roapi.h>
-#include <windows.ui.viewmanagement.h>
-#include <windows.ui.core.h>
-using namespace Microsoft::WRL;
-using namespace Microsoft::WRL::Wrappers;
-using namespace ABI::Windows::Foundation;
-using namespace ABI::Windows::UI::ViewManagement;
-using namespace ABI::Windows::UI::Core;
-
-typedef ITypedEventHandler<InputPane*, InputPaneVisibilityEventArgs*> InputPaneVisibilityHandler;
-
-QT_BEGIN_NAMESPACE
-
-Q_LOGGING_CATEGORY(lcQpaInputMethods, "qt.qpa.input.methods")
-
-inline QRectF getInputPaneRect(ComPtr<IInputPane> pane, qreal scaleFactor)
-{
- Rect rect;
- pane->get_OccludedRect(&rect);
- return QRectF(qRound(qreal(rect.X) * scaleFactor), qRound(qreal(rect.Y) * scaleFactor),
- qRound(qreal(rect.Width) * scaleFactor), qRound(qreal(rect.Height) * scaleFactor));
-}
-
-/*!
- \class QWinRTInputContext
- \brief Manages Input Method visibility
- \internal
- \ingroup qt-qpa-winrt
-
- Listens to the native virtual keyboard for hide/show events and provides
- hints to the OS for showing/hiding. On WinRT, showInputPanel()/hideInputPanel()
- have no effect because WinRT dictates that keyboard presence is user-driven:
- (http://msdn.microsoft.com/en-us/library/windows/apps/hh465404.aspx)
- Windows Phone, however, supports direct hiding/showing of the keyboard.
-*/
-
-QWinRTInputContext::QWinRTInputContext(QWinRTScreen *screen)
- : m_screen(screen)
-{
- qCDebug(lcQpaInputMethods) << __FUNCTION__ << screen;
-
- 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) {
- EventRegistrationToken showToken, hideToken;
- inputPane->add_Showing(Callback<InputPaneVisibilityHandler>(
- this, &QWinRTInputContext::onShowing).Get(), &showToken);
- inputPane->add_Hiding(Callback<InputPaneVisibilityHandler>(
- this, &QWinRTInputContext::onHiding).Get(), &hideToken);
-
- 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);
-}
-
-QRectF QWinRTInputContext::keyboardRect() const
-{
- return m_keyboardRect;
-}
-
-bool QWinRTInputContext::isInputPanelVisible() const
-{
- return m_isInputPanelVisible;
-}
-
-void QWinRTInputContext::updateScreenCursorRect()
-{
- m_screen->setCursorRect(QGuiApplication::inputMethod()->cursorRectangle());
-}
-
-HRESULT QWinRTInputContext::onShowing(IInputPane *pane, IInputPaneVisibilityEventArgs *)
-{
- qCDebug(lcQpaInputMethods) << __FUNCTION__ << pane;
- m_isInputPanelVisible = true;
- emitInputPanelVisibleChanged();
- return handleVisibilityChange(pane);
-}
-
-HRESULT QWinRTInputContext::onHiding(IInputPane *pane, IInputPaneVisibilityEventArgs *)
-{
- qCDebug(lcQpaInputMethods) << __FUNCTION__ << pane;
- m_isInputPanelVisible = false;
- emitInputPanelVisibleChanged();
- return handleVisibilityChange(pane);
-}
-
-HRESULT QWinRTInputContext::handleVisibilityChange(IInputPane *pane)
-{
- qCDebug(lcQpaInputMethods) << __FUNCTION__ << pane;
- const QRectF keyboardRect = getInputPaneRect(pane, m_screen->scaleFactor());
- if (m_keyboardRect != keyboardRect) {
- m_keyboardRect = keyboardRect;
- m_screen->setKeyboardRect(m_keyboardRect);
- emitKeyboardRectChanged();
- }
- return S_OK;
-}
-
-static HRESULT getInputPane(ComPtr<IInputPane2> *inputPane2)
-{
- ComPtr<IInputPaneStatics> 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<IInputPane> 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;
-}
-
-void QWinRTInputContext::showInputPanel()
-{
- qCDebug(lcQpaInputMethods) << __FUNCTION__;
-
- QEventDispatcherWinRT::runOnXamlThread([&]() {
- ComPtr<IInputPane2> inputPane;
- HRESULT hr = getInputPane(&inputPane);
- if (FAILED(hr))
- return S_OK;
- boolean success;
- hr = inputPane->TryShow(&success);
- if (FAILED(hr) || !success)
- qErrnoWarning(hr, "Failed to show input panel.");
- return S_OK;
- });
-}
-
-void QWinRTInputContext::hideInputPanel()
-{
- qCDebug(lcQpaInputMethods) << __FUNCTION__;
- if (!m_isInputPanelVisible)
- return;
-
- QEventDispatcherWinRT::runOnXamlThread([&]() {
- ComPtr<IInputPane2> inputPane;
- HRESULT hr = getInputPane(&inputPane);
- if (FAILED(hr))
- return S_OK;
- boolean success;
- hr = inputPane->TryHide(&success);
- if (FAILED(hr) || !success)
- qErrnoWarning(hr, "Failed to hide input panel.");
- return S_OK;
- });
-}
-
-QT_END_NAMESPACE