From bad32e1f0695304b940ae3301bcd80cbc4512556 Mon Sep 17 00:00:00 2001 From: Bartlomiej Moskal Date: Wed, 18 Oct 2023 21:40:08 +0200 Subject: [PATCH] Android: Hide text handle when it is out or covered The text handle should not be visible in case when it is out of the text-object, or when it is hidden by other object. That is why we should call updateSelectionHandles() method after touch only in case when cursor position fits to clipped input item rectangle. Fixes: QTBUG-115005 Pick-to: 6.5 Change-Id: I35c083acd8fd4d5240e3bb15afa1afbec4ea0b26 Reviewed-by: Assam Boudjelthia (cherry picked from commit d10d76f9f20d48d69117d9f7dab089cb2a696b2e) Reviewed-by: Qt Cherry-pick Bot --- src/plugins/platforms/android/qandroidinputcontext.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/plugins/platforms/android/qandroidinputcontext.cpp b/src/plugins/platforms/android/qandroidinputcontext.cpp index 5b94e553ddf..68a1ba0d07d 100644 --- a/src/plugins/platforms/android/qandroidinputcontext.cpp +++ b/src/plugins/platforms/android/qandroidinputcontext.cpp @@ -769,7 +769,15 @@ void QAndroidInputContext::touchDown(int x, int y) focusObjectStopComposing(); } - updateSelectionHandles(); + // Check if cursor is visible in focused window before updating handles + QPlatformWindow *window = qGuiApp->focusWindow()->handle(); + const QRectF curRect = cursorRectangle(); + const QPoint cursorGlobalPoint = window->mapToGlobal(QPoint(curRect.x(), curRect.y())); + const QRect windowRect = QPlatformInputContext::inputItemClipRectangle().toRect(); + const QRect windowGlobalRect = QRect(window->mapToGlobal(windowRect.topLeft()), windowRect.size()); + + if (windowGlobalRect.contains(cursorGlobalPoint.x(), cursorGlobalPoint.y())) + updateSelectionHandles(); } }