From cef33870e4310ad4d86f33a1a3d967ace9f31433 Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Mon, 15 Jun 2015 10:54:56 +0200 Subject: Workaround for Google Keyboard strangeness When deleting selected text, Google Keyboard will call deleteSurroundingText() with a negative beforeLength. This does not make any sense, and not all our controls are able to handle the resulting input method events. This patch interprets a negative beforeLength as a positive afterLength. This works with the cases I have seen so far, but since the keyboard is not following the specification, there may be more weirdness later. Task-number: QTBUG-46637 Change-Id: I410832417f6fb21139c338355e8fcfa57b9e544c Reviewed-by: Eskil Abrahamsen Blomfeldt --- src/plugins/platforms/android/qandroidinputcontext.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/plugins/platforms/android') diff --git a/src/plugins/platforms/android/qandroidinputcontext.cpp b/src/plugins/platforms/android/qandroidinputcontext.cpp index 5c8406ca03..5a007b58c5 100644 --- a/src/plugins/platforms/android/qandroidinputcontext.cpp +++ b/src/plugins/platforms/android/qandroidinputcontext.cpp @@ -650,6 +650,11 @@ jboolean QAndroidInputContext::deleteSurroundingText(jint leftLength, jint right m_composingText.clear(); m_composingTextStart = -1; + if (leftLength < 0) { + rightLength += -leftLength; + leftLength = 0; + } + QInputMethodEvent event; event.setCommitString(QString(), -leftLength, leftLength+rightLength); sendInputMethodEventThreadSafe(&event); -- cgit v1.2.3