From de9d486d2fd9af4024045ae004006b4608fe9d08 Mon Sep 17 00:00:00 2001 From: Povilas Kanapickas Date: Sun, 30 May 2021 19:00:30 +0300 Subject: [PATCH] Properly scale gesture positions in hi-DPI case MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The local/global positions for gestures should be handled the same as for other events as they mean effectively the same thing. Change-Id: Ic5ad995607ecd3daf385a7c7be3b67cbae312e7b Reviewed-by: Morten Johan Sørvig --- src/gui/kernel/qwindowsysteminterface.cpp | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/gui/kernel/qwindowsysteminterface.cpp b/src/gui/kernel/qwindowsysteminterface.cpp index 355ebb87ec..0fd5604193 100644 --- a/src/gui/kernel/qwindowsysteminterface.cpp +++ b/src/gui/kernel/qwindowsysteminterface.cpp @@ -1042,16 +1042,24 @@ void QWindowSystemInterface::handleTabletLeaveProximityEvent(int deviceType, int bool QWindowSystemInterface::handleGestureEvent(QWindow *window, ulong timestamp, const QPointingDevice *device, Qt::NativeGestureType type, const QPointF &local, const QPointF &global, int fingerCount) { + auto localPos = QHighDpi::fromNativeLocalPosition(local, window); + auto globalPos = QHighDpi::fromNativeGlobalPosition(global, window); + QWindowSystemInterfacePrivate::GestureEvent *e = - new QWindowSystemInterfacePrivate::GestureEvent(window, timestamp, type, device, fingerCount, local, global); + new QWindowSystemInterfacePrivate::GestureEvent(window, timestamp, type, device, + fingerCount, localPos, globalPos); return QWindowSystemInterfacePrivate::handleWindowSystemEvent(e); } bool QWindowSystemInterface::handleGestureEventWithRealValue(QWindow *window, ulong timestamp, const QPointingDevice *device, Qt::NativeGestureType type, qreal value, const QPointF &local, const QPointF &global, int fingerCount) { + auto localPos = QHighDpi::fromNativeLocalPosition(local, window); + auto globalPos = QHighDpi::fromNativeGlobalPosition(global, window); + QWindowSystemInterfacePrivate::GestureEvent *e = - new QWindowSystemInterfacePrivate::GestureEvent(window, timestamp, type, device, fingerCount, local, global); + new QWindowSystemInterfacePrivate::GestureEvent(window, timestamp, type, device, + fingerCount, localPos, globalPos); e->realValue = value; return QWindowSystemInterfacePrivate::handleWindowSystemEvent(e); } @@ -1060,8 +1068,12 @@ bool QWindowSystemInterface::handleGestureEventWithValueAndDelta(QWindow *window Qt::NativeGestureType type, qreal value, const QPointF &delta, const QPointF &local, const QPointF &global, int fingerCount) { + auto localPos = QHighDpi::fromNativeLocalPosition(local, window); + auto globalPos = QHighDpi::fromNativeGlobalPosition(global, window); + QWindowSystemInterfacePrivate::GestureEvent *e = - new QWindowSystemInterfacePrivate::GestureEvent(window, timestamp, type, device, fingerCount, local, global); + new QWindowSystemInterfacePrivate::GestureEvent(window, timestamp, type, device, + fingerCount, localPos, globalPos); e->realValue = value; e->delta = delta; return QWindowSystemInterfacePrivate::handleWindowSystemEvent(e);