iOS: don't report selection changed if it didn't change

Be more careful about reporting a new selection to Qt. The code for
handling IM selection events in QQuickTextArea is quite complex
and need to take pre-edit text into account. The latter means
that when the pre-edit text changes, as a result of the user composing
a word, the width of the pre-edit text will also change (and as
such, the cursor rectangle). But the cursor position itself stays
the same.  And for this reason, it emits cursorRectChanged more often
than strictly needed. But rather than trying to clean that up, we
do some extra checking before we send the IM event from QPA in
the first place.

Fixes: QTBUG-63018
Change-Id: I689d989c3fe5d61ef2b1dbee7a70418b7790bce9
Reviewed-by: Andy Shaw <andy.shaw@qt.io>
(cherry picked from commit be06164201d7d9ccdbaaff343af2e8f3662c044d)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Richard Moe Gustavsen 2021-02-04 13:33:56 +01:00 committed by Qt Cherry-pick Bot
parent 89590a1fed
commit cdf8c96118

View File

@ -640,8 +640,12 @@ static void executeBlockWithoutAnimation(Block block)
- (void)updateFocalPoint:(QPointF)touchPoint
{
QPlatformInputContext::setSelectionOnFocusObject(touchPoint, touchPoint);
self.focalPoint = touchPoint;
const int currentCursorPos = QInputMethod::queryFocusObject(Qt::ImCursorPosition, QVariant()).toInt();
const int newCursorPos = QPlatformInputContext::queryFocusObject(Qt::ImCursorPosition, touchPoint).toInt();
if (newCursorPos != currentCursorPos)
QPlatformInputContext::setSelectionOnFocusObject(touchPoint, touchPoint);
}
@end