summaryrefslogtreecommitdiffstats
path: root/src/gui/kernel/qevent.cpp
diff options
context:
space:
mode:
authorShawn Rutledge <shawn.rutledge@qt.io>2020-10-14 12:39:38 +0200
committerShawn Rutledge <shawn.rutledge@qt.io>2020-10-22 04:54:17 +0000
commit0e5bbf3507666954fefa5e3c4a2eea531ce71259 (patch)
treea14c074b9ddee8a2be4183e912d4563dcd3c34bc /src/gui/kernel/qevent.cpp
parent3310e13a17d2249a86fa533e350744c5593be54f (diff)
Make QEvent::setAccepted() virtual; set QEventPoints state the same
In Qt Quick, when we deliver an item-specific QTouchEvent that contains only the subset of eventpoints that are inside the Item's bounds, traditionally the Item can accept the event to tell the delivery logic that the event is handled and doesn't need to be delivered further. But an Item cannot be expected to have total scene awareness; so now, the delivery is "done" only when all eventpoints in the original event are accepted. This behavior has been working well enough already due to logic in QQuickWindow that iterates the points and accepts them if the event is accepted; but it seems appropriate to move this enforcement into QPointerEvent itself. Making setAccepted() virtual gives us a useful degree of freedom. Event-handling code should alternatively use QEventPoint:setAccepted() or QPointerEvent::setExclusiveGrabber() to take resonsibility for only a subset of the touchpoints. Another way to put it is that we treat QPointerEvent::setAccepted() as a convenience method: accepting the QEventPoints is what counts (at least in Qt Quick). Change-Id: Icec42dc980f407bb5116f5c0852c051a4521105a Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Diffstat (limited to 'src/gui/kernel/qevent.cpp')
-rw-r--r--src/gui/kernel/qevent.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/gui/kernel/qevent.cpp b/src/gui/kernel/qevent.cpp
index 51100f56ff..5938942399 100644
--- a/src/gui/kernel/qevent.cpp
+++ b/src/gui/kernel/qevent.cpp
@@ -684,6 +684,16 @@ bool QPointerEvent::allPointsAccepted() const
}
/*!
+ \reimp
+*/
+void QPointerEvent::setAccepted(bool accepted)
+{
+ QEvent::setAccepted(accepted);
+ for (auto &p : m_points)
+ p.setAccepted(accepted);
+}
+
+/*!
Returns the source device from which this event originates.
This is the same as QInputEvent::device() but typecast for convenience.