diff options
author | Vyacheslav Koscheev <v.koscheev@2gis.ru> | 2016-06-02 16:23:29 +0600 |
---|---|---|
committer | Vyacheslav Koscheev <vok1980@gmail.com> | 2016-06-16 14:08:27 +0000 |
commit | 797cd4b7bc8e9864c2d569c110b61e49e15c80c2 (patch) | |
tree | 94ada570742dc9d27784350555e9044905753966 /src | |
parent | 5c2d30c19ee100705a52eaa693bd835069e2b80f (diff) |
Android: Don't send tabletEvent when it's not supported
If QT_NO_TABLETEVENT defined, then there is no sense to create tablet
events.
Its better to create general touch events in this case.
Task-number: QTBUG-53887
Change-Id: I2fabc2241158d54d6c39a2f6071ab874f7debd39
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Diffstat (limited to 'src')
-rw-r--r-- | src/android/jar/src/org/qtproject/qt5/android/QtNative.java | 7 | ||||
-rw-r--r-- | src/plugins/platforms/android/androidjniinput.cpp | 12 |
2 files changed, 18 insertions, 1 deletions
diff --git a/src/android/jar/src/org/qtproject/qt5/android/QtNative.java b/src/android/jar/src/org/qtproject/qt5/android/QtNative.java index 14da281a76..e602a6deba 100644 --- a/src/android/jar/src/org/qtproject/qt5/android/QtNative.java +++ b/src/android/jar/src/org/qtproject/qt5/android/QtNative.java @@ -84,6 +84,7 @@ public class QtNative private static final int m_moveThreshold = 0; private static ClipboardManager m_clipboardManager = null; private static Method m_checkSelfPermissionMethod = null; + private static Boolean m_tabletEventSupported = null; private static ClassLoader m_classLoader = null; public static ClassLoader classLoader() @@ -343,6 +344,9 @@ public class QtNative { int pointerType = 0; + if (m_tabletEventSupported == null) + m_tabletEventSupported = isTabletEventSupported(); + if (Build.VERSION.SDK_INT >= 14) { switch (event.getToolType(0)) { case MotionEvent.TOOL_TYPE_STYLUS: @@ -355,7 +359,7 @@ public class QtNative } } - if (pointerType != 0) { + if (m_tabletEventSupported && pointerType != 0) { tabletEvent(id, event.getDeviceId(), event.getEventTime(), event.getAction(), pointerType, event.getButtonState(), event.getX(), event.getY(), event.getPressure()); } else { @@ -685,6 +689,7 @@ public class QtNative // pointer methods // tablet methods + public static native boolean isTabletEventSupported(); public static native void tabletEvent(int winId, int deviceId, long time, int action, int pointerType, int buttonState, float x, float y, float pressure); // tablet methods diff --git a/src/plugins/platforms/android/androidjniinput.cpp b/src/plugins/platforms/android/androidjniinput.cpp index 9cc5e95378..1687f9b48a 100644 --- a/src/plugins/platforms/android/androidjniinput.cpp +++ b/src/plugins/platforms/android/androidjniinput.cpp @@ -246,9 +246,19 @@ namespace QtAndroidInput QWindowSystemInterface::handleTouchEvent(window, touchDevice, m_touchPoints); } + static bool isTabletEventSupported(JNIEnv */*env*/, jobject /*thiz*/) + { +#ifdef QT_NO_TABLETEVENT + return false; +#else + return true; +#endif // QT_NO_TABLETEVENT + } + static void tabletEvent(JNIEnv */*env*/, jobject /*thiz*/, jint /*winId*/, jint deviceId, jlong time, jint action, jint pointerType, jint buttonState, jfloat x, jfloat y, jfloat pressure) { +#ifndef QT_NO_TABLETEVENT QPointF globalPosF(x, y); QPoint globalPos((int)x, (int)y); QWindow *tlw = topLevelWindowAt(globalPos); @@ -290,6 +300,7 @@ namespace QtAndroidInput QWindowSystemInterface::handleTabletEvent(tlw, ulong(time), localPos, globalPosF, QTabletEvent::Stylus, pointerType, buttons, pressure, 0, 0, 0., 0., 0, deviceId, Qt::NoModifier); +#endif // QT_NO_TABLETEVENT } static int mapAndroidKey(int key) @@ -777,6 +788,7 @@ namespace QtAndroidInput {"mouseUp", "(III)V", (void *)mouseUp}, {"mouseMove", "(III)V", (void *)mouseMove}, {"longPress", "(III)V", (void *)longPress}, + {"isTabletEventSupported", "()Z", (void *)isTabletEventSupported}, {"tabletEvent", "(IIJIIIFFF)V", (void *)tabletEvent}, {"keyDown", "(IIIZ)V", (void *)keyDown}, {"keyUp", "(IIIZ)V", (void *)keyUp}, |