aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/items/qquickevents.cpp
diff options
context:
space:
mode:
authorShawn Rutledge <shawn.rutledge@qt.io>2016-09-01 06:16:18 +0200
committerShawn Rutledge <shawn.rutledge@qt.io>2017-02-02 19:17:35 +0000
commite2fd141372335f917c2d216051abb00d8b15f87c (patch)
tree8521c470e66d1a1badeb3c3020774abc66d639f7 /src/quick/items/qquickevents.cpp
parent73e9dc0667935b7b403c10736775d24d6e22eb8c (diff)
QQuickWindow: deliver updates to handlers even if they don't grab
The "weak grab" concept depends on this. First we deliver to grabbers, then we deliver to non-grabbing handlers (but not to non-grabbing items). Avoid re-delivering to grabbing handlers which already received the same event. Change-Id: If51e1cd9372e3bed1daea3758e9ef8e37c0ba5e3 Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
Diffstat (limited to 'src/quick/items/qquickevents.cpp')
-rw-r--r--src/quick/items/qquickevents.cpp27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/quick/items/qquickevents.cpp b/src/quick/items/qquickevents.cpp
index 0c18cb4104..a68e72b0b7 100644
--- a/src/quick/items/qquickevents.cpp
+++ b/src/quick/items/qquickevents.cpp
@@ -835,6 +835,11 @@ bool QQuickPointerMouseEvent::allPointsAccepted() const {
return m_mousePoint->isAccepted();
}
+bool QQuickPointerMouseEvent::allPointsGrabbed() const
+{
+ return m_mousePoint->grabber() != nullptr;
+}
+
QMouseEvent *QQuickPointerMouseEvent::asMouseEvent(const QPointF &localPos) const
{
auto event = static_cast<QMouseEvent *>(m_event);
@@ -854,6 +859,11 @@ void QQuickPointerMouseEvent::clearGrabbers() const {
m_mousePoint->setGrabberItem(nullptr);
}
+bool QQuickPointerMouseEvent::hasGrabber(const QQuickPointerHandler *handler) const
+{
+ return m_mousePoint->grabber() == handler;
+}
+
bool QQuickPointerMouseEvent::isPressEvent() const
{
auto me = static_cast<QMouseEvent*>(m_event);
@@ -869,6 +879,15 @@ bool QQuickPointerTouchEvent::allPointsAccepted() const {
return true;
}
+bool QQuickPointerTouchEvent::allPointsGrabbed() const
+{
+ for (int i = 0; i < m_pointCount; ++i) {
+ if (!m_touchPoints.at(i)->grabber())
+ return false;
+ }
+ return true;
+}
+
QVector<QObject *> QQuickPointerTouchEvent::grabbers() const
{
QVector<QObject *> result;
@@ -887,6 +906,14 @@ void QQuickPointerTouchEvent::clearGrabbers() const {
point->setGrabber(nullptr);
}
+bool QQuickPointerTouchEvent::hasGrabber(const QQuickPointerHandler *handler) const
+{
+ for (auto point: m_touchPoints)
+ if (point->grabber() == handler)
+ return true;
+ return false;
+}
+
bool QQuickPointerTouchEvent::isPressEvent() const
{
return static_cast<QTouchEvent*>(m_event)->touchPointStates() & Qt::TouchPointPressed;