Fix hi-dpi mouse and tablet events on Android
Windows are not always fullscreen: e.g. the widget gallery example main window isn't maximized, and a popup window may open anywhere on the screen. So we always needed to offset by the window position. But it's better to use QPlatformWindow::mapFromGlobal() since we are working with native coordinates here. Pick-to: 6.5 6.2 Fixes: QTBUG-109025 Change-Id: Id3d139fad610bbbc67a394599570a309196ae64c Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io> (cherry picked from commit 05de22e5f9edb107115029a126170034a78a5096) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
1f7749ad31
commit
3369a7ab5f
@ -8,6 +8,7 @@
|
||||
#include "androidjnimain.h"
|
||||
#include "qandroidplatformintegration.h"
|
||||
|
||||
#include <qpa/qplatformwindow.h>
|
||||
#include <qpa/qwindowsysteminterface.h>
|
||||
#include <QTouchEvent>
|
||||
#include <QPointer>
|
||||
@ -99,7 +100,7 @@ namespace QtAndroidInput
|
||||
QPoint globalPos(x,y);
|
||||
QWindow *tlw = topLevelWindowAt(globalPos);
|
||||
m_mouseGrabber = tlw;
|
||||
QPoint localPos = tlw ? (globalPos - tlw->position()) : globalPos;
|
||||
QPoint localPos = tlw && tlw->handle() ? tlw->handle()->mapFromGlobal(globalPos) : globalPos;
|
||||
QWindowSystemInterface::handleMouseEvent(tlw, localPos, globalPos,
|
||||
Qt::MouseButtons(Qt::LeftButton),
|
||||
Qt::LeftButton, QEvent::MouseButtonPress);
|
||||
@ -111,7 +112,8 @@ namespace QtAndroidInput
|
||||
QWindow *tlw = m_mouseGrabber.data();
|
||||
if (!tlw)
|
||||
tlw = topLevelWindowAt(globalPos);
|
||||
QPoint localPos = tlw ? (globalPos -tlw->position()) : globalPos;
|
||||
|
||||
QPoint localPos = tlw && tlw->handle() ? tlw->handle()->mapFromGlobal(globalPos) : globalPos;
|
||||
QWindowSystemInterface::handleMouseEvent(tlw, localPos, globalPos,
|
||||
Qt::MouseButtons(Qt::NoButton),
|
||||
Qt::LeftButton, QEvent::MouseButtonRelease);
|
||||
@ -129,7 +131,7 @@ namespace QtAndroidInput
|
||||
QWindow *tlw = m_mouseGrabber.data();
|
||||
if (!tlw)
|
||||
tlw = topLevelWindowAt(globalPos);
|
||||
QPoint localPos = tlw ? (globalPos-tlw->position()) : globalPos;
|
||||
QPoint localPos = tlw && tlw->handle() ? tlw->handle()->mapFromGlobal(globalPos) : globalPos;
|
||||
QWindowSystemInterface::handleMouseEvent(tlw, localPos, globalPos,
|
||||
Qt::MouseButtons(m_mouseGrabber ? Qt::LeftButton : Qt::NoButton),
|
||||
Qt::NoButton, QEvent::MouseMove);
|
||||
@ -144,7 +146,7 @@ namespace QtAndroidInput
|
||||
QWindow *tlw = m_mouseGrabber.data();
|
||||
if (!tlw)
|
||||
tlw = topLevelWindowAt(globalPos);
|
||||
QPoint localPos = tlw ? (globalPos-tlw->position()) : globalPos;
|
||||
QPoint localPos = tlw && tlw->handle() ? tlw->handle()->mapFromGlobal(globalPos) : globalPos;
|
||||
QPoint angleDelta(hdelta * 120, vdelta * 120);
|
||||
|
||||
QWindowSystemInterface::handleWheelEvent(tlw,
|
||||
@ -167,7 +169,7 @@ namespace QtAndroidInput
|
||||
m_ignoreMouseEvents = true;
|
||||
QPoint globalPos(x,y);
|
||||
QWindow *tlw = topLevelWindowAt(globalPos);
|
||||
QPoint localPos = tlw ? (globalPos-tlw->position()) : globalPos;
|
||||
QPoint localPos = tlw && tlw->handle() ? tlw->handle()->mapFromGlobal(globalPos) : globalPos;
|
||||
|
||||
// Click right button if no other button is already pressed.
|
||||
if (!m_mouseGrabber) {
|
||||
@ -292,7 +294,7 @@ namespace QtAndroidInput
|
||||
QPointF globalPosF(x, y);
|
||||
QPoint globalPos((int)x, (int)y);
|
||||
QWindow *tlw = topLevelWindowAt(globalPos);
|
||||
QPointF localPos = tlw ? (globalPosF - tlw->position()) : globalPosF;
|
||||
QPointF localPos = tlw && tlw->handle() ? tlw->handle()->mapFromGlobalF(globalPosF) : globalPosF;
|
||||
|
||||
// Galaxy Note with plain Android:
|
||||
// 0 1 0 stylus press
|
||||
|
Loading…
x
Reference in New Issue
Block a user