From 5da5230ab29743b63bf238a379891c98ac9d5038 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Wed, 30 Nov 2011 15:48:54 +0200 Subject: 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 --- src/plugins/generic/touchscreen/qtoucheventsenderqpa.cpp | 5 ++--- src/plugins/generic/touchscreen/qtoucheventsenderqpa.h | 2 +- src/plugins/generic/touchscreen/qtouchscreen.cpp | 2 +- src/plugins/generic/touchscreen/qtouchscreen.h | 2 +- src/plugins/platforms/cocoa/qnsview.mm | 8 ++++---- src/plugins/platforms/windows/qwindowsmousehandler.cpp | 5 ++--- src/plugins/platforms/xcb/qxcbconnection_maemo.cpp | 2 +- 7 files changed, 12 insertions(+), 14 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/generic/touchscreen/qtoucheventsenderqpa.cpp b/src/plugins/generic/touchscreen/qtoucheventsenderqpa.cpp index 08db058e10..f8dc84373d 100644 --- a/src/plugins/generic/touchscreen/qtoucheventsenderqpa.cpp +++ b/src/plugins/generic/touchscreen/qtoucheventsenderqpa.cpp @@ -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 &points) +void QTouchEventSenderQPA::touch_point(const QList &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 diff --git a/src/plugins/generic/touchscreen/qtoucheventsenderqpa.h b/src/plugins/generic/touchscreen/qtoucheventsenderqpa.h index b6e1613b24..f0e923b3a0 100644 --- a/src/plugins/generic/touchscreen/qtoucheventsenderqpa.h +++ b/src/plugins/generic/touchscreen/qtoucheventsenderqpa.h @@ -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 &points); + void touch_point(const QList &points); private: bool m_forceToActiveWindow; diff --git a/src/plugins/generic/touchscreen/qtouchscreen.cpp b/src/plugins/generic/touchscreen/qtouchscreen.cpp index fd2de62d6b..fd73bffd4f 100644 --- a/src/plugins/generic/touchscreen/qtouchscreen.cpp +++ b/src/plugins/generic/touchscreen/qtouchscreen.cpp @@ -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) diff --git a/src/plugins/generic/touchscreen/qtouchscreen.h b/src/plugins/generic/touchscreen/qtouchscreen.h index 3c35b0012f..6127cdba32 100644 --- a/src/plugins/generic/touchscreen/qtouchscreen.h +++ b/src/plugins/generic/touchscreen/qtouchscreen.h @@ -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 &points) = 0; + virtual void touch_point(const QList &points) = 0; }; class QTouchScreenHandler : public QObject diff --git a/src/plugins/platforms/cocoa/qnsview.mm b/src/plugins/platforms/cocoa/qnsview.mm index 4ae268dda5..a0a5a2e5cf 100644 --- a/src/plugins/platforms/cocoa/qnsview.mm +++ b/src/plugins/platforms/cocoa/qnsview.mm @@ -295,28 +295,28 @@ static QTouchDevice *touchDevice = 0; { const NSTimeInterval timestamp = [event timestamp]; const QList 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 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 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 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 diff --git a/src/plugins/platforms/windows/qwindowsmousehandler.cpp b/src/plugins/platforms/windows/qwindowsmousehandler.cpp index a2b6aa8d68..608230e6e0 100644 --- a/src/plugins/platforms/windows/qwindowsmousehandler.cpp +++ b/src/plugins/platforms/windows/qwindowsmousehandler.cpp @@ -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; diff --git a/src/plugins/platforms/xcb/qxcbconnection_maemo.cpp b/src/plugins/platforms/xcb/qxcbconnection_maemo.cpp index 719fc85ae2..23421e59d2 100644 --- a/src/plugins/platforms/xcb/qxcbconnection_maemo.cpp +++ b/src/plugins/platforms/xcb/qxcbconnection_maemo.cpp @@ -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) { -- cgit v1.2.3