Modified: trunk/Tools/ChangeLog (120206 => 120207)
--- trunk/Tools/ChangeLog 2012-06-13 14:40:02 UTC (rev 120206)
+++ trunk/Tools/ChangeLog 2012-06-13 15:01:49 UTC (rev 120207)
@@ -1,3 +1,20 @@
+2012-06-13 Allan Sandfeld Jensen <[email protected]>
+
+ [Qt] Handle multiple held buttons in touch mocking.
+ https://bugs.webkit.org/show_bug.cgi?id=88865
+
+ Reviewed by Kenneth Rohde Christiansen.
+
+ Add handling for multiple held mouse-buttons in the appropiate places.
+ To do this last-pos and start-pos are now also read from the last recorded
+ touch-point instead from object-global variables.
+
+ * MiniBrowser/qt/MiniBrowserApplication.cpp:
+ (MiniBrowserApplication::notify):
+ (MiniBrowserApplication::updateTouchPoint):
+ * MiniBrowser/qt/MiniBrowserApplication.h:
+ (MiniBrowserApplication):
+
2012-06-13 Simon Hausmann <[email protected]>
[Qt] Make it possible to disable -Werror in production builds
Modified: trunk/Tools/MiniBrowser/qt/MiniBrowserApplication.cpp (120206 => 120207)
--- trunk/Tools/MiniBrowser/qt/MiniBrowserApplication.cpp 2012-06-13 14:40:02 UTC (rev 120206)
+++ trunk/Tools/MiniBrowser/qt/MiniBrowserApplication.cpp 2012-06-13 15:01:49 UTC (rev 120207)
@@ -133,18 +133,6 @@
m_holdingControl = mouseEvent->modifiers().testFlag(Qt::ControlModifier);
QTouchEvent::TouchPoint touchPoint;
-
- touchPoint.setRect(touchRectForPosition(mouseEvent->localPos()));
- touchPoint.setLastPos(m_lastPos);
- m_lastPos = mouseEvent->localPos();
-
- // Gesture recognition uses the screen position for the initial threshold
- // but since the canvas translates touch events we actually need to pass
- // the screen position as the scene position to deliver the appropriate
- // coordinates to the target.
- touchPoint.setSceneRect(touchRectForPosition(mouseEvent->screenPos()));
- touchPoint.setLastScenePos(m_lastScreenPos);
- m_lastScreenPos = mouseEvent->screenPos();
touchPoint.setPressure(1);
QEvent::Type touchType = QEvent::None;
@@ -158,12 +146,15 @@
touchType = QEvent::TouchUpdate;
} else {
touchPoint.setState(Qt::TouchPointPressed);
- touchType = QEvent::TouchBegin;
- m_startScreenPos = mouseEvent->screenPos();
+ // Check if more buttons are held down than just the event triggering one.
+ if (mouseEvent->buttons() > mouseEvent->button())
+ touchType = QEvent::TouchUpdate;
+ else
+ touchType = QEvent::TouchBegin;
}
break;
case QEvent::MouseMove:
- if (!mouseEvent->buttons() || !m_touchPoints.contains(mouseEvent->buttons())) {
+ if (!mouseEvent->buttons()) {
// We have to swallow the event instead of propagating it,
// since we avoid sending the mouse release events and if the
// Flickable is the mouse grabber it would receive the event
@@ -176,32 +167,37 @@
touchPoint.setState(Qt::TouchPointMoved);
break;
case QEvent::MouseButtonRelease:
- touchType = QEvent::TouchEnd;
+ // Check if any buttons are still held down after this event.
+ if (mouseEvent->buttons())
+ touchType = QEvent::TouchUpdate;
+ else
+ touchType = QEvent::TouchEnd;
+ touchPoint.setId(mouseEvent->button());
touchPoint.setState(Qt::TouchPointReleased);
- touchPoint.setId(mouseEvent->button());
- if (m_holdingControl) {
- m_heldTouchPoints.insert(touchPoint.id());
-
- // We avoid sending the release event because the Flickable is
- // listening to mouse events and would start a bounce-back
- // animation if it received a mouse release.
- event->accept();
- return true;
- }
break;
default:
Q_ASSERT_X(false, "multi-touch mocking", "unhandled event type");
}
- // Set the screen pos as the scene pos as canvas translates the touch events.
- touchPoint.setStartScenePos(m_startScreenPos);
+ // A move can have resulted in multiple buttons, so we need check them individually.
+ if (touchPoint.id() & Qt::LeftButton)
+ updateTouchPoint(mouseEvent, touchPoint, Qt::LeftButton);
+ if (touchPoint.id() & Qt::MidButton)
+ updateTouchPoint(mouseEvent, touchPoint, Qt::MidButton);
+ if (touchPoint.id() & Qt::RightButton)
+ updateTouchPoint(mouseEvent, touchPoint, Qt::RightButton);
- // Update current touch-point
- m_touchPoints.insert(touchPoint.id(), touchPoint);
+ if (m_holdingControl && touchPoint.state() == Qt::TouchPointReleased) {
+ // We avoid sending the release event because the Flickable is
+ // listening to mouse events and would start a bounce-back
+ // animation if it received a mouse release.
+ event->accept();
+ return true;
+ }
// Update states for all other touch-points
for (QHash<int, QTouchEvent::TouchPoint>::iterator it = m_touchPoints.begin(), end = m_touchPoints.end(); it != end; ++it) {
- if (it.value().id() != touchPoint.id())
+ if (!(it.value().id() & touchPoint.id()))
it.value().setState(Qt::TouchPointStationary);
}
@@ -217,6 +213,34 @@
return QGuiApplication::notify(target, event);
}
+void MiniBrowserApplication::updateTouchPoint(const QMouseEvent* mouseEvent, QTouchEvent::TouchPoint touchPoint, Qt::MouseButton mouseButton)
+{
+ if (m_holdingControl && touchPoint.state() == Qt::TouchPointReleased) {
+ m_heldTouchPoints.insert(mouseButton);
+ return;
+ }
+ // Gesture recognition uses the screen position for the initial threshold
+ // but since the canvas translates touch events we actually need to pass
+ // the screen position as the scene position to deliver the appropriate
+ // coordinates to the target.
+ touchPoint.setRect(touchRectForPosition(mouseEvent->localPos()));
+ touchPoint.setSceneRect(touchRectForPosition(mouseEvent->screenPos()));
+
+ if (touchPoint.state() == Qt::TouchPointPressed)
+ touchPoint.setStartScenePos(mouseEvent->screenPos());
+ else {
+ const QTouchEvent::TouchPoint& oldTouchPoint = m_touchPoints[mouseButton];
+ touchPoint.setStartScenePos(oldTouchPoint.startScenePos());
+ touchPoint.setLastPos(oldTouchPoint.pos());
+ touchPoint.setLastScenePos(oldTouchPoint.scenePos());
+ }
+
+ // Update current touch-point.
+ touchPoint.setId(mouseButton);
+ m_touchPoints.insert(mouseButton, touchPoint);
+}
+
+
bool MiniBrowserApplication::sendTouchEvent(BrowserWindow* browserWindow, QEvent::Type type, ulong timestamp)
{
static QTouchDevice* device = 0;
Modified: trunk/Tools/MiniBrowser/qt/MiniBrowserApplication.h (120206 => 120207)
--- trunk/Tools/MiniBrowser/qt/MiniBrowserApplication.h 2012-06-13 14:40:02 UTC (rev 120206)
+++ trunk/Tools/MiniBrowser/qt/MiniBrowserApplication.h 2012-06-13 15:01:49 UTC (rev 120207)
@@ -101,6 +101,7 @@
virtual bool notify(QObject*, QEvent*);
private:
+ void updateTouchPoint(const QMouseEvent*, QTouchEvent::TouchPoint, Qt::MouseButton);
bool sendTouchEvent(BrowserWindow*, QEvent::Type, ulong timestamp);
void handleUserOptions();
@@ -112,10 +113,6 @@
int m_robotExtraTimeSeconds;
QStringList m_urls;
- QPointF m_lastPos;
- QPointF m_lastScreenPos;
- QPointF m_startScreenPos;
-
QHash<int, QTouchEvent::TouchPoint> m_touchPoints;
QSet<int> m_heldTouchPoints;