aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Moe Gustavsen <richard.gustavsen@qt.io>2021-02-25 13:47:37 +0100
committerRichard Moe Gustavsen <richard.gustavsen@qt.io>2021-03-05 08:49:07 +0100
commit79cde77f23358adbe57ab8ce08730d2de5bb1288 (patch)
treef1d450c9fa6486aa994710283b64338dc5492954
parent38cb0e9a74bf44413590b96767773b3138ad6666 (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 Pick-to: 6.1 Change-Id: Idc5720a2aad2b0b5714807965e0edc4e8325bfdc Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
-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);