Chromium Code Reviews| Index: mojo/services/native_viewport/android/mojo_viewport.cc |
| diff --git a/mojo/services/native_viewport/android/mojo_viewport.cc b/mojo/services/native_viewport/android/mojo_viewport.cc |
| index 8530b7c109469826344ffc384e05e75ca5686366..1aa1cbe4a18726d675aa8d2e5fe0ec0ada699e93 100644 |
| --- a/mojo/services/native_viewport/android/mojo_viewport.cc |
| +++ b/mojo/services/native_viewport/android/mojo_viewport.cc |
| @@ -14,6 +14,37 @@ |
| namespace mojo { |
| namespace services { |
| +const int ACTION_DOWN = 0; |
|
Ben Goodger (Google)
2013/11/07 00:20:38
I'm not sure if there's a better way to do this. T
abarth-chromium
2013/11/07 00:29:11
Is there a header we can include to get these cons
|
| +const int ACTION_HOVER_ENTER = 9; |
| +const int ACTION_HOVER_EXIT = 10; |
| +const int ACTION_HOVER_MOVE = 7; |
| +const int ACTION_MOVE = 2; |
| +const int ACTION_UP = 1; |
| + |
| +ui::EventType MotionEventActionToEventType(jint action, jboolean is_touch) { |
| + switch (action) { |
| + case ACTION_DOWN: |
| + return is_touch ? ui::ET_TOUCH_PRESSED : ui::ET_MOUSE_PRESSED; |
| + case ACTION_HOVER_ENTER: |
| + DCHECK(!is_touch); |
| + return ui::ET_MOUSE_ENTERED; |
| + case ACTION_HOVER_EXIT: |
| + DCHECK(!is_touch); |
| + return ui::ET_MOUSE_EXITED; |
| + case ACTION_HOVER_MOVE: |
| + DCHECK(!is_touch); |
| + return ui::ET_MOUSE_MOVED; |
| + case ACTION_MOVE: |
| + return is_touch ? ui::ET_TOUCH_MOVED : ui::ET_MOUSE_DRAGGED; |
| + case ACTION_UP: |
| + return is_touch ? ui::ET_TOUCH_RELEASED : ui::ET_MOUSE_RELEASED; |
| + default: |
| + NOTREACHED(); |
| + } |
| + return ui::ET_UNKNOWN; |
| +} |
| + |
| + |
|
abarth-chromium
2013/11/07 00:29:11
You've got a blank line here.
|
| MojoViewportInit::MojoViewportInit() { |
| } |
| @@ -70,6 +101,25 @@ void MojoViewport::SurfaceSetSize( |
| gfx::Size(width, height))); |
| } |
| +bool MojoViewport::MotionEvent(JNIEnv* env, jobject obj, |
| + jboolean is_touch, |
| + jint pointer_id, |
| + jint action, |
| + jfloat x, jfloat y, |
| + jlong time_ms) { |
| + ui_runner_->PostTask(FROM_HERE, base::Bind( |
| + &NativeViewportAndroid::OnMotionEvent, |
| + native_viewport_, |
| + is_touch, |
| + pointer_id, |
| + MotionEventActionToEventType(action, is_touch), |
| + x, y, |
| + time_ms)); |
| + // TODO(beng): This type needs to live on the main thread so we can respond to |
| + // this question truthfully. |
| + return true; |
| +} |
| + |
| bool MojoViewport::Register(JNIEnv* env) { |
| return RegisterNativesImpl(env); |
| } |