Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(19)

Unified Diff: services/native_viewport/android/src/org/chromium/mojo/PlatformViewportAndroid.java

Issue 1029753002: Plumbs through android supplying multipe touch points (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: no pointer Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: services/native_viewport/android/src/org/chromium/mojo/PlatformViewportAndroid.java
diff --git a/services/native_viewport/android/src/org/chromium/mojo/PlatformViewportAndroid.java b/services/native_viewport/android/src/org/chromium/mojo/PlatformViewportAndroid.java
index 956290401a245bf70ed84f7dcf7b819ea54ed1bd..15eb96cbcf876632bf7c91725da553c888bdc851 100644
--- a/services/native_viewport/android/src/org/chromium/mojo/PlatformViewportAndroid.java
+++ b/services/native_viewport/android/src/org/chromium/mojo/PlatformViewportAndroid.java
@@ -83,8 +83,20 @@ public class PlatformViewportAndroid extends SurfaceView {
@Override
public boolean onTouchEvent(MotionEvent event) {
- return nativeTouchEvent(mNativeMojoViewport, event.getPointerId(0), event.getAction(),
- event.getX(), event.getY(), event.getEventTime());
+ final int actionMasked = event.getActionMasked();
+ if (actionMasked == MotionEvent.ACTION_POINTER_DOWN
+ || actionMasked == MotionEvent.ACTION_POINTER_UP) {
+ // Up/down events identify a single point.
+ return notifyTouchEventAtIndex(event, event.getActionIndex());
+ }
+ assert event.getPointerCount() != 0;
+ // All other types can have more than one point.
+ boolean result = false;
+ for (int i = 0, count = event.getPointerCount(); i < count; i++) {
+ final boolean sub_result = notifyTouchEventAtIndex(event, i);
+ result |= sub_result;
+ }
+ return result;
}
@Override
@@ -111,6 +123,14 @@ public class PlatformViewportAndroid extends SurfaceView {
return super.dispatchKeyShortcutEvent(event);
}
+ private boolean notifyTouchEventAtIndex(MotionEvent event, int index) {
+ return nativeTouchEvent(mNativeMojoViewport, event.getEventTime(), event.getActionMasked(),
+ event.getPointerId(index), event.getX(index), event.getY(index),
+ event.getPressure(index), event.getTouchMajor(index), event.getTouchMinor(index),
+ event.getOrientation(index), event.getAxisValue(MotionEvent.AXIS_HSCROLL, index),
+ event.getAxisValue(MotionEvent.AXIS_VSCROLL, index));
+ }
+
private boolean privateDispatchKeyEvent(KeyEvent event) {
if (event.getAction() == KeyEvent.ACTION_MULTIPLE) {
boolean result = false;
@@ -154,12 +174,9 @@ public class PlatformViewportAndroid extends SurfaceView {
private static native void nativeSurfaceSetSize(
long nativePlatformViewportAndroid, int width, int height, float density);
- private static native boolean nativeTouchEvent(
- long nativePlatformViewportAndroid,
- int pointerId,
- int action,
- float x, float y,
- long timeMs);
+ private static native boolean nativeTouchEvent(long nativePlatformViewportAndroid, long timeMs,
+ int maskedAction, int pointerId, float x, float y, float pressure, float touchMajor,
+ float touchMinor, float orientation, float hWheel, float vWheel);
private static native boolean nativeKeyEvent(
long nativePlatformViewportAndroid, boolean pressed, int keyCode, int unicodeCharacter);
« no previous file with comments | « mojo/services/input_events/public/interfaces/input_events.mojom ('k') | services/native_viewport/native_viewport_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698