Chromium Code Reviews| Index: blimp/client/android/blimp_view.cc |
| diff --git a/blimp/client/android/blimp_view.cc b/blimp/client/android/blimp_view.cc |
| index de27258a9817a49cfbc6079cfd254909538a0c66..8c97dd9dd41648b28103ccd6271353bf443f8dd4 100644 |
| --- a/blimp/client/android/blimp_view.cc |
| +++ b/blimp/client/android/blimp_view.cc |
| @@ -6,7 +6,11 @@ |
| #include "blimp/client/compositor/blimp_compositor_android.h" |
| #include "jni/BlimpView_jni.h" |
| +#include "ui/events/android/motion_event_android.h" |
| +#include "ui/events/blink/blink_event_util.h" |
| +#include "ui/events/gesture_detection/gesture_provider_config_helper.h" |
| #include "ui/gfx/geometry/size.h" |
| +#include "third_party/WebKit/public/web/WebInputEvent.h" |
| namespace blimp { |
| @@ -33,7 +37,12 @@ BlimpView::BlimpView(JNIEnv* env, |
| const gfx::Size& real_size, |
| const gfx::Size& size, |
| float dp_to_px) |
| - : compositor_(BlimpCompositorAndroid::Create(real_size, size, dp_to_px)), |
| + : device_scale_factor_(dp_to_px), |
| + compositor_(BlimpCompositorAndroid::Create(real_size, size, dp_to_px)), |
| + // TODO(khushalsagar): Verify if any default configurations need to be |
| + // changed. |
| + gesture_provider_(ui::GetGestureProviderConfig( |
| + ui::GestureProviderConfigType::CURRENT_PLATFORM), this), |
| current_surface_format_(0) { |
| java_obj_.Reset(env, jobj); |
| } |
| @@ -73,4 +82,93 @@ void BlimpView::SetVisibility(JNIEnv* env, jobject jobj, jboolean visible) { |
| compositor_->SetVisible(visible); |
| } |
| +jboolean BlimpView::OnTouchEvent(JNIEnv* env, |
| + jobject obj, |
| + jobject motion_event, |
| + jlong time_ms, |
| + jint android_action, |
| + jint pointer_count, |
| + jint history_size, |
| + jint action_index, |
| + jfloat pos_x_0, |
| + jfloat pos_y_0, |
| + jfloat pos_x_1, |
| + jfloat pos_y_1, |
| + jint pointer_id_0, |
| + jint pointer_id_1, |
| + jfloat touch_major_0, |
| + jfloat touch_major_1, |
| + jfloat touch_minor_0, |
| + jfloat touch_minor_1, |
| + jfloat orientation_0, |
| + jfloat orientation_1, |
| + jfloat raw_pos_x, |
| + jfloat raw_pos_y, |
| + jint android_tool_type_0, |
| + jint android_tool_type_1, |
| + jint android_button_state, |
| + jint android_meta_state) { |
| + |
| + ui::MotionEventAndroid::Pointer pointer0(pointer_id_0, |
| + pos_x_0, |
|
David Trainor- moved to gerrit
2015/11/02 16:55:30
fix indentation. Same for all other MotionEventAn
Khushal
2015/12/01 08:22:25
Done.
|
| + pos_y_0, |
| + touch_major_0, |
| + touch_minor_0, |
| + orientation_0, |
| + android_tool_type_0); |
| + ui::MotionEventAndroid::Pointer pointer1(pointer_id_1, |
| + pos_x_1, |
| + pos_y_1, |
| + touch_major_1, |
| + touch_minor_1, |
| + orientation_1, |
| + android_tool_type_1); |
| + ui::MotionEventAndroid event(1.f / device_scale_factor_, |
| + env, |
| + motion_event, |
| + time_ms, |
| + android_action, |
| + pointer_count, |
| + history_size, |
| + action_index, |
| + android_button_state, |
| + android_meta_state, |
| + raw_pos_x - pos_x_0, |
| + raw_pos_y - pos_y_0, |
| + pointer0, |
| + pointer1); |
| + |
| + ui::FilteredGestureProvider::TouchHandlingResult result = |
| + gesture_provider_.OnTouchEvent(event); |
| + if (!result.succeeded) |
|
David Trainor- moved to gerrit
2015/11/02 16:55:30
indentation
Khushal
2015/12/01 08:22:25
Moved to BlimpInputManager.
|
| + return false; |
| + |
| + blink::WebTouchEvent web_event = |
| + ui::CreateWebTouchEventFromMotionEvent(event, result.did_generate_scroll); |
| + |
| + // Touch events are queued in the Gesture Provider until acknowledged to |
| + // allow them to be consumed by the touch event handlers in blink which can |
| + // prevent-default on the event. Since we currently do not support touch |
| + // handlers the event is always acknowledged as not consumed. |
| + // TODO(khushalsagar): Add support for touch events to blink. |
|
David Trainor- moved to gerrit
2015/11/02 16:55:30
s/blink/blimp?
Khushal
2015/12/01 08:22:25
Moved to BlimpInputManager.
|
| + gesture_provider_.OnTouchEventAck(web_event.uniqueTouchEventId, false); |
| + |
| + return true; |
| +} |
| + |
| +void BlimpView::OnGestureEvent(const ui::GestureEventData& gesture) { |
| + blink::WebGestureEvent web_gesture = |
| + ui::CreateWebGestureEventFromGestureEventData(gesture); |
| + // TODO(jdduke): Remove this workaround after Android fixes UiAutomator to |
| + // stop providing shift meta values to synthetic MotionEvents. This prevents |
| + // unintended shift+click interpretation of all accessibility clicks. |
| + // See crbug.com/443247. |
| + if (web_gesture.type == blink::WebInputEvent::GestureTap && |
| + web_gesture.modifiers == blink::WebInputEvent::ShiftKey) { |
| + web_gesture.modifiers = 0; |
| + } |
| + |
| + // TODO(khushalsagar): Use the GestureEventQueue. |
|
David Trainor- moved to gerrit
2015/11/02 16:55:30
TODO: Push the event to the compositor?
Khushal
2015/12/01 08:22:25
Done. Moved to BlimpInputManager.
|
| +} |
| + |
| } // namespace blimp |