diff options
author | Vova Mshanetskiy <vovams163@gmail.com> | 2019-05-31 19:42:57 +0300 |
---|---|---|
committer | Vova Mshanetskiy <vovams163@gmail.com> | 2019-06-28 15:38:04 +0300 |
commit | 2c61b4e0f08e55d5478e710fe66eb12594ae17cb (patch) | |
tree | 08d6f24c50ab4286ae30b3aacdda0ae043b43c30 /src/plugins/platforms | |
parent | 399bf445771936648691c48bebca500b36ae69dd (diff) |
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>
Diffstat (limited to 'src/plugins/platforms')
-rw-r--r-- | src/plugins/platforms/android/qandroidinputcontext.cpp | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/src/plugins/platforms/android/qandroidinputcontext.cpp b/src/plugins/platforms/android/qandroidinputcontext.cpp index bab71751f8..69b100fa4e 100644 --- a/src/plugins/platforms/android/qandroidinputcontext.cpp +++ b/src/plugins/platforms/android/qandroidinputcontext.cpp @@ -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(); } } |