winrt: set correct virtual keyboard size
This is done by multiplying by the DIP scale factor. Task-number: QTBUG-44152 Change-Id: I587a66f1a2f7fa3a713c279f5d877e6acb844620 Reviewed-by: Andrew Knight <qt@panimo.net>bb10
parent
2af77ab826
commit
331ddacfca
|
|
@ -32,6 +32,7 @@
|
|||
****************************************************************************/
|
||||
|
||||
#include "qwinrtinputcontext.h"
|
||||
#include "qwinrtscreen.h"
|
||||
#include <QtGui/QWindow>
|
||||
|
||||
#include <wrl.h>
|
||||
|
|
@ -61,8 +62,8 @@ QT_BEGIN_NAMESPACE
|
|||
Windows Phone, however, supports direct hiding/showing of the keyboard.
|
||||
*/
|
||||
|
||||
QWinRTInputContext::QWinRTInputContext(ICoreWindow *window)
|
||||
: m_window(window)
|
||||
QWinRTInputContext::QWinRTInputContext(QWinRTScreen *screen)
|
||||
: m_screen(screen)
|
||||
{
|
||||
IInputPaneStatics *statics;
|
||||
if (FAILED(GetActivationFactory(HString::MakeReference(RuntimeClass_Windows_UI_ViewManagement_InputPane).Get(),
|
||||
|
|
@ -81,9 +82,7 @@ QWinRTInputContext::QWinRTInputContext(ICoreWindow *window)
|
|||
inputPane->add_Hiding(Callback<InputPaneVisibilityHandler>(
|
||||
this, &QWinRTInputContext::onHiding).Get(), &hideToken);
|
||||
|
||||
Rect rect;
|
||||
inputPane->get_OccludedRect(&rect);
|
||||
m_keyboardRect = QRectF(rect.X, rect.Y, rect.Width, rect.Height);
|
||||
handleVisibilityChange(inputPane);
|
||||
m_isInputPanelVisible = !m_keyboardRect.isEmpty();
|
||||
} else {
|
||||
qWarning(Q_FUNC_INFO ": failed to retrieve InputPane.");
|
||||
|
|
@ -104,33 +103,27 @@ HRESULT QWinRTInputContext::onShowing(IInputPane *pane, IInputPaneVisibilityEven
|
|||
{
|
||||
m_isInputPanelVisible = true;
|
||||
emitInputPanelVisibleChanged();
|
||||
|
||||
Rect rect;
|
||||
pane->get_OccludedRect(&rect);
|
||||
setKeyboardRect(QRectF(rect.X, rect.Y, rect.Width, rect.Height));
|
||||
|
||||
return S_OK;
|
||||
return handleVisibilityChange(pane);
|
||||
}
|
||||
|
||||
HRESULT QWinRTInputContext::onHiding(IInputPane *pane, IInputPaneVisibilityEventArgs *)
|
||||
{
|
||||
m_isInputPanelVisible = false;
|
||||
emitInputPanelVisibleChanged();
|
||||
|
||||
Rect rect;
|
||||
pane->get_OccludedRect(&rect);
|
||||
setKeyboardRect(QRectF(rect.X, rect.Y, rect.Width, rect.Height));
|
||||
|
||||
return S_OK;
|
||||
return handleVisibilityChange(pane);
|
||||
}
|
||||
|
||||
void QWinRTInputContext::setKeyboardRect(const QRectF rect)
|
||||
HRESULT QWinRTInputContext::handleVisibilityChange(IInputPane *pane)
|
||||
{
|
||||
if (m_keyboardRect == rect)
|
||||
return;
|
||||
|
||||
m_keyboardRect = rect;
|
||||
emitKeyboardRectChanged();
|
||||
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()));
|
||||
if (m_keyboardRect != keyboardRect) {
|
||||
m_keyboardRect = keyboardRect;
|
||||
emitKeyboardRectChanged();
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
#ifdef Q_OS_WINPHONE
|
||||
|
|
@ -234,7 +227,7 @@ HRESULT QWinRTInputContext::GetPropertyValue(PROPERTYID idProp, VARIANT *retVal)
|
|||
break;
|
||||
case 30020: //UIA_NativeWindowHandlePropertyId
|
||||
retVal->vt = VT_PTR;
|
||||
retVal->punkVal = m_window;
|
||||
retVal->punkVal = m_screen->coreWindow();
|
||||
break;
|
||||
}
|
||||
return S_OK;
|
||||
|
|
@ -244,7 +237,7 @@ HRESULT QWinRTInputContext::get_HostRawElementProvider(IRawElementProviderSimple
|
|||
{
|
||||
// Return the window's element provider
|
||||
IInspectable *hostProvider;
|
||||
HRESULT hr = m_window->get_AutomationHostProvider(&hostProvider);
|
||||
HRESULT hr = m_screen->coreWindow()->get_AutomationHostProvider(&hostProvider);
|
||||
if (SUCCEEDED(hr)) {
|
||||
hr = hostProvider->QueryInterface(IID_PPV_ARGS(retVal));
|
||||
hostProvider->Release();
|
||||
|
|
|
|||
|
|
@ -58,6 +58,7 @@ namespace ABI {
|
|||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QWinRTScreen;
|
||||
class QWinRTInputContext : public QPlatformInputContext
|
||||
#ifndef Q_OS_WINPHONE
|
||||
, public Microsoft::WRL::RuntimeClass<
|
||||
|
|
@ -66,7 +67,7 @@ class QWinRTInputContext : public QPlatformInputContext
|
|||
#endif // !Q_OS_WINPHONE
|
||||
{
|
||||
public:
|
||||
explicit QWinRTInputContext(ABI::Windows::UI::Core::ICoreWindow *window);
|
||||
explicit QWinRTInputContext(QWinRTScreen *);
|
||||
|
||||
QRectF keyboardRect() const;
|
||||
|
||||
|
|
@ -101,9 +102,10 @@ private:
|
|||
ABI::Windows::UI::ViewManagement::IInputPaneVisibilityEventArgs *);
|
||||
HRESULT onHiding(ABI::Windows::UI::ViewManagement::IInputPane *,
|
||||
ABI::Windows::UI::ViewManagement::IInputPaneVisibilityEventArgs *);
|
||||
void setKeyboardRect(const QRectF rect);
|
||||
|
||||
ABI::Windows::UI::Core::ICoreWindow *m_window;
|
||||
HRESULT handleVisibilityChange(ABI::Windows::UI::ViewManagement::IInputPane *);
|
||||
|
||||
QWinRTScreen *m_screen;
|
||||
QRectF m_keyboardRect;
|
||||
bool m_isInputPanelVisible;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -497,9 +497,9 @@ QWinRTScreen::QWinRTScreen()
|
|||
Q_ASSERT_SUCCEEDED(hr);
|
||||
|
||||
#ifdef Q_OS_WINPHONE
|
||||
d->inputContext.reset(new QWinRTInputContext(d->coreWindow.Get()));
|
||||
d->inputContext.reset(new QWinRTInputContext(this));
|
||||
#else
|
||||
d->inputContext = Make<QWinRTInputContext>(d->coreWindow.Get());
|
||||
d->inputContext = Make<QWinRTInputContext>(this);
|
||||
#endif
|
||||
|
||||
Rect rect;
|
||||
|
|
@ -680,6 +680,12 @@ QDpi QWinRTScreen::logicalDpi() const
|
|||
return QDpi(d->logicalDpi, d->logicalDpi);
|
||||
}
|
||||
|
||||
qreal QWinRTScreen::scaleFactor() const
|
||||
{
|
||||
Q_D(const QWinRTScreen);
|
||||
return d->scaleFactor;
|
||||
}
|
||||
|
||||
QWinRTInputContext *QWinRTScreen::inputContext() const
|
||||
{
|
||||
Q_D(const QWinRTScreen);
|
||||
|
|
|
|||
|
|
@ -93,6 +93,7 @@ public:
|
|||
QSurfaceFormat surfaceFormat() const;
|
||||
QSizeF physicalSize() const Q_DECL_OVERRIDE;
|
||||
QDpi logicalDpi() const Q_DECL_OVERRIDE;
|
||||
qreal scaleFactor() const;
|
||||
QWinRTInputContext *inputContext() const;
|
||||
QPlatformCursor *cursor() const;
|
||||
Qt::KeyboardModifiers keyboardModifiers() const;
|
||||
|
|
|
|||
Loading…
Reference in New Issue