summaryrefslogtreecommitdiffstats
path: root/src/gui/kernel
diff options
context:
space:
mode:
authorShawn Rutledge <shawn.rutledge@qt.io>2020-09-30 21:32:44 +0200
committerShawn Rutledge <shawn.rutledge@qt.io>2020-09-30 23:17:50 +0200
commit871d19a5b96fa5a5be4ac50e3121e0704ff08374 (patch)
tree9f73926dae70696e4dd86ccbf4aaab6924dda3b2 /src/gui/kernel
parent7ee682a1ddc259225618b57ff00f4c36ff5e724c (diff)
Treat a double-click event as an update event with stationary point
The sequence is still press, release, press, double-click, release. isBeginEvent() should not be true for a double-click event: the second click began with a normal MouseButtonPress, and the MouseButtonDblClick event is a way of sending updated state to tell the recipient that the second click was special, occurring within such spatial and temporal constraints that it can be interpreted as a double-click. It never has a different position either, because MouseButtonDblClick is a synthetic event occurring at the same position as the second press; so we might as well say its QEventPoint is Stationary. Together, these changes fix tst_controls::Basic::DelayButton::test_mouse in Controls 2, without any changes in qtdeclarative. In QQuickWindowPrivate::deliverPointerEvent(), if isBeginEvent() == true, it delivers to all items under the point position(s) first, and then if all _updated_ points were not accepted, it continues delivery to grabbers; whereas if isBeginEvent() == false, it delivers only to grabbers. isBeginEvent() and QEventPoint::state() are important to that algorithm. Amends 6d6ed64d6ca27c1b5fec305e6ed9b923b5bb1037 Task-number: QTBUG-87018 Change-Id: I95def9704652147540df5cc065354a0fe04ed626 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Diffstat (limited to 'src/gui/kernel')
-rw-r--r--src/gui/kernel/qevent.cpp16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/gui/kernel/qevent.cpp b/src/gui/kernel/qevent.cpp
index 2772ca6fe2..087873d67e 100644
--- a/src/gui/kernel/qevent.cpp
+++ b/src/gui/kernel/qevent.cpp
@@ -851,8 +851,10 @@ QSinglePointEvent::QSinglePointEvent(QEvent::Type type, const QPointingDevice *d
mut.setGlobalPosition(globalPos);
if (isWheel && mut.state() != QEventPoint::State::Updated)
mut.setGlobalPressPosition(globalPos);
- if (button == Qt::NoButton || isWheel)
- mut.setState(QEventPoint::State::Updated); // stationary only happens with touch events, not single-point events
+ if (type == MouseButtonDblClick)
+ mut.setState(QEventPoint::State::Stationary);
+ else if (button == Qt::NoButton || isWheel)
+ mut.setState(QEventPoint::State::Updated);
else if (isPress)
mut.setState(QEventPoint::State::Pressed);
else
@@ -890,7 +892,11 @@ QSinglePointEvent::QSinglePointEvent(QEvent::Type type, const QPointingDevice *d
*/
bool QSinglePointEvent::isBeginEvent() const
{
- return m_button != Qt::NoButton && m_mouseState.testFlag(m_button);
+ // A double-click event does not begin a sequence: it comes after a press event,
+ // and while it tells which button caused the double-click, it doesn't represent
+ // a change of button state. So it's an update event.
+ return m_button != Qt::NoButton && m_mouseState.testFlag(m_button)
+ && type() != QEvent::MouseButtonDblClick;
}
/*!
@@ -898,7 +904,9 @@ bool QSinglePointEvent::isBeginEvent() const
*/
bool QSinglePointEvent::isUpdateEvent() const
{
- return m_button == Qt::NoButton;
+ // A double-click event is an update event even though it tells which button
+ // caused the double-click, because a MouseButtonPress event was sent right before it.
+ return m_button == Qt::NoButton || type() == QEvent::MouseButtonDblClick;
}
/*!