aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/handlers
diff options
context:
space:
mode:
authorShawn Rutledge <shawn.rutledge@qt.io>2017-02-10 10:01:39 +0100
committerShawn Rutledge <shawn.rutledge@qt.io>2017-02-17 13:22:52 +0000
commite9a2155cfd76666043dee8c034708a0149f3e2e6 (patch)
tree1cbf4282fd29c50c22d1b915927f6a42ad972613 /src/quick/handlers
parent7042cfd9cb1b552c5fd753b6912439ce604eb1a0 (diff)
DragHandler: keep the grab (prevent stealing) when dragging
Whenever the DragHandler gets an exclusive grab, it needs to prevent a parent Flickable (for example) from taking over that grab. Since it waits until the drag threshold is exceeded in an allowed dragging direction, this does not prevent the Flickable from being draggable in the other direction. We restore the state of keepTouchGrab and keepMouseGrab when ungrabbing. Change-Id: Id9d456c99322e0cb6996d1f690b38fcd6becc6f9 Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
Diffstat (limited to 'src/quick/handlers')
-rw-r--r--src/quick/handlers/qquickdraghandler.cpp8
-rw-r--r--src/quick/handlers/qquickpointerhandler.cpp10
-rw-r--r--src/quick/handlers/qquickpointerhandler_p.h2
3 files changed, 20 insertions, 0 deletions
diff --git a/src/quick/handlers/qquickdraghandler.cpp b/src/quick/handlers/qquickdraghandler.cpp
index 9575f7ede9..db17df36ca 100644
--- a/src/quick/handlers/qquickdraghandler.cpp
+++ b/src/quick/handlers/qquickdraghandler.cpp
@@ -98,6 +98,14 @@ void QQuickDragHandler::handleEventPoint(QQuickEventPoint *point)
} else if ((m_xAxis.enabled() && QQuickWindowPrivate::dragOverThreshold(delta.x(), Qt::XAxis, point)) ||
(m_yAxis.enabled() && QQuickWindowPrivate::dragOverThreshold(delta.y(), Qt::YAxis, point))) {
setExclusiveGrab(point);
+ if (target()) {
+ if (point->pointerEvent()->asPointerTouchEvent())
+ target()->setKeepTouchGrab(true);
+ // tablet and mouse are treated the same by Item's legacy event handling, and
+ // touch becomes synth-mouse for Flickable, so we need to prevent stealing
+ // mouse grab too, whenever dragging occurs in an enabled direction
+ target()->setKeepMouseGrab(true);
+ }
}
} break;
default:
diff --git a/src/quick/handlers/qquickpointerhandler.cpp b/src/quick/handlers/qquickpointerhandler.cpp
index 641324e61e..90d07b5d6d 100644
--- a/src/quick/handlers/qquickpointerhandler.cpp
+++ b/src/quick/handlers/qquickpointerhandler.cpp
@@ -62,6 +62,8 @@ QQuickPointerHandler::QQuickPointerHandler(QObject *parent)
, m_enabled(true)
, m_active(false)
, m_targetExplicitlySet(false)
+ , m_hadKeepMouseGrab(false)
+ , m_hadKeepTouchGrab(false)
{
}
@@ -92,12 +94,20 @@ void QQuickPointerHandler::setExclusiveGrab(QQuickEventPoint *point, bool grab)
{
QQuickPointerHandler *oldGrabber = point->grabberPointerHandler();
if (grab && oldGrabber != this) {
+ if (target()) {
+ m_hadKeepMouseGrab = target()->keepMouseGrab();
+ m_hadKeepTouchGrab = target()->keepTouchGrab();
+ }
if (oldGrabber)
oldGrabber->handleGrabCancel(point);
point->setGrabberPointerHandler(this, true);
onGrabChanged(point);
// emit grabChanged(point); // TODO maybe
} else if (!grab && oldGrabber == this) {
+ if (auto tgt = target()) {
+ tgt->setKeepMouseGrab(m_hadKeepMouseGrab);
+ tgt->setKeepTouchGrab(m_hadKeepTouchGrab);
+ }
point->setGrabberPointerHandler(nullptr, true);
onGrabChanged(point);
// emit grabChanged(point); // TODO maybe
diff --git a/src/quick/handlers/qquickpointerhandler_p.h b/src/quick/handlers/qquickpointerhandler_p.h
index 0931cfcfad..39362ca2e0 100644
--- a/src/quick/handlers/qquickpointerhandler_p.h
+++ b/src/quick/handlers/qquickpointerhandler_p.h
@@ -113,6 +113,8 @@ private:
bool m_enabled : 1;
bool m_active : 1;
bool m_targetExplicitlySet : 1;
+ bool m_hadKeepMouseGrab : 1; // some handlers override target()->setKeepMouseGrab(); this remembers previous state
+ bool m_hadKeepTouchGrab : 1; // some handlers override target()->setKeepTouchGrab(); this remembers previous state
friend class QQuickEventPoint;
};