Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "ui/android/event_handler.h" | |
| 6 | |
| 7 #include "base/android/jni_android.h" | |
| 8 #include "jni/EventHandler_jni.h" | |
| 9 #include "ui/android/view_android.h" | |
| 10 #include "ui/android/view_client.h" | |
| 11 #include "ui/events/android/motion_event_android.h" | |
| 12 | |
| 13 namespace ui { | |
| 14 | |
| 15 using base::android::JavaParamRef; | |
| 16 using base::android::ScopedJavaLocalRef; | |
| 17 | |
| 18 EventHandler* EventHandler::Create(ViewAndroid* view) { | |
| 19 return new EventHandler(view); | |
| 20 } | |
| 21 | |
| 22 EventHandler::EventHandler(ViewAndroid* view) : view_(view) {} | |
| 23 | |
| 24 ScopedJavaLocalRef<jobject> EventHandler::CreateJavaObject() { | |
|
boliu
2017/03/02 20:58:14
should create only one java side for each native s
Jinsuk Kim
2017/03/03 06:29:21
Done.
| |
| 25 return Java_EventHandler_create(base::android::AttachCurrentThread(), | |
| 26 reinterpret_cast<intptr_t>(this)); | |
| 27 } | |
| 28 | |
| 29 jboolean EventHandler::OnTouchEvent(JNIEnv* env, | |
| 30 const JavaParamRef<jobject>& obj, | |
| 31 const JavaParamRef<jobject>& motion_event, | |
| 32 jlong time_ms, | |
| 33 jint android_action, | |
| 34 jint pointer_count, | |
| 35 jint history_size, | |
| 36 jint action_index, | |
| 37 jfloat pos_x_0, | |
| 38 jfloat pos_y_0, | |
| 39 jfloat pos_x_1, | |
| 40 jfloat pos_y_1, | |
| 41 jint pointer_id_0, | |
| 42 jint pointer_id_1, | |
| 43 jfloat touch_major_0, | |
| 44 jfloat touch_major_1, | |
| 45 jfloat touch_minor_0, | |
| 46 jfloat touch_minor_1, | |
| 47 jfloat orientation_0, | |
| 48 jfloat orientation_1, | |
| 49 jfloat tilt_0, | |
| 50 jfloat tilt_1, | |
| 51 jfloat raw_pos_x, | |
| 52 jfloat raw_pos_y, | |
| 53 jint android_tool_type_0, | |
| 54 jint android_tool_type_1, | |
| 55 jint android_button_state, | |
| 56 jint android_meta_state, | |
| 57 jboolean is_touch_handle_event) { | |
| 58 return view_->OnTouchEvent(MotionEventData::ForTouch( | |
| 59 view_->GetDipScale(), motion_event.obj(), time_ms, android_action, | |
| 60 pointer_count, history_size, action_index, pos_x_0, pos_y_0, pos_x_1, | |
| 61 pos_y_1, pointer_id_0, pointer_id_1, touch_major_0, touch_major_1, | |
| 62 touch_minor_0, touch_minor_1, orientation_0, orientation_1, tilt_0, | |
| 63 tilt_1, raw_pos_x, raw_pos_y, android_tool_type_0, android_tool_type_1, | |
| 64 android_button_state, android_meta_state, is_touch_handle_event)); | |
| 65 } | |
| 66 | |
| 67 void EventHandler::OnMouseEvent(JNIEnv* env, | |
| 68 const JavaParamRef<jobject>& obj, | |
| 69 jlong time_ms, | |
| 70 jint android_action, | |
| 71 jfloat x, | |
| 72 jfloat y, | |
| 73 jint pointer_id, | |
| 74 jfloat orientation, | |
| 75 jfloat pressure, | |
| 76 jfloat tilt, | |
| 77 jint android_action_button, | |
| 78 jint android_button_state, | |
| 79 jint android_meta_state, | |
| 80 jint android_tool_type) { | |
| 81 view_->OnMouseEvent(MotionEventData::ForMouse( | |
| 82 view_->GetDipScale(), time_ms, android_action, x, y, pointer_id, | |
| 83 orientation, pressure, tilt, android_action_button, android_button_state, | |
| 84 android_meta_state, android_tool_type)); | |
| 85 } | |
| 86 | |
| 87 bool RegisterEventHandler(JNIEnv* env) { | |
| 88 return RegisterNativesImpl(env); | |
| 89 } | |
| 90 | |
| 91 } // namespace ui | |
| OLD | NEW |