summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@digia.com>2013-03-06 11:54:08 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-03-12 09:16:42 +0100
commit638d9d3831357f80800a2fae4925f71648907f30 (patch)
tree7eb12b5a1c657cac51a167468cc2c0dc1112add0
parent5f25dc6be7e6a8f185d37884611123f7d3af7615 (diff)
Fix multi-touch input on Android
The touch events were collected but then thrown away because of a missing port of he handleTouchEvent() function call. Task-number: QTBUG-29126 Change-Id: I02f7380945be04a36da14a89f2f3ff9429b17cbc Reviewed-by: Samuel Rødal <samuel.rodal@digia.com>
-rw-r--r--src/plugins/platforms/android/src/androidjniinput.cpp21
-rw-r--r--src/plugins/platforms/android/src/androidjnimain.cpp6
-rw-r--r--src/plugins/platforms/android/src/androidjnimain.h1
-rw-r--r--src/plugins/platforms/android/src/qandroidplatformintegration.cpp4
-rw-r--r--src/plugins/platforms/android/src/qandroidplatformintegration.h6
5 files changed, 35 insertions, 3 deletions
diff --git a/src/plugins/platforms/android/src/androidjniinput.cpp b/src/plugins/platforms/android/src/androidjniinput.cpp
index 6a3dd1f349..da6156a330 100644
--- a/src/plugins/platforms/android/src/androidjniinput.cpp
+++ b/src/plugins/platforms/android/src/androidjniinput.cpp
@@ -41,6 +41,7 @@
#include "androidjniinput.h"
#include "androidjnimain.h"
+#include "qandroidplatformintegration.h"
#include <qpa/qwindowsysteminterface.h>
#include <QTouchEvent>
@@ -219,6 +220,9 @@ namespace QtAndroidInput
static void touchEnd(JNIEnv */*env*/, jobject /*thiz*/, jint /*winId*/, jint action)
{
+ if (m_touchPoints.isEmpty())
+ return;
+
QEvent::Type eventType = QEvent::None;
switch (action) {
case 0:
@@ -232,8 +236,21 @@ namespace QtAndroidInput
break;
}
- // FIXME
- // QWindowSystemInterface::handleTouchEvent(0, 0, eventType, QTouchEvent::TouchScreen, m_touchPoints);
+ QAndroidPlatformIntegration *platformIntegration = QtAndroid::androidPlatformIntegration();
+ QTouchDevice *touchDevice = platformIntegration->touchDevice();
+ if (touchDevice == 0) {
+ touchDevice = new QTouchDevice;
+ touchDevice->setType(QTouchDevice::TouchScreen);
+ touchDevice->setCapabilities(QTouchDevice::Position
+ | QTouchDevice::Area
+ | QTouchDevice::Pressure
+ | QTouchDevice::NormalizedPosition);
+ QWindowSystemInterface::registerTouchDevice(touchDevice);
+ platformIntegration->setTouchDevice(touchDevice);
+ }
+
+ QWindow *window = QtAndroid::topLevelWindowAt(m_touchPoints.at(0).area.center().toPoint());
+ QWindowSystemInterface::handleTouchEvent(window, touchDevice, m_touchPoints);
}
static int mapAndroidKey(int key)
diff --git a/src/plugins/platforms/android/src/androidjnimain.cpp b/src/plugins/platforms/android/src/androidjnimain.cpp
index 2a4c48df3c..f8f077908c 100644
--- a/src/plugins/platforms/android/src/androidjnimain.cpp
+++ b/src/plugins/platforms/android/src/androidjnimain.cpp
@@ -266,6 +266,12 @@ namespace QtAndroid
m_surfaceMutex.unlock();
}
+ QAndroidPlatformIntegration *androidPlatformIntegration()
+ {
+ QMutexLocker locker(&m_surfaceMutex);
+ return m_androidPlatformIntegration;
+ }
+
void setFullScreen(QWidget *widget)
{
AttachedJNIEnv env;
diff --git a/src/plugins/platforms/android/src/androidjnimain.h b/src/plugins/platforms/android/src/androidjnimain.h
index 36699f15b8..618bd87cdb 100644
--- a/src/plugins/platforms/android/src/androidjnimain.h
+++ b/src/plugins/platforms/android/src/androidjnimain.h
@@ -65,6 +65,7 @@ class QWindow;
namespace QtAndroid
{
+ QAndroidPlatformIntegration *androidPlatformIntegration();
void setAndroidPlatformIntegration(QAndroidPlatformIntegration *androidPlatformIntegration);
void setQtThread(QThread *thread);
diff --git a/src/plugins/platforms/android/src/qandroidplatformintegration.cpp b/src/plugins/platforms/android/src/qandroidplatformintegration.cpp
index 1091416ccc..cbd0f26835 100644
--- a/src/plugins/platforms/android/src/qandroidplatformintegration.cpp
+++ b/src/plugins/platforms/android/src/qandroidplatformintegration.cpp
@@ -84,8 +84,9 @@ void *QAndroidPlatformNativeInterface::nativeResourceForIntegration(const QByteA
}
QAndroidPlatformIntegration::QAndroidPlatformIntegration(const QStringList &paramList)
+ : m_touchDevice(0)
#ifdef ANDROID_PLUGIN_OPENGL
- : m_primaryWindow(0)
+ , m_primaryWindow(0)
#endif
{
Q_UNUSED(paramList);
@@ -179,6 +180,7 @@ QAndroidPlatformIntegration::~QAndroidPlatformIntegration()
{
delete m_androidPlatformNativeInterface;
delete m_androidFDB;
+ delete m_touchDevice;
QtAndroid::setAndroidPlatformIntegration(NULL);
}
QPlatformFontDatabase *QAndroidPlatformIntegration::fontDatabase() const
diff --git a/src/plugins/platforms/android/src/qandroidplatformintegration.h b/src/plugins/platforms/android/src/qandroidplatformintegration.h
index 7dde277d25..3f8cc5a809 100644
--- a/src/plugins/platforms/android/src/qandroidplatformintegration.h
+++ b/src/plugins/platforms/android/src/qandroidplatformintegration.h
@@ -126,9 +126,15 @@ public:
return QSize(m_defaultGeometryWidth, m_defaultGeometryHeight);
}
+ QTouchDevice *touchDevice() const { return m_touchDevice; }
+ void setTouchDevice(QTouchDevice *touchDevice) { m_touchDevice = touchDevice; }
+
private:
friend class QEglFSAndroidHooks;
+
+ QTouchDevice *m_touchDevice;
+
#ifndef ANDROID_PLUGIN_OPENGL
QAbstractEventDispatcher *m_eventDispatcher;
QAndroidPlatformScreen *m_primaryScreen;