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

Unified Diff: mojo/services/native_viewport/android/mojo_viewport.cc

Issue 63493002: Wires up MotionEvents for mojo_shell_apk on Android. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 1 month 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: 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);
}

Powered by Google App Engine
This is Rietveld 408576698