diff options
author | Michael Dippold <michael.dippold@us.thalesgroup.com> | 2018-03-05 12:24:53 -0800 |
---|---|---|
committer | Michael Dippold <michael.dippold@us.thalesgroup.com> | 2018-07-13 17:20:34 +0000 |
commit | c80611a4591882910fd1277410c0de127d46d3b2 (patch) | |
tree | 0a8a41038cd4283c48145c673eb183e732039da7 | |
parent | 019dd88d2cf63ff065bfd801876b213e8193c60f (diff) |
Android: Support mouse hover
Android supports hover events through the generic motion event. Routed
mouse events to specific mouse handler.
Task-number: QTBUG-42799
Change-Id: Iee17c71c09d84f52235e66ec08c65ffa30ec9cd9
Reviewed-by: BogDan Vatra <bogdan@kdab.com>
-rw-r--r-- | src/android/jar/src/org/qtproject/qt5/android/QtNative.java | 51 | ||||
-rw-r--r-- | src/plugins/platforms/android/androidjniinput.cpp | 3 |
2 files changed, 34 insertions, 20 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 6b54ae45e7..61f6afe85d 100644 --- a/src/android/jar/src/org/qtproject/qt5/android/QtNative.java +++ b/src/android/jar/src/org/qtproject/qt5/android/QtNative.java @@ -469,10 +469,11 @@ public class QtNative case MotionEvent.TOOL_TYPE_ERASER: pointerType = 3; // QTabletEvent::Eraser break; - // TODO TOOL_TYPE_MOUSE } - if (m_tabletEventSupported && pointerType != 0) { + if (event.getToolType(0) == MotionEvent.TOOL_TYPE_MOUSE) { + sendMouseEvent(event, id); + } else if (m_tabletEventSupported && pointerType != 0) { tabletEvent(id, event.getDeviceId(), event.getEventTime(), event.getAction(), pointerType, event.getButtonState(), event.getX(), event.getY(), event.getPressure()); } else { @@ -507,7 +508,22 @@ public class QtNative static public void sendTrackballEvent(MotionEvent event, int id) { - switch (event.getAction()) { + sendMouseEvent(event,id); + } + + static public boolean sendGenericMotionEvent(MotionEvent event, int id) + { + if (((event.getAction() & (MotionEvent.ACTION_SCROLL | MotionEvent.ACTION_HOVER_MOVE)) == 0) + || (event.getSource() & InputDevice.SOURCE_CLASS_POINTER) != InputDevice.SOURCE_CLASS_POINTER) { + return false; + } + + return sendMouseEvent(event, id); + } + + static public boolean sendMouseEvent(MotionEvent event, int id) + { + switch (event.getActionMasked()) { case MotionEvent.ACTION_UP: mouseUp(id, (int) event.getX(), (int) event.getY()); break; @@ -517,28 +533,27 @@ public class QtNative m_oldx = (int) event.getX(); m_oldy = (int) event.getY(); break; - + case MotionEvent.ACTION_HOVER_MOVE: case MotionEvent.ACTION_MOVE: - int dx = (int) (event.getX() - m_oldx); - int dy = (int) (event.getY() - m_oldy); - if (Math.abs(dx) > 5 || Math.abs(dy) > 5) { + if (event.getToolType(0) == MotionEvent.TOOL_TYPE_MOUSE) { + mouseMove(id, (int) event.getX(), (int) event.getY()); + } else { + int dx = (int) (event.getX() - m_oldx); + int dy = (int) (event.getY() - m_oldy); + if (Math.abs(dx) > 5 || Math.abs(dy) > 5) { mouseMove(id, (int) event.getX(), (int) event.getY()); m_oldx = (int) event.getX(); m_oldy = (int) event.getY(); + } } break; + case MotionEvent.ACTION_SCROLL: + mouseWheel(id, (int) event.getX(), (int) event.getY(), + event.getAxisValue(MotionEvent.AXIS_HSCROLL), event.getAxisValue(MotionEvent.AXIS_VSCROLL)); + break; + default: + return false; } - } - - static public boolean sendGenericMotionEvent(MotionEvent event, int id) - { - if (event.getActionMasked() != MotionEvent.ACTION_SCROLL - || (event.getSource() & InputDevice.SOURCE_CLASS_POINTER) != InputDevice.SOURCE_CLASS_POINTER) { - return false; - } - - mouseWheel(id, (int) event.getX(), (int) event.getY(), - event.getAxisValue(MotionEvent.AXIS_HSCROLL), event.getAxisValue(MotionEvent.AXIS_VSCROLL)); return true; } diff --git a/src/plugins/platforms/android/androidjniinput.cpp b/src/plugins/platforms/android/androidjniinput.cpp index b36222502d..9cdc5de0e1 100644 --- a/src/plugins/platforms/android/androidjniinput.cpp +++ b/src/plugins/platforms/android/androidjniinput.cpp @@ -58,7 +58,6 @@ using namespace QtAndroid; namespace QtAndroidInput { - static bool m_ignoreMouseEvents = false; static bool m_softwareKeyboardVisible = false; static QRect m_softwareKeyboardRect; @@ -174,7 +173,7 @@ namespace QtAndroidInput QWindowSystemInterface::handleMouseEvent(tlw, localPos, globalPos, - Qt::MouseButtons(Qt::LeftButton)); + Qt::MouseButtons(m_mouseGrabber ? Qt::LeftButton : Qt::NoButton)); } static void mouseWheel(JNIEnv */*env*/, jobject /*thiz*/, jint /*winId*/, jint x, jint y, jfloat hdelta, jfloat vdelta) |