summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Moe Gustavsen <richard.gustavsen@qt.io>2021-02-25 13:47:37 +0100
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2021-03-30 18:48:22 +0000
commit9ed9a14be80b377e6681db8076dce31316ded144 (patch)
treec861987ae854a64f06fc8e8a7fb1b6001040db14
parent43cd08cde3e9115753a6b3a817419f199c703405 (diff)
QQuickSinglePointHandler: don't reset the point in hover handlers
A HoverHandler should not reset the reported position when it receives a mouse release. As it stands, a HoverHandler, like all the other SinglPointHandlers, will emit a position change of (0, 0) when clicking on it. This patch will factor the reset code into the virtual handleEventPoint(). By doing so, the subclasses can choose to call the base implementation to opt in for the "reset" logic. This patch will let all the subclasses, except HoverHandler, do that. Fixes: QTBUG-83980 Change-Id: Idc5720a2aad2b0b5714807965e0edc4e8325bfdc Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io> (cherry picked from commit 79cde77f23358adbe57ab8ce08730d2de5bb1288) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r--src/quick/handlers/qquickpointhandler.cpp1
-rw-r--r--src/quick/handlers/qquicksinglepointhandler.cpp16
-rw-r--r--src/quick/handlers/qquicksinglepointhandler_p.h2
-rw-r--r--src/quick/handlers/qquicktaphandler.cpp2
-rw-r--r--src/quick/handlers/qquickwheelhandler.cpp2
5 files changed, 18 insertions, 5 deletions
diff --git a/src/quick/handlers/qquickpointhandler.cpp b/src/quick/handlers/qquickpointhandler.cpp
index c3dd997e4a..147724e5b3 100644
--- a/src/quick/handlers/qquickpointhandler.cpp
+++ b/src/quick/handlers/qquickpointhandler.cpp
@@ -156,6 +156,7 @@ void QQuickPointHandler::handleEventPoint(QPointerEvent *event, QEventPoint &poi
}
point.setAccepted(false); // Just lurking... don't interfere with propagation
emit translationChanged();
+ QQuickSinglePointHandler::handleEventPoint(event, point);
}
QVector2D QQuickPointHandler::translation() const
diff --git a/src/quick/handlers/qquicksinglepointhandler.cpp b/src/quick/handlers/qquicksinglepointhandler.cpp
index 6289177894..aa650654eb 100644
--- a/src/quick/handlers/qquicksinglepointhandler.cpp
+++ b/src/quick/handlers/qquicksinglepointhandler.cpp
@@ -136,13 +136,21 @@ void QQuickSinglePointHandler::handlePointerEventImpl(QPointerEvent *event)
Q_ASSERT(currentPoint);
d->pointInfo.reset(event, *currentPoint);
handleEventPoint(event, *currentPoint);
- if (currentPoint->state() == QEventPoint::Released && (static_cast<QSinglePointEvent *>(event)->buttons() & acceptedButtons()) == Qt::NoButton) {
- setExclusiveGrab(event, *currentPoint, false);
- d->reset();
- }
emit pointChanged();
}
+void QQuickSinglePointHandler::handleEventPoint(QPointerEvent *event, QEventPoint &point)
+{
+ if (point.state() != QEventPoint::Released)
+ return;
+
+ const Qt::MouseButtons releasedButtons = static_cast<QSinglePointEvent *>(event)->buttons();
+ if ((releasedButtons & acceptedButtons()) == Qt::NoButton) {
+ setExclusiveGrab(event, point, false);
+ d_func()->reset();
+ }
+}
+
void QQuickSinglePointHandler::onGrabChanged(QQuickPointerHandler *grabber, QPointingDevice::GrabTransition transition, QPointerEvent *event, QEventPoint &point)
{
Q_D(QQuickSinglePointHandler);
diff --git a/src/quick/handlers/qquicksinglepointhandler_p.h b/src/quick/handlers/qquicksinglepointhandler_p.h
index 85ab4f24d4..fd0351b3db 100644
--- a/src/quick/handlers/qquicksinglepointhandler_p.h
+++ b/src/quick/handlers/qquicksinglepointhandler_p.h
@@ -76,7 +76,7 @@ protected:
bool wantsPointerEvent(QPointerEvent *event) override;
void handlePointerEventImpl(QPointerEvent *event) override;
- virtual void handleEventPoint(QPointerEvent *event, QEventPoint &point) = 0;
+ virtual void handleEventPoint(QPointerEvent *event, QEventPoint &point);
QEventPoint &currentPoint(QPointerEvent *ev);
void onGrabChanged(QQuickPointerHandler *grabber, QPointingDevice::GrabTransition transition, QPointerEvent *event, QEventPoint &point) override;
diff --git a/src/quick/handlers/qquicktaphandler.cpp b/src/quick/handlers/qquicktaphandler.cpp
index e71738c2d2..0a7cc7e075 100644
--- a/src/quick/handlers/qquicktaphandler.cpp
+++ b/src/quick/handlers/qquicktaphandler.cpp
@@ -162,6 +162,8 @@ void QQuickTapHandler::handleEventPoint(QPointerEvent *event, QEventPoint &point
default:
break;
}
+
+ QQuickSinglePointHandler::handleEventPoint(event, point);
}
/*!
diff --git a/src/quick/handlers/qquickwheelhandler.cpp b/src/quick/handlers/qquickwheelhandler.cpp
index b598e43439..7045f10d8e 100644
--- a/src/quick/handlers/qquickwheelhandler.cpp
+++ b/src/quick/handlers/qquickwheelhandler.cpp
@@ -387,6 +387,8 @@ bool QQuickWheelHandler::wantsPointerEvent(QPointerEvent *event)
void QQuickWheelHandler::handleEventPoint(QPointerEvent *ev, QEventPoint &point)
{
Q_D(QQuickWheelHandler);
+ QQuickSinglePointHandler::handleEventPoint(ev, point);
+
if (ev->type() != QEvent::Wheel)
return;
const QWheelEvent *event = static_cast<const QWheelEvent *>(ev);