QGuiApplicationPrivate *QGuiApplicationPrivate::self = 0;
QTouchDevice *QGuiApplicationPrivate::m_fakeTouchDevice = 0;
+int QGuiApplicationPrivate::m_fakeMouseSourcePointId = 0;
#ifndef QT_NO_CLIPBOARD
QClipboard *QGuiApplicationPrivate::qt_clipboard = 0;
if (touchEvent.device()->type() != QTouchDevice::TouchPad) {
Qt::MouseButtons b = eventType == QEvent::TouchEnd ? Qt::NoButton : Qt::LeftButton;
- const QTouchEvent::TouchPoint &touchPoint = touchEvent.touchPoints().first();
-
- QWindowSystemInterfacePrivate::MouseEvent fake(w, e->timestamp, touchPoint.pos(), touchPoint.screenPos(), b, e->modifiers);
- fake.synthetic = true;
- processMouseEvent(&fake);
+ QList<QTouchEvent::TouchPoint> touchPoints = touchEvent.touchPoints();
+ if (eventType == QEvent::TouchBegin)
+ m_fakeMouseSourcePointId = touchPoints.first().id();
+
+ for (int i = 0; i < touchPoints.count(); ++i) {
+ const QTouchEvent::TouchPoint &touchPoint = touchPoints.at(i);
+ if (touchPoint.id() == m_fakeMouseSourcePointId) {
+ QWindowSystemInterfacePrivate::MouseEvent fake(w, e->timestamp,
+ touchPoint.pos(),
+ touchPoint.screenPos(),
+ b, e->modifiers);
+ fake.synthetic = true;
+ processMouseEvent(&fake);
+ break;
+ }
+ }
}
}
}
keyReleaseCode = event->key();
}
void mousePressEvent(QMouseEvent *event) {
- if (ignoreMouse)
+ if (ignoreMouse) {
event->ignore();
- else
+ } else {
mousePressButton = event->button();
+ mousePressScreenPos = event->screenPos();
+ }
}
void mouseReleaseEvent(QMouseEvent *event) {
if (ignoreMouse)
else
mouseReleaseButton = event->button();
}
+ void mouseMoveEvent(QMouseEvent *event) {
+ if (ignoreMouse) {
+ event->ignore();
+ } else {
+ mouseMoveButton = event->button();
+ mouseMoveScreenPos = event->screenPos();
+ }
+ }
void touchEvent(QTouchEvent *event) {
if (ignoreTouch) {
event->ignore();
}
int keyPressCode, keyReleaseCode;
- int mousePressButton, mouseReleaseButton;
+ int mousePressButton, mouseReleaseButton, mouseMoveButton;
+ QPointF mousePressScreenPos, mouseMoveScreenPos;
int touchPressedCount, touchReleasedCount;
bool ignoreMouse, ignoreTouch;
QList<QWindowSystemInterface::TouchPoint> points;
QWindowSystemInterface::TouchPoint tp1, tp2;
+ const QRectF pressArea(101, 102, 4, 4);
+ const QRectF moveArea(105, 108, 4, 4);
tp1.id = 1;
tp1.state = Qt::TouchPointPressed;
+ tp1.area = pressArea;
tp2.id = 2;
tp2.state = Qt::TouchPointPressed;
points << tp1 << tp2;
QWindowSystemInterface::handleTouchEvent(&window, touchDevice, points);
+ // Now an update but with changed list order. The mouse event should still
+ // be generated from the point with id 1.
+ tp1.id = 2;
+ tp1.state = Qt::TouchPointStationary;
+ tp2.id = 1;
+ tp2.state = Qt::TouchPointMoved;
+ tp2.area = moveArea;
+ points.clear();
+ points << tp1 << tp2;
+ QWindowSystemInterface::handleTouchEvent(&window, touchDevice, points);
points[0].state = Qt::TouchPointReleased;
points[1].state = Qt::TouchPointReleased;
QWindowSystemInterface::handleTouchEvent(&window, touchDevice, points);
QTRY_COMPARE(window.mousePressButton, int(Qt::LeftButton));
QTRY_COMPARE(window.mouseReleaseButton, int(Qt::LeftButton));
+ QTRY_COMPARE(window.mousePressScreenPos, pressArea.center());
+ QTRY_COMPARE(window.mouseMoveScreenPos, moveArea.center());
window.mousePressButton = 0;
window.mouseReleaseButton = 0;