aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/handlers/qquickpointerhandler.cpp
diff options
context:
space:
mode:
authorShawn Rutledge <shawn.rutledge@qt.io>2016-11-29 14:50:05 +0100
committerShawn Rutledge <shawn.rutledge@qt.io>2017-02-10 13:04:47 +0000
commit50aaca40fe09a3ab6c927f7a550b2e97cf332a9c (patch)
tree9353a10e848499b14ff8ae0254cbfde67dbce721 /src/quick/handlers/qquickpointerhandler.cpp
parent02f430462b4e9256b6ae021e3d415c0d2180404d (diff)
start making explicit exclusive or passive grabs
Change-Id: I4a6e3c72d69e893fec2e39f4faab24af6d00c7e0 Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
Diffstat (limited to 'src/quick/handlers/qquickpointerhandler.cpp')
-rw-r--r--src/quick/handlers/qquickpointerhandler.cpp34
1 files changed, 28 insertions, 6 deletions
diff --git a/src/quick/handlers/qquickpointerhandler.cpp b/src/quick/handlers/qquickpointerhandler.cpp
index 0398863ba3..c91fb2de88 100644
--- a/src/quick/handlers/qquickpointerhandler.cpp
+++ b/src/quick/handlers/qquickpointerhandler.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2017 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the QtQuick module of the Qt Toolkit.
@@ -42,6 +42,7 @@
QT_BEGIN_NAMESPACE
Q_LOGGING_CATEGORY(lcPointerHandlerDispatch, "qt.quick.handler.dispatch")
+Q_LOGGING_CATEGORY(lcPointerHandlerActive, "qt.quick.handler.active")
/*!
\qmltype PointerHandler
@@ -73,22 +74,42 @@ QQuickPointerHandler::~QQuickPointerHandler()
}
}
-void QQuickPointerHandler::setGrab(QQuickEventPoint *point, bool grab)
+void QQuickPointerHandler::setPassiveGrab(QQuickEventPoint *point, bool grab)
+{
+ if (grab) {
+ point->setGrabberPointerHandler(this, false);
+ emit grabChanged(point);
+ } else if (point->grabberPointerHandler() == this) {
+ // TODO should giving up passive grab imply giving up exclusive grab too?
+ // we're being inconsistent here: check whether the exclusive grabber is this,
+ // then say that the passive grab was canceled.
+ point->cancelPassiveGrab(this);
+ emit grabChanged(point);
+ }
+}
+
+void QQuickPointerHandler::setExclusiveGrab(QQuickEventPoint *point, bool grab)
{
QQuickPointerHandler *oldGrabber = point->grabberPointerHandler();
if (grab && oldGrabber != this) {
if (oldGrabber)
oldGrabber->handleGrabCancel(point);
- point->setGrabberPointerHandler(this);
+ point->setGrabberPointerHandler(this, true);
onGrabChanged(point);
- emit grabChanged(point);
+// emit grabChanged(point); // TODO maybe
} else if (!grab && oldGrabber == this) {
- point->setGrabberPointerHandler(nullptr);
+ point->setGrabberPointerHandler(nullptr, true);
onGrabChanged(point);
- emit grabChanged(point);
+// emit grabChanged(point); // TODO maybe
}
}
+void QQuickPointerHandler::cancelAllGrabs(QQuickEventPoint *point)
+{
+ point->cancelAllGrabs(this);
+ emit grabChanged(point);
+}
+
QPointF QQuickPointerHandler::eventPos(const QQuickEventPoint *point) const
{
return (target() ? target()->mapFromScene(point->scenePos()) : point->scenePos());
@@ -164,6 +185,7 @@ bool QQuickPointerHandler::wantsPointerEvent(QQuickPointerEvent *event)
void QQuickPointerHandler::setActive(bool active)
{
if (m_active != active) {
+ qCDebug(lcPointerHandlerActive) << this << m_active << "->" << active;
m_active = active;
onActiveChanged();
emit activeChanged();