summaryrefslogtreecommitdiffstats
path: root/mojo
diff options
context:
space:
mode:
authorben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-12-06 17:35:13 +0000
committerben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-12-06 17:35:13 +0000
commit32d07d6400ac9c21c0f2cf8619212af9215be38c (patch)
tree5ab474c0a6d8667e3a4f0891f7b82f34abc3c5d3 /mojo
parent0f5a491d2dc8d94056514cba2ccd08ec13afffe8 (diff)
downloadchromium_src-32d07d6400ac9c21c0f2cf8619212af9215be38c.zip
chromium_src-32d07d6400ac9c21c0f2cf8619212af9215be38c.tar.gz
chromium_src-32d07d6400ac9c21c0f2cf8619212af9215be38c.tar.bz2
Wire events through to sample_app
R=abarth@chromium.org http://crbug.com/324639 Review URL: https://codereview.chromium.org/100823010 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@239233 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'mojo')
-rw-r--r--mojo/examples/sample_app/native_viewport_client_impl.cc9
-rw-r--r--mojo/examples/sample_app/native_viewport_client_impl.h1
-rw-r--r--mojo/services/native_viewport/native_viewport.h2
-rw-r--r--mojo/services/native_viewport/native_viewport.mojom17
-rw-r--r--mojo/services/native_viewport/native_viewport_impl.cc24
-rw-r--r--mojo/services/native_viewport/native_viewport_impl.h2
6 files changed, 52 insertions, 3 deletions
diff --git a/mojo/examples/sample_app/native_viewport_client_impl.cc b/mojo/examples/sample_app/native_viewport_client_impl.cc
index c956051..387a64e 100644
--- a/mojo/examples/sample_app/native_viewport_client_impl.cc
+++ b/mojo/examples/sample_app/native_viewport_client_impl.cc
@@ -6,6 +6,8 @@
#include <stdio.h>
+#include "base/logging.h"
+
namespace mojo {
namespace examples {
@@ -32,5 +34,12 @@ void NativeViewportClientImpl::Open() {
void NativeViewportClientImpl::DidOpen() {
}
+void NativeViewportClientImpl::HandleEvent(const Event& event) {
+ if (!event.location().is_null()) {
+ LOG(INFO) << "Located Event @"
+ << event.location().x() << "," << event.location().y();
+ }
+}
+
} // namespace examples
} // namespace mojo
diff --git a/mojo/examples/sample_app/native_viewport_client_impl.h b/mojo/examples/sample_app/native_viewport_client_impl.h
index 32beb6b..c2b3de9 100644
--- a/mojo/examples/sample_app/native_viewport_client_impl.h
+++ b/mojo/examples/sample_app/native_viewport_client_impl.h
@@ -22,6 +22,7 @@ class NativeViewportClientImpl : public NativeViewportClientStub {
private:
virtual void DidOpen() MOJO_OVERRIDE;
+ virtual void HandleEvent(const Event& event) MOJO_OVERRIDE;
scoped_ptr<GLES2ClientImpl> gles2_client_;
diff --git a/mojo/services/native_viewport/native_viewport.h b/mojo/services/native_viewport/native_viewport.h
index cc8b426..8597156 100644
--- a/mojo/services/native_viewport/native_viewport.h
+++ b/mojo/services/native_viewport/native_viewport.h
@@ -26,7 +26,7 @@ class NativeViewportDelegate {
virtual void OnResized(const gfx::Size& size) = 0;
virtual void OnAcceleratedWidgetAvailable(gfx::AcceleratedWidget widget) = 0;
- virtual bool OnEvent(ui::Event* event) = 0;
+ virtual bool OnEvent(ui::Event* ui_event) = 0;
virtual void OnDestroyed() = 0;
};
diff --git a/mojo/services/native_viewport/native_viewport.mojom b/mojo/services/native_viewport/native_viewport.mojom
index caae29a..20348fe 100644
--- a/mojo/services/native_viewport/native_viewport.mojom
+++ b/mojo/services/native_viewport/native_viewport.mojom
@@ -4,6 +4,22 @@
module mojo {
+struct Point {
+ float x;
+ float y;
+};
+
+struct TouchData {
+ int32 pointer_id;
+};
+
+struct Event {
+ int32 action;
+ int64 time_stamp;
+ Point location;
+ TouchData touch_data;
+};
+
[Peer=NativeViewportClient]
interface NativeViewport {
void Open();
@@ -14,6 +30,7 @@ interface NativeViewport {
[Peer=NativeViewport]
interface NativeViewportClient {
void DidOpen();
+ void HandleEvent(Event event);
};
}
diff --git a/mojo/services/native_viewport/native_viewport_impl.cc b/mojo/services/native_viewport/native_viewport_impl.cc
index bce78e3..777c8d2 100644
--- a/mojo/services/native_viewport/native_viewport_impl.cc
+++ b/mojo/services/native_viewport/native_viewport_impl.cc
@@ -47,7 +47,29 @@ void NativeViewportImpl::CreateGLES2ContextIfNeeded() {
gles2_->CreateContext(widget_, native_viewport_->GetSize());
}
-bool NativeViewportImpl::OnEvent(ui::Event* event) {
+bool NativeViewportImpl::OnEvent(ui::Event* ui_event) {
+ AllocationScope scope;
+
+ Event::Builder event;
+ event.set_action(ui_event->type());
+ event.set_time_stamp(ui_event->time_stamp().ToInternalValue());
+
+ if (ui_event->IsMouseEvent() || ui_event->IsTouchEvent()) {
+ ui::LocatedEvent* located_event = static_cast<ui::LocatedEvent*>(ui_event);
+ Point::Builder location;
+ location.set_x(located_event->location().x());
+ location.set_y(located_event->location().y());
+ event.set_location(location.Finish());
+ }
+
+ if (ui_event->IsTouchEvent()) {
+ ui::TouchEvent* touch_event = static_cast<ui::TouchEvent*>(ui_event);
+ TouchData::Builder touch_data;
+ touch_data.set_pointer_id(touch_event->touch_id());
+ event.set_touch_data(touch_data.Finish());
+ }
+
+ client_->HandleEvent(event.Finish());
return false;
}
diff --git a/mojo/services/native_viewport/native_viewport_impl.h b/mojo/services/native_viewport/native_viewport_impl.h
index 332105e..fe9d821 100644
--- a/mojo/services/native_viewport/native_viewport_impl.h
+++ b/mojo/services/native_viewport/native_viewport_impl.h
@@ -37,7 +37,7 @@ class NativeViewportImpl : public NativeViewportStub,
virtual void OnResized(const gfx::Size& size) OVERRIDE;
virtual void OnAcceleratedWidgetAvailable(
gfx::AcceleratedWidget widget) OVERRIDE;
- virtual bool OnEvent(ui::Event* event) OVERRIDE;
+ virtual bool OnEvent(ui::Event* ui_event) OVERRIDE;
virtual void OnDestroyed() OVERRIDE;
void CreateGLES2ContextIfNeeded();