diff options
author | Paul Olav Tvete <paul.tvete@digia.com> | 2013-11-14 15:39:28 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-11-14 21:15:35 +0100 |
commit | b8c93d4592837f3a4d30a543d461d432f2cd59eb (patch) | |
tree | c8dec86303bd35b53295f8c65d4860c8c11983de | |
parent | 4577026397ac15bead5ddcbda4b0a57bae831acb (diff) |
Android: work around input method cursor position bug
Since the Qt input method queries only give us information
on the position within the block, moving to the same position
in a different block will be interpreted as not moving.
The quick fix is to send a fake position before the real one in
this case.
Task-number: QTBUG-34845
Change-Id: I5d62bdffc283e41d0384c60a0b69c01811caa629
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@digia.com>
Reviewed-by: BogDan Vatra <bogdan@kde.org>
-rw-r--r-- | src/plugins/platforms/android/src/androidjniinput.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/plugins/platforms/android/src/androidjniinput.cpp b/src/plugins/platforms/android/src/androidjniinput.cpp index 27d29129f8..8ce95532d3 100644 --- a/src/plugins/platforms/android/src/androidjniinput.cpp +++ b/src/plugins/platforms/android/src/androidjniinput.cpp @@ -67,12 +67,32 @@ namespace QtAndroidInput static QPointer<QWindow> m_mouseGrabber; + static int m_lastCursorPos = -1; + void updateSelection(int selStart, int selEnd, int candidatesStart, int candidatesEnd) { AttachedJNIEnv env; if (!env.jniEnv) return; +#ifdef QT_DEBUG_ANDROID_IM_PROTOCOL + qDebug() << ">>> UPDATESELECTION" << selStart << selEnd << candidatesStart << candidatesEnd; +#endif + if (candidatesStart == -1 && candidatesEnd == -1 && selStart == selEnd) { + // Qt only gives us position inside the block, so if we move to the + // same position in another block, the Android keyboard will believe + // we have not changed position, and be terribly confused. + if (selStart == m_lastCursorPos) { +#ifdef QT_DEBUG_ANDROID_IM_PROTOCOL + qDebug() << ">>> FAKEUPDATESELECTION" << selStart+1; +#endif + env.jniEnv->CallStaticVoidMethod(applicationClass(), m_updateSelectionMethodID, + selStart+1, selEnd+1, candidatesStart, candidatesEnd); + } + m_lastCursorPos = selStart; + } else { + m_lastCursorPos = -1; + } env.jniEnv->CallStaticVoidMethod(applicationClass(), m_updateSelectionMethodID, selStart, selEnd, candidatesStart, candidatesEnd); } |