From 8d8cbe87e21f05b7d611ed4be47299977288b267 Mon Sep 17 00:00:00 2001 From: Axel Spoerl Date: Mon, 15 Apr 2024 10:42:00 +0200 Subject: 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 --- src/android/jar/src/org/qtproject/qt/android/QtInputDelegate.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/android') 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; -- cgit v1.2.3