aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/handlers/qquickpointerhandler.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/quick/handlers/qquickpointerhandler.cpp')
-rw-r--r--src/quick/handlers/qquickpointerhandler.cpp17
1 files changed, 15 insertions, 2 deletions
diff --git a/src/quick/handlers/qquickpointerhandler.cpp b/src/quick/handlers/qquickpointerhandler.cpp
index 4c60180f46..731de295e9 100644
--- a/src/quick/handlers/qquickpointerhandler.cpp
+++ b/src/quick/handlers/qquickpointerhandler.cpp
@@ -65,10 +65,14 @@ QQuickPointerHandler::QQuickPointerHandler(QObject *parent)
void QQuickPointerHandler::setGrab(QQuickEventPoint *point, bool grab)
{
- if (grab)
+ if (grab) {
+ QQuickPointerHandler *oldGrabber = point->grabberPointerHandler();
+ if (oldGrabber && oldGrabber != this)
+ oldGrabber->handleGrabCancel(point);
point->setGrabberPointerHandler(this);
- else if (point->grabberPointerHandler() == this)
+ } else if (point->grabberPointerHandler() == this) {
point->setGrabberPointerHandler(nullptr);
+ }
}
QPointF QQuickPointerHandler::eventPos(const QQuickEventPoint *point) const
@@ -130,6 +134,15 @@ void QQuickPointerHandler::handlePointerEvent(QQuickPointerEvent *event)
handlePointerEventImpl(event);
}
+void QQuickPointerHandler::handleGrabCancel(QQuickEventPoint *point)
+{
+ qCDebug(lcPointerHandlerDispatch) << point;
+ Q_ASSERT(point);
+ setActive(false);
+ point->setAccepted(false);
+ emit canceled(point);
+}
+
bool QQuickPointerHandler::wantsPointerEvent(QQuickPointerEvent *event)
{
Q_UNUSED(event)