From fddc0b34dfa7fae74aca43534642a40ea1e30381 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= Date: Wed, 13 Jan 2021 13:55:02 +0100 Subject: Add geometry accessors to QPlatformInputContext Currently the platform plugins use the public QInputMethod API when querying geometry. However, QInputMethod returns geometry in device independent pixels, while the platform plugins require geometry in native pixels. Add new API to QPlatformInputContext which returns input geometry in the native window coordinate system: QRectF inputItemRectangle() QRectF inputItemClipRectangle() QRectF cursorRectangle() QRectF anchorRectangle() QRectF keyboardRectangle() These make the relevant QHighDpi calls internally, and such calls can then be moved out of the platform plugins. Disambiguate inputItemRectangle() in qandroidinputcontext.cpp by renaming it to screenInputItemRectangle(). Change-Id: I561745b64fb197d64e3dfddcf0751528bb8d0605 Reviewed-by: Richard Moe Gustavsen --- src/plugins/platforms/android/qandroidinputcontext.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/plugins/platforms/android') diff --git a/src/plugins/platforms/android/qandroidinputcontext.cpp b/src/plugins/platforms/android/qandroidinputcontext.cpp index 06947c9c32..24cb261e6f 100644 --- a/src/plugins/platforms/android/qandroidinputcontext.cpp +++ b/src/plugins/platforms/android/qandroidinputcontext.cpp @@ -405,7 +405,7 @@ static JNINativeMethod methods[] = { {"updateCursorPosition", "()Z", (void *)updateCursorPosition} }; -static QRect inputItemRectangle() +static QRect screenInputItemRectangle() { QRectF itemRect = qGuiApp->inputMethod()->inputItemRectangle(); QRect rect = qGuiApp->inputMethod()->inputItemTransform().mapRect(itemRect).toRect(); @@ -786,7 +786,7 @@ void QAndroidInputContext::handleLocationChanged(int handleId, int x, int y) void QAndroidInputContext::touchDown(int x, int y) { - if (m_focusObject && inputItemRectangle().contains(x, y)) { + if (m_focusObject && screenInputItemRectangle().contains(x, y)) { // If the user touch the input rectangle, we can show the cursor handle m_handleMode = ShowCursor; // The VK will appear in a moment, stop the timer @@ -820,7 +820,7 @@ void QAndroidInputContext::longPress(int x, int y) if (noHandles) return; - if (m_focusObject && inputItemRectangle().contains(x, y)) { + if (m_focusObject && screenInputItemRectangle().contains(x, y)) { BatchEditLock batchEditLock(this); focusObjectStopComposing(); @@ -928,7 +928,7 @@ void QAndroidInputContext::showInputPanel() else m_updateCursorPosConnection = connect(qGuiApp->focusObject(), SIGNAL(cursorPositionChanged()), this, SLOT(updateCursorPosition())); - QRect rect = inputItemRectangle(); + QRect rect = screenInputItemRectangle(); QtAndroidInput::showSoftwareKeyboard(rect.left(), rect.top(), rect.width(), rect.height(), query->value(Qt::ImHints).toUInt(), query->value(Qt::ImEnterKeyType).toUInt()); -- cgit v1.2.3