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>
This commit is contained in:
Vyacheslav Koscheev 2016-06-02 16:23:29 +06:00 committed by Vyacheslav Koscheev
parent 5c2d30c19e
commit 797cd4b7bc
2 changed files with 18 additions and 1 deletions

View File

@ -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

View File

@ -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},