From 1bf44cc71f8454a93d2593404887c5672dd5f5ca Mon Sep 17 00:00:00 2001 From: Bartlomiej Moskal Date: Fri, 21 Mar 2025 11:09:06 +0100 Subject: [PATCH] Android: Fix touchDown event coordinates In the touchAdd method, the mapped touch point is divided by the platform integration screen size. In order not to mix different coordinate systems, we should use platformWindow to correctly calculate global position of touch event. Pick-to: 6.8 Task-number: QTBUG-130576 Task-number: QTBUG-127925 Change-Id: Ic7653a60fb3def181f29a3e28b963878dc54a99e Reviewed-by: Assam Boudjelthia (cherry picked from commit 01d25533b4f3c63c0484930e06664ad61ce24748) Reviewed-by: Qt Cherry-pick Bot --- src/plugins/platforms/android/androidjniinput.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/plugins/platforms/android/androidjniinput.cpp b/src/plugins/platforms/android/androidjniinput.cpp index 461b2da51c9..4f27aaff5ca 100644 --- a/src/plugins/platforms/android/androidjniinput.cpp +++ b/src/plugins/platforms/android/androidjniinput.cpp @@ -284,7 +284,12 @@ namespace QtAndroidInput return; } - QPointF mappedTouchPoint = window->mapToGlobal(QPointF(x, y)); + QPointF mappedTouchPoint; + if (window->handle()) + mappedTouchPoint = window->handle()->mapToGlobalF(QPointF(x, y)); + else + mappedTouchPoint = window->mapToGlobal(QPointF(x, y)); + QWindowSystemInterface::TouchPoint touchPoint; // Start numbering touch points from 1 touchPoint.id = id + 1;