summaryrefslogtreecommitdiffstats
path: root/src/android
diff options
context:
space:
mode:
authorAxel Spoerl <axel.spoerl@qt.io>2024-04-15 10:42:00 +0200
committerAxel Spoerl <axel.spoerl@qt.io>2024-04-22 23:28:36 +0200
commit8d8cbe87e21f05b7d611ed4be47299977288b267 (patch)
treeb52ebc18fd635e461263d55b3c900aa338946e86 /src/android
parent038c199d59ff5e9e16fe2a010f3f1f55764cf5ba (diff)
Android: Detect mouse buttons
The mouseDown() and mouseUp() methods in androidjniinput.cpp hardcoded Qt::LeftButton to all mouse-press / release events. If a mouse is connected to an android device, all three buttons are mapped to the left button. Extend both mehtods' signature by a mouse button state. Add a converter method to map from Android button states to Qt::MouseButtons. Add a sendMouseButtonEvents method, that iterates through all buttons pressed/released and sends the respective events to QWSI. Adapt the mouse handler in java, to obtain and pass the button state to C++. The patch can't be verified in an autotest. Testlib's mouse emulation injects into QWSI. Fixes: QTBUG-99106 Pick-to: 6.7 6.6 6.5 6.2 Change-Id: I933f490901928db9761d2ef254ae1e5b4f473f28 Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
Diffstat (limited to 'src/android')
-rw-r--r--src/android/jar/src/org/qtproject/qt/android/QtInputDelegate.java8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/android/jar/src/org/qtproject/qt/android/QtInputDelegate.java b/src/android/jar/src/org/qtproject/qt/android/QtInputDelegate.java
index 11346ed715..cfa273e410 100644
--- a/src/android/jar/src/org/qtproject/qt/android/QtInputDelegate.java
+++ b/src/android/jar/src/org/qtproject/qt/android/QtInputDelegate.java
@@ -502,8 +502,8 @@ class QtInputDelegate implements QtInputConnection.QtInputConnectionListener {
// tablet methods
// pointer methods
- public static native void mouseDown(int winId, int x, int y);
- public static native void mouseUp(int winId, int x, int y);
+ public static native void mouseDown(int winId, int x, int y, int mouseButtonState);
+ public static native void mouseUp(int winId, int x, int y, int mouseButtonState);
public static native void mouseMove(int winId, int x, int y);
public static native void mouseWheel(int winId, int x, int y, float hDelta, float vDelta);
public static native void touchBegin(int winId);
@@ -619,11 +619,11 @@ class QtInputDelegate implements QtInputConnection.QtInputConnectionListener {
{
switch (event.getActionMasked()) {
case MotionEvent.ACTION_UP:
- mouseUp(id, (int) event.getX(), (int) event.getY());
+ mouseUp(id, (int) event.getX(), (int) event.getY(), event.getButtonState());
break;
case MotionEvent.ACTION_DOWN:
- mouseDown(id, (int) event.getX(), (int) event.getY());
+ mouseDown(id, (int) event.getX(), (int) event.getY(), event.getButtonState());
m_oldX = (int) event.getX();
m_oldY = (int) event.getY();
break;