From 0d308c4111f7cd322ed4a07e04b83c20e923e06a Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen Date: Thu, 2 May 2013 10:12:30 +0200 Subject: QApplication: fix touch to mouse bug when setting buttons() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit QApplicationPrivate::translateTouchToMouse always sets buttons() to Qt::LeftButton for synthesised events. This is wrong for a mouse release, since 'button' should in that case be Qt::LeftButton, and 'buttons' should be Qt::NoButton (since no buttons are actually being pressed). This caused problems for QGraphicsView, which refuses to release any mouse grab set on a QGraphicsItem if at least one button is being pressed (which was always true). This resulted in broken drag behavior on touch platforms. Change-Id: Iefe63cd753f9f8bb04278fd04a4d728e3deda25e Reviewed-by: Samuel Rødal Reviewed-by: Tor Arne Vestbø Reviewed-by: Frederik Gladhorn Reviewed-by: Shawn Rutledge --- src/widgets/kernel/qapplication.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp index b8d3117a41..edd7cafd83 100644 --- a/src/widgets/kernel/qapplication.cpp +++ b/src/widgets/kernel/qapplication.cpp @@ -3821,7 +3821,8 @@ bool QApplicationPrivate::translateTouchToMouse(QWidget *widget, QTouchEvent *ev const QPoint pos = widget->mapFromGlobal(p.screenPos().toPoint()); QMouseEvent mouseEvent(eventType, pos, p.screenPos().toPoint(), - Qt::LeftButton, Qt::LeftButton, + Qt::LeftButton, + (eventType == QEvent::MouseButtonRelease) ? Qt::NoButton : Qt::LeftButton, event->modifiers()); mouseEvent.setAccepted(true); mouseEvent.setTimestamp(event->timestamp()); -- cgit v1.2.3