aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/handlers/qquickpointerhandler.cpp
diff options
context:
space:
mode:
authorShawn Rutledge <shawn.rutledge@qt.io>2016-08-26 16:27:25 +0200
committerShawn Rutledge <shawn.rutledge@qt.io>2016-10-17 14:05:13 +0000
commit68a0023bd5330ff57961240aecdd26e30a62d338 (patch)
treea636a7febc83d7cf41c874580a1a91c72a0fba67 /src/quick/handlers/qquickpointerhandler.cpp
parent37b3c6ecc5cb17021d7251cfca1d6e31d7edda4d (diff)
add QQuickPointerHandler::handleGrabCancel; call in setGrab
Only one handler can be the grabber at one time, so we need to ensure that we notify the others when they lose the grab. Also handle this in QQuickPointerSingleHandler: forget m_currentPointId, so that wantsPointerEvent will not continue to "want" the same ID. Also add the canceled(QQuickEventPoint *point) signal, which is one of the four possible "state signals" (press, update, release, cancel) but which we didn't commit to adding yet. Change-Id: I46256acb75ece863d84e812af2d30cb0b12e3c1f Reviewed-by: Jan Arve Sæther <jan-arve.saether@theqtcompany.com>
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)