Title: [91667] trunk/Tools
- Revision
- 91667
- Author
- [email protected]
- Date
- 2011-07-25 07:48:10 -0700 (Mon, 25 Jul 2011)
Log Message
[Qt][WK2] Add multi-point touch mocking to MiniBrowser
https://bugs.webkit.org/show_bug.cgi?id=64374
Reviewed by Benjamin Poulain.
Each mouse button generate a touch point. The touch point stay
virtually on screen if the mouse release happened while the Ctrl
modifier was pressed.
Modified Paths
Diff
Modified: trunk/Tools/ChangeLog (91666 => 91667)
--- trunk/Tools/ChangeLog 2011-07-25 14:42:45 UTC (rev 91666)
+++ trunk/Tools/ChangeLog 2011-07-25 14:48:10 UTC (rev 91667)
@@ -1,3 +1,18 @@
+2011-07-25 Tor Arne Vestbø <[email protected]>
+
+ [Qt][WK2] Add multi-point touch mocking to MiniBrowser
+ https://bugs.webkit.org/show_bug.cgi?id=64374
+
+ Reviewed by Benjamin Poulain.
+
+ Each mouse button generate a touch point. The touch point stay
+ virtually on screen if the mouse release happened while the Ctrl
+ modifier was pressed.
+
+ * MiniBrowser/qt/MiniBrowserApplication.cpp:
+ (MiniBrowserApplication::notify):
+ * MiniBrowser/qt/MiniBrowserApplication.h:
+
2011-07-25 Balazs Kelemen <[email protected]>
[Qt][WK2] Use NRWT for Qt-WK2
Modified: trunk/Tools/MiniBrowser/qt/MiniBrowserApplication.cpp (91666 => 91667)
--- trunk/Tools/MiniBrowser/qt/MiniBrowserApplication.cpp 2011-07-25 14:42:45 UTC (rev 91666)
+++ trunk/Tools/MiniBrowser/qt/MiniBrowserApplication.cpp 2011-07-25 14:48:10 UTC (rev 91667)
@@ -90,35 +90,54 @@
}
if (isMouseEvent(event)) {
const QMouseEvent* const mouseEvent = static_cast<QMouseEvent*>(event);
- if (mouseEvent->button() != Qt::LeftButton && mouseEvent->buttons() != Qt::LeftButton)
- return QApplication::notify(target, event);
QTouchEvent::TouchPoint touchPoint;
touchPoint.setScreenPos(mouseEvent->globalPos());
touchPoint.setPos(mouseEvent->pos());
- touchPoint.setId(0);
switch (mouseEvent->type()) {
case QEvent::MouseButtonPress:
case QEvent::MouseButtonDblClick:
- touchPoint.setState(Qt::TouchPointPressed);
+ touchPoint.setId(mouseEvent->button());
+ if (m_touchPoints.contains(touchPoint.id()))
+ touchPoint.setState(Qt::TouchPointMoved);
+ else
+ touchPoint.setState(Qt::TouchPointPressed);
break;
case QEvent::MouseMove:
+ if (!mouseEvent->buttons() || !m_touchPoints.contains(mouseEvent->buttons()))
+ return QApplication::notify(target, event);
touchPoint.setState(Qt::TouchPointMoved);
+ touchPoint.setId(mouseEvent->buttons());
break;
case QEvent::MouseButtonRelease:
+ if (mouseEvent->modifiers().testFlag(Qt::ControlModifier))
+ return QApplication::notify(target, event);
touchPoint.setState(Qt::TouchPointReleased);
+ touchPoint.setId(mouseEvent->button());
break;
default:
- Q_ASSERT(false);
- break;
+ Q_ASSERT_X(false, "multi-touch mocking", "unhandled event type");
}
- QList<QTouchEvent::TouchPoint> touchPoints;
- touchPoints.append(touchPoint);
+ // Update current touch-point
+ m_touchPoints.insert(touchPoint.id(), touchPoint);
+
+ // Update states for all other touch-points
+ for (QHash<int, QTouchEvent::TouchPoint>::iterator it = m_touchPoints.begin(); it != m_touchPoints.end(); ++it) {
+ if (it.value().id() != touchPoint.id())
+ it.value().setState(Qt::TouchPointStationary);
+ }
+
m_sendingFakeTouchEvent = true;
- qt_translateRawTouchEvent(0, QTouchEvent::TouchScreen, touchPoints);
+ qt_translateRawTouchEvent(0, QTouchEvent::TouchScreen, m_touchPoints.values());
m_sendingFakeTouchEvent = false;
+
+ // Get rid of touch-points that are no longer valid
+ foreach (const QTouchEvent::TouchPoint& touchPoint, m_touchPoints) {
+ if (touchPoint.state() == Qt::TouchPointReleased)
+ m_touchPoints.remove(touchPoint.id());
+ }
}
return QApplication::notify(target, event);
Modified: trunk/Tools/MiniBrowser/qt/MiniBrowserApplication.h (91666 => 91667)
--- trunk/Tools/MiniBrowser/qt/MiniBrowserApplication.h 2011-07-25 14:42:45 UTC (rev 91666)
+++ trunk/Tools/MiniBrowser/qt/MiniBrowserApplication.h 2011-07-25 14:48:10 UTC (rev 91667)
@@ -29,7 +29,9 @@
#ifndef MiniBrowserApplication_h
#define MiniBrowserApplication_h
+#include <QHash>
#include <QStringList>
+#include <QTouchEvent>
#include <QtGui>
struct WindowOptions {
@@ -75,6 +77,8 @@
int m_robotTimeoutSeconds;
int m_robotExtraTimeSeconds;
QStringList m_urls;
+
+ QHash<int, QTouchEvent::TouchPoint> m_touchPoints;
};
#endif
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes