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

Unified Diff: ui/android/view_client.cc

Issue 2708613002: Add EventForwarder for routing touch events (Closed)
Patch Set: unittests Created 3 years, 10 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
« ui/android/view_client.h ('K') | « ui/android/view_client.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/android/view_client.cc
diff --git a/ui/android/view_client.cc b/ui/android/view_client.cc
new file mode 100644
index 0000000000000000000000000000000000000000..0bcb4df2202eac3cda102ecbe1b5cbf5b4fee496
--- /dev/null
+++ b/ui/android/view_client.cc
@@ -0,0 +1,178 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ui/android/view_client.h"
+
+namespace ui {
+
+MotionEventData::MotionEventData(float dip_scale,
+ jobject jevent,
+ long time_ms,
+ int android_action,
+ int pointer_count,
+ int history_size,
+ int action_index,
+ float pos_x_0,
+ float pos_y_0,
+ float pos_x_1,
+ float pos_y_1,
+ int pointer_id_0,
+ int pointer_id_1,
+ float touch_major_0,
+ float touch_major_1,
+ float touch_minor_0,
+ float touch_minor_1,
+ float orientation_0,
+ float orientation_1,
+ float tilt_0,
+ float tilt_1,
+ float raw_pos_x,
+ float raw_pos_y,
+ float pressure,
+ int android_tool_type_0,
+ int android_tool_type_1,
+ int android_action_button,
+ int android_button_state,
+ int android_meta_state,
+ bool is_touch_handle_event)
+ : dip_scale(dip_scale),
+ jevent(jevent),
+ time_ms(time_ms),
+ android_action(android_action),
+ pointer_count(pointer_count),
+ history_size(history_size),
+ action_index(action_index),
+ pos_x_0(pos_x_0),
+ pos_y_0(pos_y_0),
+ pos_x_1(pos_x_1),
+ pos_y_1(pos_y_1),
+ pointer_id_0(pointer_id_0),
+ pointer_id_1(pointer_id_1),
+ touch_major_0(touch_major_0),
+ touch_major_1(touch_major_1),
+ touch_minor_0(touch_minor_0),
+ touch_minor_1(touch_minor_1),
+ orientation_0(orientation_0),
+ orientation_1(orientation_1),
+ tilt_0(tilt_0),
+ tilt_1(tilt_1),
+ raw_pos_x(raw_pos_x),
+ raw_pos_y(raw_pos_y),
+ pressure(pressure),
+ android_tool_type_0(android_tool_type_0),
+ android_tool_type_1(android_tool_type_1),
+ android_action_button(android_action_button),
+ android_button_state(android_button_state),
+ android_meta_state(android_meta_state),
+ is_touch_handle_event(is_touch_handle_event) {}
+
+MotionEventData::MotionEventData(const MotionEventData& other)
+ : dip_scale(other.dip_scale),
+ jevent(other.jevent),
+ time_ms(other.time_ms),
+ android_action(other.android_action),
+ pointer_count(other.pointer_count),
+ history_size(other.history_size),
+ action_index(other.action_index),
+ pos_x_0(other.pos_x_0),
+ pos_y_0(other.pos_y_0),
+ pos_x_1(other.pos_x_1),
+ pos_y_1(other.pos_y_1),
+ pointer_id_0(other.pointer_id_0),
+ pointer_id_1(other.pointer_id_1),
+ touch_major_0(other.touch_major_0),
+ touch_major_1(other.touch_major_1),
+ touch_minor_0(other.touch_minor_0),
+ touch_minor_1(other.touch_minor_1),
+ orientation_0(other.orientation_0),
+ orientation_1(other.orientation_1),
+ tilt_0(other.tilt_0),
+ tilt_1(other.tilt_1),
+ raw_pos_x(other.raw_pos_x),
+ raw_pos_y(other.raw_pos_y),
+ pressure(other.pressure),
+ android_tool_type_0(other.android_tool_type_0),
+ android_tool_type_1(other.android_tool_type_1),
+ android_action_button(other.android_action_button),
+ android_button_state(other.android_button_state),
+ android_meta_state(other.android_meta_state),
+ is_touch_handle_event(other.is_touch_handle_event) {}
+
+MotionEventData MotionEventData::Offset(float delta_x, float delta_y) const {
+ return MotionEventData(
+ dip_scale, jevent, time_ms, android_action, pointer_count, history_size,
+ action_index, pos_x_0 + delta_x, pos_y_0 + delta_y, pos_x_1 + delta_x,
+ pos_y_1 + delta_y, pointer_id_0, pointer_id_1, touch_major_0,
+ touch_major_1, touch_minor_0, touch_minor_1, orientation_0, orientation_1,
+ tilt_0, tilt_1, raw_pos_x, raw_pos_y, pressure, android_tool_type_0,
+ android_tool_type_1, android_action_button, android_button_state,
+ android_meta_state, is_touch_handle_event);
+}
+
+// static
+MotionEventData MotionEventData::ForTouch(float dip_scale,
+ jobject jevent,
+ long time,
+ int action,
+ int pointer_count,
+ int history_size,
+ int action_index,
+ float pos_x0,
+ float pos_y0,
+ float pos_x1,
+ float pos_y1,
+ int pointer_id_0,
+ int pointer_id_1,
+ float touch_major_0,
+ float touch_major_1,
+ float touch_minor_0,
+ float touch_minor_1,
+ float orientation_0,
+ float orientation_1,
+ float tilt_0,
+ float tilt_1,
+ float raw_pos_x,
+ float raw_pos_y,
+ int tool_type_0,
+ int tool_type_1,
+ int button_state,
+ int meta_state,
+ bool is_touch_handle_event) {
+ return MotionEventData(
+ dip_scale, jevent, time, action, pointer_count, history_size,
+ action_index, pos_x0, pos_y0, pos_x1, pos_y1, pointer_id_0, pointer_id_1,
+ touch_major_0, touch_major_1, touch_minor_0, touch_minor_1, orientation_0,
+ orientation_1, tilt_0, tilt_1, raw_pos_x, raw_pos_y, 0.f, tool_type_0,
+ tool_type_1, 0, button_state, meta_state, is_touch_handle_event);
+}
+
+MotionEventData MotionEventData::ForMouse(float dip_scale,
+ long time_ms,
+ int android_action,
+ float pos_x,
+ float pos_y,
+ int pointer_id,
+ float orientation,
+ float pressure,
+ float tilt,
+ int android_tool_type,
+ int android_action_button,
+ int android_button_state,
+ int android_meta_state) {
+ return MotionEventData(dip_scale, nullptr, time_ms, android_action, 0, 0, 0,
+ pos_x, pos_y, 0.f, 0.f, pointer_id, 0, 0.f, 0.f, 0.f,
+ 0.f, orientation, 0.f, tilt, 0.f, 0.f, 0.f, pressure,
+ android_tool_type, 0, android_action_button,
+ android_button_state, android_meta_state, false);
+}
+
+bool ViewClient::OnTouchEvent(const MotionEventData& m) {
+ return false;
+}
+
+bool ViewClient::OnMouseEvent(const MotionEventData& m) {
+ return false;
+}
+
+} // namespace ui
« ui/android/view_client.h ('K') | « ui/android/view_client.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698