summaryrefslogtreecommitdiffstats
path: root/src/android
diff options
context:
space:
mode:
authorMichael Dippold <michael.dippold@us.thalesgroup.com>2018-03-05 12:24:53 -0800
committerMichael Dippold <michael.dippold@us.thalesgroup.com>2018-07-13 17:20:34 +0000
commitc80611a4591882910fd1277410c0de127d46d3b2 (patch)
tree0a8a41038cd4283c48145c673eb183e732039da7 /src/android
parent019dd88d2cf63ff065bfd801876b213e8193c60f (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>
Diffstat (limited to 'src/android')
-rw-r--r--src/android/jar/src/org/qtproject/qt5/android/QtNative.java51
1 files changed, 33 insertions, 18 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;
}