It would be nice to be able to simulate touch events with a mouse from Q(GV)Launcher. Kim's idea was to have a menu item to toggle mocking. When enabled a single mouse click is converted to be a single touch event instead. Pressing Ctrl + F (as in "finger") will make the last mouse position a stationary touch point and any subsequence mouse clicks produce a second touch point. Pressing Ctrl+F again would remove the second point again.
Created attachment 44954 [details] Adds multitouch mocking to QtLauncher This is pretty much what I had in mind. Now the mocking is switched on by default and can be switched off from the 'Tools'-menu or by pressing Ctrl+Alt+T. The other finger is pressed and released by pressing Ctrl+F and the other is controlled with mouse.
style-queue ran check-webkit-style on attachment 44954 [details] without any errors.
Created attachment 44955 [details] Test page for Touch DOM events. Supports two touchpoints. This test page can be used to test the multi-touch mocking with QtLauncher.
Comment on attachment 44954 [details] Adds multitouch mocking to QtLauncher > +#if QT_VERSION >= QT_VERSION_CHECK(4, 6, 0) > +#include <qevent.h> > +#endif This #if isn't necessary, qevent.h has been there since Qt 1.0 :-) > + bool eventFilter(QObject* obj, QEvent* event) > + { > + if (!touchMocking || obj != view) > + return QObject::eventFilter(obj, event); > + > + if (event->type() == QEvent::MouseButtonPress > + || event->type() == QEvent::MouseButtonRelease > + || event->type() == QEvent::MouseButtonDblClick > + || event->type() == QEvent::MouseMove) { > + > + QMouseEvent* ev = static_cast<QMouseEvent *>(event); Coding style nitpick: No space before the * :) > + if (ev->type() == QEvent::MouseMove > + && !(ev->buttons() & Qt::LeftButton)) > + return false; > + > + QTouchEvent::TouchPoint touchPoint; > + touchPoint.setState(Qt::TouchPointMoved); > + if ((ev->type() == QEvent::MouseButtonPress > + || ev->type() == QEvent::MouseButtonDblClick)) > + touchPoint.setState(Qt::TouchPointPressed); > + else if (ev->type() == QEvent::MouseButtonRelease) > + touchPoint.setState(Qt::TouchPointReleased); > + > + touchPoint.setId(0); > + touchPoint.setScreenPos(ev->globalPos()); > + touchPoint.setPos(ev->pos()); > + touchPoint.setPressure(1); > + > + // If the point already exists, update it. Otherwise create it. > + if (touchPoints.size()>0 && !touchPoints[0].id()) Coding style: There should be a space before and after the > character > + touchPoints[0] = touchPoint; > + else if (touchPoints.size()>1 && !touchPoints[1].id()) Ditto. > + touchPoints[1] = touchPoint; > + else > + touchPoints.append(touchPoint); > + > + sendTouchEvent(); > + } else if (event->type() == QEvent::KeyPress > + && ((QKeyEvent*)event)->key() == Qt::Key_F > + && ((QKeyEvent*)event)->modifiers() == Qt::ControlModifier) { Please use a static_cast. > + // If the keyboard point is already pressed, release it. > + // Otherwise create it and append to touchPoints. > + if (touchPoints.size()>0 && touchPoints[0].id() == 1) { Coding style: There should be a space before and after the > character > + touchPoints[0].setState(Qt::TouchPointReleased); > + sendTouchEvent(); > + } else if (touchPoints.size()>1 && touchPoints[1].id() == 1) { Ditto. > + touchPoints[1].setState(Qt::TouchPointReleased); > + sendTouchEvent(); > + } else { > + QTouchEvent::TouchPoint touchPoint; > + touchPoint.setState(Qt::TouchPointPressed); > + touchPoint.setId(1); > + touchPoint.setScreenPos(QCursor::pos()); > + touchPoint.setPos(view->mapFromGlobal(QCursor::pos())); I suggest to remember the last mouse point. Just a thought :) > + touchPoint.setPressure(1); > + touchPoints.append(touchPoint); > + sendTouchEvent(); > + > + // After sending the event, change the touchpoint state to stationary > + touchPoints.last().setState(Qt::TouchPointStationary); Shouldn't we disable mocking by default?
Created attachment 45057 [details] Adds multitouch mocking to QtLauncher Updated patch according to Simon's comments except remembering the last mouse point. It would just add lines of code and make it slightly more complicated. I don't see any downsides in using QCursor::pos() to get the mouse position. It's simple and works :) However, I will change that as well if demanded?
style-queue ran check-webkit-style on attachment 45057 [details] without any errors.
Comment on attachment 45057 [details] Adds multitouch mocking to QtLauncher r=me
Comment on attachment 45057 [details] Adds multitouch mocking to QtLauncher Clearing flags on attachment: 45057 Committed r52250: <http://trac.webkit.org/changeset/52250>
All reviewed patches have been landed. Closing bug.
Created attachment 45071 [details] The event delivery should go through the normal path
style-queue ran check-webkit-style on attachment 45071 [details] without any errors.
Reopening. The event should go through the normal path. We need to simulate touch events are if they were sent by the system (with filtering in some cases). I'd prefer to see something like this in Qt. This feature could be useful in many more cases.
Comment on attachment 45071 [details] The event delivery should go through the normal path Clearing flags on attachment: 45071 Committed r52257: <http://trac.webkit.org/changeset/52257>