Warning, /graphics/krita/3rdparty/ext_qt/0002-Bugfix-fix-the-offset-bug-when-using-Stylus-with-And.patch is written in an unsupported language. File is not indexed.
0001 From 12ae384f7253b5b9dd4974f2a92c2d15adb428bf Mon Sep 17 00:00:00 2001 0002 From: Sharaf Zaman <sharafzaz121@gmail.com> 0003 Date: Tue, 11 Feb 2020 18:12:20 +0300 0004 Subject: [PATCH 02/46] Bugfix: fix the offset bug when using Stylus with 0005 Android 0006 0007 Platform plugin for Android calculated the local coordinates of the 0008 tabletEvent by using QWindow::position(), which returned High-DPI 0009 scaled coordinates. But, globalPosF being unscaled made the 0010 calculation invalid. 0011 0012 Proper demonstration of this can be seen in Krita Android. 0013 0014 [ChangeLog][Android] Fix offset bug in tabletEvents 0015 0016 Change-Id: I4679df7de3b1491009708d7e80d5bc176e29afed 0017 --- 0018 .../platforms/android/androidjniinput.cpp | 36 +++++++++++++++---- 0019 1 file changed, 30 insertions(+), 6 deletions(-) 0020 0021 diff --git a/src/plugins/platforms/android/androidjniinput.cpp b/src/plugins/platforms/android/androidjniinput.cpp 0022 index 6ba1aa5e24..a5bd1a58d1 100644 0023 --- a/src/plugins/platforms/android/androidjniinput.cpp 0024 +++ b/src/plugins/platforms/android/androidjniinput.cpp 0025 @@ -43,6 +43,7 @@ 0026 #include "androidjniinput.h" 0027 #include "androidjnimain.h" 0028 #include "qandroidplatformintegration.h" 0029 +#include "qandroidplatformwindow.h" 0030 0031 #include <qpa/qwindowsysteminterface.h> 0032 #include <QTouchEvent> 0033 @@ -137,9 +138,13 @@ namespace QtAndroidInput 0034 return; 0035 0036 QPoint globalPos(x,y); 0037 + QPoint localPos = globalPos; 0038 QWindow *tlw = topLevelWindowAt(globalPos); 0039 + if (tlw) { 0040 + QPlatformWindow *platformWindow = tlw->handle(); 0041 + localPos = platformWindow ? platformWindow->mapFromGlobal(globalPos) : globalPos; 0042 + } 0043 m_mouseGrabber = tlw; 0044 - QPoint localPos = tlw ? (globalPos - tlw->position()) : globalPos; 0045 QWindowSystemInterface::handleMouseEvent(tlw, 0046 localPos, 0047 globalPos, 0048 @@ -152,7 +157,12 @@ namespace QtAndroidInput 0049 QWindow *tlw = m_mouseGrabber.data(); 0050 if (!tlw) 0051 tlw = topLevelWindowAt(globalPos); 0052 - QPoint localPos = tlw ? (globalPos -tlw->position()) : globalPos; 0053 + 0054 + QPoint localPos = globalPos; 0055 + if (tlw) { 0056 + QPlatformWindow *platformWindow = tlw->handle(); 0057 + localPos = platformWindow ? platformWindow->mapFromGlobal(globalPos) : globalPos; 0058 + } 0059 QWindowSystemInterface::handleMouseEvent(tlw, localPos, globalPos 0060 , Qt::MouseButtons(Qt::NoButton)); 0061 m_ignoreMouseEvents = false; 0062 @@ -161,7 +171,6 @@ namespace QtAndroidInput 0063 0064 static void mouseMove(JNIEnv */*env*/, jobject /*thiz*/, jint /*winId*/, jint x, jint y) 0065 { 0066 - 0067 if (m_ignoreMouseEvents) 0068 return; 0069 0070 @@ -169,7 +178,12 @@ namespace QtAndroidInput 0071 QWindow *tlw = m_mouseGrabber.data(); 0072 if (!tlw) 0073 tlw = topLevelWindowAt(globalPos); 0074 - QPoint localPos = tlw ? (globalPos-tlw->position()) : globalPos; 0075 + 0076 + QPoint localPos = globalPos; 0077 + if (tlw) { 0078 + QPlatformWindow *platformWindow = tlw->handle(); 0079 + localPos = platformWindow ? platformWindow->mapFromGlobal(globalPos) : globalPos; 0080 + } 0081 QWindowSystemInterface::handleMouseEvent(tlw, 0082 localPos, 0083 globalPos, 0084 @@ -185,7 +199,12 @@ namespace QtAndroidInput 0085 QWindow *tlw = m_mouseGrabber.data(); 0086 if (!tlw) 0087 tlw = topLevelWindowAt(globalPos); 0088 - QPoint localPos = tlw ? (globalPos-tlw->position()) : globalPos; 0089 + 0090 + QPoint localPos = globalPos; 0091 + if (tlw) { 0092 + QPlatformWindow *platformWindow = tlw->handle(); 0093 + localPos = platformWindow ? platformWindow->mapFromGlobal(globalPos) : globalPos; 0094 + } 0095 QPoint angleDelta(hdelta * 120, vdelta * 120); 0096 0097 QWindowSystemInterface::handleWheelEvent(tlw, 0098 @@ -310,7 +329,12 @@ namespace QtAndroidInput 0099 QPointF globalPosF(x, y); 0100 QPoint globalPos((int)x, (int)y); 0101 QWindow *tlw = topLevelWindowAt(globalPos); 0102 - QPointF localPos = tlw ? (globalPosF - tlw->position()) : globalPosF; 0103 + 0104 + QPointF localPos = globalPosF; 0105 + if (tlw) { 0106 + QPlatformWindow *platformWindow = tlw->handle(); 0107 + localPos = platformWindow ? platformWindow->mapFromGlobal(globalPos) : globalPosF; 0108 + } 0109 0110 // Galaxy Note with plain Android: 0111 // 0 1 0 stylus press 0112 -- 0113 2.33.0 0114