diff options
author | Shawn Rutledge <shawn.rutledge@qt.io> | 2022-05-30 23:04:22 +0200 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2022-06-08 10:24:49 +0000 |
commit | dc71fcd46eb10bdda411f4397cc66f76eba68584 (patch) | |
tree | 3a1a22d7ea1e320f673d05bd46316c19ba3dd67e /src/quick/util/qquickdeliveryagent_p_p.h | |
parent | e2a3667e341a91f8ddedcb4341b0dcced6788327 (diff) |
QQuickItem: ignore double-clicks by default; remove allowDoubleClick
Because Qt has a pattern that events arrive pre-accepted, most
event-handling functions in QQuickItem call ignore(), and it's up to
subclasses to override those functions to allow the event to remain
accepted, if they choose to handle it. So it was odd that
QQuickItem::mouseDoubleClickEvent() did not call ignore().
Pointer handlers don't handle MouseButtonDblClick events, so
QQuickDeliveryAgent does not send those events to handlers. Since
0e3adb65b0e9c44fa6e202630ff57c907ecf0820 though, we disallowed delivery
of double-click events to Items after any handler has already accepted
the single point in a mouse event. This caused some inconsistencies; in
fact the allowDoubleClick variable was getting thrashed a lot, making it
hard to reason about the logic. Items that contained handlers behaved
differently than items that did not. One scenario being fixed here was
absurd: a parent Rectangle (which never handles pointer events on its
own) got an implicit grab in deliverMatchingPointsToItem() and thus
stole the grab from a handler (!), during delivery of a
MouseButtonDblClick (!!), just because the event happened to remain
accepted, even though no item or handler reacted to it directly.
The Rectangle needs to ignore() the event to avoid that, just as all
Items now do by default. Then it turns out that we don't need a stateful
allowDoubleClick anymore: the logic is more consistent without it.
Items can handle double-clicks, but they don't by default, as with any
other pointer event. Pointer handlers don't handle MouseButtonDblClick
because they detect double-clicks in their own way, and that's enforced
by simply not sending those events to handlers. Passive grabs should be
retained regardless of the interloper MouseButtonDblClick event: items
that handle it cannot cancel a handler's passive grab. They can steal a
handler's exclusive grab, but that should be prevented in other ways,
such as ignoring the event so that there is no accidental implicit grab.
Reverts 0e3adb65b0e9c44fa6e202630ff57c907ecf0820. DeliveryAgent no longer
calls clearPassiveGrabbers() directly as QQuickWindow did then; and it
also no longer delivers MouseButtonDblClick the same as a press event.
QSinglePointEvent::isBeginEvent() returns false in that case, so
deliverPressOrReleaseEvent() is not called.
A couple of existing tests now need to avoid generating double-clicks,
but they were not trying to test that anyway. New tests are added (test
coverage of double-clicks has been unfortunately sparse so far).
Fixes: QTBUG-102625
Change-Id: If74baff68ffc46b8b403d37f4e10ddf6b159d40c
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Doris Verria <doris.verria@qt.io>
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
(cherry picked from commit 72651a50f83aa72998822312c7b5c6235d28978f)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'src/quick/util/qquickdeliveryagent_p_p.h')
-rw-r--r-- | src/quick/util/qquickdeliveryagent_p_p.h | 1 |
1 files changed, 0 insertions, 1 deletions
diff --git a/src/quick/util/qquickdeliveryagent_p_p.h b/src/quick/util/qquickdeliveryagent_p_p.h index b962864103..153fdf765e 100644 --- a/src/quick/util/qquickdeliveryagent_p_p.h +++ b/src/quick/util/qquickdeliveryagent_p_p.h @@ -118,7 +118,6 @@ public: #endif uchar compressedTouchCount = 0; bool allowChildEventFiltering = true; - bool allowDoubleClick = true; bool frameSynchronousHoverEnabled = true; bool hoveredLeafItemFound = false; |