[Webkit-unassigned] [Bug 32434] [Qt] Add support for mocking touch events with Q(GV)Launcher
bugzilla-daemon at webkit.org
bugzilla-daemon at webkit.org
Wed Dec 16 03:27:23 PST 2009
https://bugs.webkit.org/show_bug.cgi?id=32434
Simon Hausmann <hausmann at webkit.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Attachment #44954|review? |review-
Flag| |
--- Comment #4 from Simon Hausmann <hausmann at webkit.org> 2009-12-16 03:27:23 PST ---
(From update of attachment 44954)
> +#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?
--
Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
More information about the webkit-unassigned
mailing list