Android: Fix inputItemRectangle when using EnableHighDpiScaling

When EnableHighDpiScaling is enabled, qGuiApp->inputMethod()-
>inputItemRectangle() returns the position divided by pixel density,
therefore all the controls positions must by multiplied by pixel density
to translate them into screen coordinates.

Task-number: QTBUG-52001
Change-Id: Iea92a912cfbab03a9497fc8cddc24bebd0db2192
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@theqtcompany.com>
This commit is contained in:
BogDan Vatra 2016-03-21 11:33:19 +02:00
parent bc913ea452
commit 51e71d4111

View File

@ -39,6 +39,7 @@
#include "androidjniinput.h"
#include "qandroideventdispatcher.h"
#include "androiddeadlockprotector.h"
#include "qandroidplatformintegration.h"
#include <QDebug>
#include <qevent.h>
#include <qguiapplication.h>
@ -47,6 +48,7 @@
#include <qinputmethod.h>
#include <qwindow.h>
#include <QtCore/private/qjni_p.h>
#include <private/qhighdpiscaling_p.h>
#include <QTextCharFormat>
@ -541,10 +543,13 @@ void QAndroidInputContext::showInputPanel()
if (window)
rect = QRect(window->mapToGlobal(rect.topLeft()), rect.size());
QtAndroidInput::showSoftwareKeyboard(rect.left(),
rect.top(),
rect.width(),
rect.height(),
double pixelDensity = window ? QHighDpiScaling::factor(window)
: QHighDpiScaling::factor(QtAndroid::androidPlatformIntegration()->screen());
QtAndroidInput::showSoftwareKeyboard(rect.left() * pixelDensity,
rect.top() * pixelDensity,
rect.width() * pixelDensity,
rect.height() * pixelDensity,
query->value(Qt::ImHints).toUInt(),
query->value(Qt::ImEnterKeyType).toUInt()
);