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

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..5f1adc8dd6ad8663b3ba7588c84a8176d4d46ba1 100644
--- a/mojo/services/native_viewport/android/mojo_viewport.cc
+++ b/mojo/services/native_viewport/android/mojo_viewport.cc
@@ -4,7 +4,9 @@
#include "mojo/services/native_viewport/android/mojo_viewport.h"
+#include <android/input.h>
#include <android/native_window_jni.h>
+
#include "base/android/jni_android.h"
#include "base/bind.h"
#include "base/location.h"
@@ -14,6 +16,20 @@
namespace mojo {
namespace services {
+ui::EventType MotionEventActionToEventType(jint action) {
+ switch (action) {
+ case AMOTION_EVENT_ACTION_DOWN:
+ return ui::ET_TOUCH_PRESSED;
+ case AMOTION_EVENT_ACTION_MOVE:
+ return ui::ET_TOUCH_MOVED;
+ case AMOTION_EVENT_ACTION_UP:
+ return ui::ET_TOUCH_RELEASED;
+ default:
+ NOTREACHED();
+ }
+ return ui::ET_UNKNOWN;
+}
+
MojoViewportInit::MojoViewportInit() {
}
@@ -70,6 +86,23 @@ void MojoViewport::SurfaceSetSize(
gfx::Size(width, height)));
}
+bool MojoViewport::TouchEvent(JNIEnv* env, jobject obj,
+ jint pointer_id,
+ jint action,
+ jfloat x, jfloat y,
+ jlong time_ms) {
+ ui_runner_->PostTask(FROM_HERE, base::Bind(
+ &NativeViewportAndroid::OnTouchEvent,
+ native_viewport_,
+ pointer_id,
+ MotionEventActionToEventType(action),
+ 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