Remove event type parameter from handleTouchEvent.
Requiring platform and generic plug-ins to pass TouchBegin, TouchUpdate, or TouchEnd is unnecessary. The type can be easily deduced from the touch point states. In fact handleTouchEvent already collected the combined point states, it was just not utilized until now. Change-Id: Icf3c787fefdebc51609a763bc4286c18a0b6aac2 Reviewed-by: Lars Knoll <lars.knoll@nokia.com>bb10
parent
b986131c6d
commit
5da5230ab2
|
|
@ -219,16 +219,15 @@ void QWindowSystemInterface::registerTouchDevice(QTouchDevice *device)
|
|||
QTouchDevicePrivate::registerDevice(device);
|
||||
}
|
||||
|
||||
void QWindowSystemInterface::handleTouchEvent(QWindow *w, QEvent::Type type, QTouchDevice *device,
|
||||
const QList<struct TouchPoint> &points, Qt::KeyboardModifiers mods)
|
||||
void QWindowSystemInterface::handleTouchEvent(QWindow *w, QTouchDevice *device,
|
||||
const QList<TouchPoint> &points, Qt::KeyboardModifiers mods)
|
||||
{
|
||||
unsigned long time = QWindowSystemInterfacePrivate::eventTime.elapsed();
|
||||
handleTouchEvent(w, time, type, device, points, mods);
|
||||
handleTouchEvent(w, time, device, points, mods);
|
||||
}
|
||||
|
||||
void QWindowSystemInterface::handleTouchEvent(QWindow *tlw, ulong timestamp, QEvent::Type type,
|
||||
QTouchDevice *device,
|
||||
const QList<struct TouchPoint> &points, Qt::KeyboardModifiers mods)
|
||||
void QWindowSystemInterface::handleTouchEvent(QWindow *tlw, ulong timestamp, QTouchDevice *device,
|
||||
const QList<TouchPoint> &points, Qt::KeyboardModifiers mods)
|
||||
{
|
||||
if (!points.size()) // Touch events must have at least one point
|
||||
return;
|
||||
|
|
@ -268,6 +267,13 @@ void QWindowSystemInterface::handleTouchEvent(QWindow *tlw, ulong timestamp, QEv
|
|||
++point;
|
||||
}
|
||||
|
||||
// Determine the event type based on the combined point states.
|
||||
QEvent::Type type = QEvent::TouchUpdate;
|
||||
if (states == Qt::TouchPointPressed)
|
||||
type = QEvent::TouchBegin;
|
||||
else if (states == Qt::TouchPointReleased)
|
||||
type = QEvent::TouchEnd;
|
||||
|
||||
QWindowSystemInterfacePrivate::TouchEvent *e =
|
||||
new QWindowSystemInterfacePrivate::TouchEvent(tlw, timestamp, type, device, touchPoints, mods);
|
||||
QWindowSystemInterfacePrivate::queueWindowSystemEvent(e);
|
||||
|
|
|
|||
|
|
@ -99,9 +99,9 @@ public:
|
|||
};
|
||||
|
||||
static void registerTouchDevice(QTouchDevice *device);
|
||||
static void handleTouchEvent(QWindow *w, QEvent::Type type, QTouchDevice *device,
|
||||
static void handleTouchEvent(QWindow *w, QTouchDevice *device,
|
||||
const QList<struct TouchPoint> &points, Qt::KeyboardModifiers mods = Qt::NoModifier);
|
||||
static void handleTouchEvent(QWindow *w, ulong timestamp, QEvent::Type type, QTouchDevice *device,
|
||||
static void handleTouchEvent(QWindow *w, ulong timestamp, QTouchDevice *device,
|
||||
const QList<struct TouchPoint> &points, Qt::KeyboardModifiers mods = Qt::NoModifier);
|
||||
|
||||
static void handleGeometryChange(QWindow *w, const QRect &newRect);
|
||||
|
|
|
|||
|
|
@ -66,8 +66,7 @@ void QTouchEventSenderQPA::touch_configure(int x_min, int x_max, int y_min, int
|
|||
hw_range_y_max = y_max;
|
||||
}
|
||||
|
||||
void QTouchEventSenderQPA::touch_point(QEvent::Type state,
|
||||
const QList<QWindowSystemInterface::TouchPoint> &points)
|
||||
void QTouchEventSenderQPA::touch_point(const QList<QWindowSystemInterface::TouchPoint> &points)
|
||||
{
|
||||
QRect winRect;
|
||||
if (m_forceToActiveWindow) {
|
||||
|
|
@ -107,7 +106,7 @@ void QTouchEventSenderQPA::touch_point(QEvent::Type state,
|
|||
#endif
|
||||
}
|
||||
|
||||
QWindowSystemInterface::handleTouchEvent(0, state, m_device, touchPoints);
|
||||
QWindowSystemInterface::handleTouchEvent(0, m_device, touchPoints);
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ class QTouchEventSenderQPA : public QTouchScreenObserver
|
|||
public:
|
||||
QTouchEventSenderQPA(const QString &spec = QString());
|
||||
void touch_configure(int x_min, int x_max, int y_min, int y_max);
|
||||
void touch_point(QEvent::Type state, const QList<QWindowSystemInterface::TouchPoint> &points);
|
||||
void touch_point(const QList<QWindowSystemInterface::TouchPoint> &points);
|
||||
|
||||
private:
|
||||
bool m_forceToActiveWindow;
|
||||
|
|
|
|||
|
|
@ -291,7 +291,7 @@ void QTouchScreenData::processInputEvent(input_event *data)
|
|||
|
||||
if (!skip && !(m_state == m_prevState && m_state == QEvent::TouchEnd))
|
||||
for (int i = 0; i < m_observers.count(); ++i)
|
||||
m_observers.at(i)->touch_point(m_state, m_touchPoints);
|
||||
m_observers.at(i)->touch_point(m_touchPoints);
|
||||
|
||||
m_prevState = m_state;
|
||||
if (m_state == QEvent::TouchBegin)
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ class QTouchScreenObserver
|
|||
{
|
||||
public:
|
||||
virtual void touch_configure(int x_min, int x_max, int y_min, int y_max) = 0;
|
||||
virtual void touch_point(QEvent::Type state, const QList<QWindowSystemInterface::TouchPoint> &points) = 0;
|
||||
virtual void touch_point(const QList<QWindowSystemInterface::TouchPoint> &points) = 0;
|
||||
};
|
||||
|
||||
class QTouchScreenHandler : public QObject
|
||||
|
|
|
|||
|
|
@ -295,28 +295,28 @@ static QTouchDevice *touchDevice = 0;
|
|||
{
|
||||
const NSTimeInterval timestamp = [event timestamp];
|
||||
const QList<QWindowSystemInterface::TouchPoint> points = QCocoaTouch::getCurrentTouchPointList(event, /*acceptSingleTouch= ### true or false?*/false);
|
||||
QWindowSystemInterface::handleTouchEvent(m_window, timestamp * 1000, QEvent::TouchBegin, touchDevice, points);
|
||||
QWindowSystemInterface::handleTouchEvent(m_window, timestamp * 1000, touchDevice, points);
|
||||
}
|
||||
|
||||
- (void)touchesMovedWithEvent:(NSEvent *)event
|
||||
{
|
||||
const NSTimeInterval timestamp = [event timestamp];
|
||||
const QList<QWindowSystemInterface::TouchPoint> points = QCocoaTouch::getCurrentTouchPointList(event, /*acceptSingleTouch= ### true or false?*/false);
|
||||
QWindowSystemInterface::handleTouchEvent(m_window, timestamp * 1000, QEvent::TouchUpdate, touchDevice, points);
|
||||
QWindowSystemInterface::handleTouchEvent(m_window, timestamp * 1000, touchDevice, points);
|
||||
}
|
||||
|
||||
- (void)touchesEndedWithEvent:(NSEvent *)event
|
||||
{
|
||||
const NSTimeInterval timestamp = [event timestamp];
|
||||
const QList<QWindowSystemInterface::TouchPoint> points = QCocoaTouch::getCurrentTouchPointList(event, /*acceptSingleTouch= ### true or false?*/false);
|
||||
QWindowSystemInterface::handleTouchEvent(m_window, timestamp * 1000, QEvent::TouchEnd, touchDevice, points);
|
||||
QWindowSystemInterface::handleTouchEvent(m_window, timestamp * 1000, touchDevice, points);
|
||||
}
|
||||
|
||||
- (void)touchesCancelledWithEvent:(NSEvent *)event
|
||||
{
|
||||
const NSTimeInterval timestamp = [event timestamp];
|
||||
const QList<QWindowSystemInterface::TouchPoint> points = QCocoaTouch::getCurrentTouchPointList(event, /*acceptSingleTouch= ### true or false?*/false);
|
||||
QWindowSystemInterface::handleTouchEvent(m_window, timestamp * 1000, QEvent::TouchEnd, touchDevice, points);
|
||||
QWindowSystemInterface::handleTouchEvent(m_window, timestamp * 1000, touchDevice, points);
|
||||
}
|
||||
|
||||
#ifndef QT_NO_WHEELEVENT
|
||||
|
|
|
|||
|
|
@ -280,14 +280,13 @@ bool QWindowsMouseHandler::translateTouchEvent(QWindow *window, HWND,
|
|||
|
||||
if (!m_touchDevice) {
|
||||
m_touchDevice = new QTouchDevice;
|
||||
// TODO: Device used to be hardcoded to screen in previous code.
|
||||
m_touchDevice->setType(QTouchDevice::TouchScreen);
|
||||
m_touchDevice->setCapabilities(QTouchDevice::Position | QTouchDevice::Area | QTouchDevice::NormalizedPosition);
|
||||
QWindowSystemInterface::registerTouchDevice(m_touchDevice);
|
||||
}
|
||||
|
||||
// TODO: Device used to be hardcoded to screen in previous code.
|
||||
// What is the correct event type? Which parts of translateRawTouchEvent() are required?
|
||||
QWindowSystemInterface::handleTouchEvent(window, QEvent::TouchBegin,
|
||||
QWindowSystemInterface::handleTouchEvent(window,
|
||||
m_touchDevice,
|
||||
touchPoints);
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -288,7 +288,7 @@ void QXcbConnection::handleGenericEvent(xcb_ge_event_t *event)
|
|||
QWindowSystemInterface::registerTouchDevice(dev);
|
||||
m_xinputData->qtTouchDevice = dev;
|
||||
}
|
||||
QWindowSystemInterface::handleTouchEvent(platformWindow->window(), xideviceevent->time, (QEvent::Type)0 /*None*/, dev, touchPoints);
|
||||
QWindowSystemInterface::handleTouchEvent(platformWindow->window(), xideviceevent->time, dev, touchPoints);
|
||||
}
|
||||
|
||||
if (xideviceevent->evtype == XI_ButtonRelease) {
|
||||
|
|
|
|||
|
|
@ -136,7 +136,7 @@ namespace QTest
|
|||
if (!points.isEmpty()) {
|
||||
if (targetWindow)
|
||||
{
|
||||
QWindowSystemInterface::handleTouchEvent(targetWindow,QEvent::None, device, touchPointList(points.values()));
|
||||
QWindowSystemInterface::handleTouchEvent(targetWindow, device, touchPointList(points.values()));
|
||||
QTest::qWait(10);
|
||||
}
|
||||
#ifdef QT_WIDGETS_LIB
|
||||
|
|
|
|||
Loading…
Reference in New Issue