Index: mojo/services/native_viewport/native_viewport_android.cc |
diff --git a/mojo/services/native_viewport/native_viewport_android.cc b/mojo/services/native_viewport/native_viewport_android.cc |
index 753b8ed7d4f4046749f8db63abfbeac8de67ba36..04a4e688cd028defb4d0fe546f0ca5fc3fa93237 100644 |
--- a/mojo/services/native_viewport/native_viewport_android.cc |
+++ b/mojo/services/native_viewport/native_viewport_android.cc |
@@ -9,6 +9,8 @@ |
#include "gpu/command_buffer/client/gles2_implementation.h" |
#include "mojo/services/native_viewport/android/mojo_viewport.h" |
#include "mojo/shell/context.h" |
+#include "ui/events/event.h" |
+#include "ui/gfx/point.h" |
namespace mojo { |
namespace services { |
@@ -16,6 +18,7 @@ namespace services { |
NativeViewportAndroid::NativeViewportAndroid(NativeViewportDelegate* delegate) |
: delegate_(delegate), |
window_(NULL), |
+ id_generator_(0), |
weak_factory_(this) { |
} |
@@ -52,6 +55,26 @@ void NativeViewportAndroid::OnResized(const gfx::Size& size) { |
delegate_->OnResized(size); |
} |
+void NativeViewportAndroid::OnMotionEvent(bool is_touch, |
+ int pointer_id, |
+ ui::EventType action, |
+ float x, float y, |
+ int64 time_ms) { |
+ gfx::Point location(static_cast<int>(x), static_cast<int>(y)); |
+ if (is_touch) { |
+ ui::TouchEvent event(action, location, |
+ id_generator_.GetGeneratedID(pointer_id), |
+ base::TimeDelta::FromMilliseconds(time_ms)); |
+ // TODO(beng): handle multiple touch-points. |
+ delegate_->OnEvent(&event); |
+ if (action == ui::ET_TOUCH_RELEASED) |
+ id_generator_.ReleaseNumber(pointer_id); |
+ } else { |
+ ui::MouseEvent event(action, location, location, 0); |
+ delegate_->OnEvent(&event); |
+ } |
+} |
+ |
void NativeViewportAndroid::ReleaseWindow() { |
gl_context_.reset(); |
ANativeWindow_release(window_); |