QAndroidInputContext: Do not stop composing when user taps the cursor

There is no need to tell the editor to stop composing if user taps so
close to the cursor position that the cursor will not move anyway. If we
do stop composing in such case, then since there will be no cursor
position change notification, we will never start composing again
(before the cursor is actually moved), and the current composing region
will remain being displayed as normal text instead of being displayed as
composing text.

Change-Id: I4ebe6442e1ba8c365d6754c1a8487235d177c732
Reviewed-by: BogDan Vatra <bogdan@kdab.com>
bb10
Vova Mshanetskiy 2019-05-31 19:42:57 +03:00
parent 399bf44577
commit 2c61b4e0f0
1 changed files with 19 additions and 1 deletions

View File

@ -792,7 +792,25 @@ void QAndroidInputContext::touchDown(int x, int y)
m_handleMode = ShowCursor;
// The VK will appear in a moment, stop the timer
m_hideCursorHandleTimer.stop();
focusObjectStopComposing();
if (focusObjectIsComposing()) {
const double pixelDensity =
QGuiApplication::focusWindow()
? QHighDpiScaling::factor(QGuiApplication::focusWindow())
: QHighDpiScaling::factor(QtAndroid::androidPlatformIntegration()->screen());
const QPointF touchPointLocal =
QGuiApplication::inputMethod()->inputItemTransform().inverted().map(
QPointF(x / pixelDensity, y / pixelDensity));
const int curBlockPos = getBlockPosition(
focusObjectInputMethodQuery(Qt::ImCursorPosition | Qt::ImAbsolutePosition));
const int touchPosition = curBlockPos
+ QInputMethod::queryFocusObject(Qt::ImCursorPosition, touchPointLocal).toInt();
if (touchPosition != m_composingCursor)
focusObjectStopComposing();
}
updateSelectionHandles();
}
}