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

Unified Diff: mojo/services/public/cpp/input_events/lib/input_events_type_converters.cc

Issue 316713002: Wire input events through the ViewManagerClient interface. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: cleanup Created 6 years, 7 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
Index: mojo/services/public/cpp/input_events/lib/input_events_type_converters.cc
diff --git a/mojo/services/public/cpp/input_events/lib/input_events_type_converters.cc b/mojo/services/public/cpp/input_events/lib/input_events_type_converters.cc
new file mode 100644
index 0000000000000000000000000000000000000000..bc3a9c94436cb18ed23b9c1ea90823166de01966
--- /dev/null
+++ b/mojo/services/public/cpp/input_events/lib/input_events_type_converters.cc
@@ -0,0 +1,44 @@
+// Copyright 2014 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 "mojo/services/public/cpp/input_events/input_events_type_converters.h"
+
+#include "mojo/services/public/cpp/geometry/geometry_type_converters.h"
+#include "ui/events/keycodes/keyboard_codes.h"
+
+namespace mojo {
+
+// static
+EventPtr TypeConverter<EventPtr, ui::Event>::ConvertFrom(
+ const ui::Event& input) {
+ EventPtr event(Event::New());
+ event->action = input.type();
+ event->flags = input.flags();
+ event->time_stamp = input.time_stamp().ToInternalValue();
+
+ if (input.IsMouseEvent() || input.IsTouchEvent()) {
+ const ui::LocatedEvent* located_event =
+ static_cast<const ui::LocatedEvent*>(&input);
+ event->location =
+ TypeConverter<PointPtr, gfx::Point>::ConvertFrom(
+ located_event->location());
+ }
+
+ if (input.IsTouchEvent()) {
+ const ui::TouchEvent* touch_event =
+ static_cast<const ui::TouchEvent*>(&input);
+ TouchDataPtr touch_data(TouchData::New());
+ touch_data->pointer_id = touch_event->touch_id();
+ event->touch_data = touch_data.Pass();
+ } else if (input.IsKeyEvent()) {
+ const ui::KeyEvent* key_event = static_cast<const ui::KeyEvent*>(&input);
+ KeyDataPtr key_data(KeyData::New());
+ key_data->key_code = key_event->key_code();
+ key_data->is_char = key_event->is_char();
+ event->key_data = key_data.Pass();
+ }
+ return event.Pass();
+}
+
+} // namespace mojo

Powered by Google App Engine
This is Rietveld 408576698