diff options
author | morrita@chromium.org <morrita@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-07-24 00:06:23 +0000 |
---|---|---|
committer | morrita@chromium.org <morrita@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-07-24 00:06:23 +0000 |
commit | bb7004b1e0d1295d89610e098489341e279914a9 (patch) | |
tree | d07c1ec8d188d02af21945a9e5ec0545d406b443 | |
parent | 7b6056468a422425880c2982f6b7f79027ddb131 (diff) | |
download | chromium_src-bb7004b1e0d1295d89610e098489341e279914a9.zip chromium_src-bb7004b1e0d1295d89610e098489341e279914a9.tar.gz chromium_src-bb7004b1e0d1295d89610e098489341e279914a9.tar.bz2 |
Mojo: Introduces mojo::EventType and mojo::EventFlags
This change introduces EventType and EventFlags enum types
which mirror ui::EventType and ui::EventFlags. With these,
simple mouse/touch based Mojo apps no longer have to depend
on the ui module.
Note that this doesn't introduce any keycodes. It will need
some non-trivial work which deserves its own CL.
BUG=330467
R=beng@chromium.org, darin@chromium.org, viettrungluu@chromium.org
TEST=none
Review URL: https://codereview.chromium.org/413633003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@285080 0039d316-1c4b-4281-b951-d872f2087c98
11 files changed, 255 insertions, 59 deletions
diff --git a/mojo/examples/embedded_app/embedded_app.cc b/mojo/examples/embedded_app/embedded_app.cc index 73f281d..8600dc7 100644 --- a/mojo/examples/embedded_app/embedded_app.cc +++ b/mojo/examples/embedded_app/embedded_app.cc @@ -104,8 +104,8 @@ class EmbeddedApp : public ApplicationDelegate, // Overridden from ViewObserver: virtual void OnViewInputEvent(View* view, const EventPtr& event) OVERRIDE { - if (event->action == ui::ET_MOUSE_RELEASED) { - if (event->flags & ui::EF_LEFT_MOUSE_BUTTON) { + if (event->action == EVENT_TYPE_MOUSE_RELEASED) { + if (event->flags & EVENT_FLAGS_LEFT_MOUSE_BUTTON) { navigation::NavigationDetailsPtr nav_details( navigation::NavigationDetails::New()); nav_details->url = "http://www.aaronboodman.com/z_dropbox/test.html"; diff --git a/mojo/examples/nesting_app/nesting_app.cc b/mojo/examples/nesting_app/nesting_app.cc index e62f1b7..4141cd6 100644 --- a/mojo/examples/nesting_app/nesting_app.cc +++ b/mojo/examples/nesting_app/nesting_app.cc @@ -101,7 +101,7 @@ class NestingApp : public ApplicationDelegate, // Overridden from ViewObserver: virtual void OnViewInputEvent(View* view, const EventPtr& event) OVERRIDE { - if (event->action == ui::ET_MOUSE_RELEASED) + if (event->action == EVENT_TYPE_MOUSE_RELEASED) window_manager_->CloseWindow(view->node()->id()); } diff --git a/mojo/examples/sample_app/DEPS b/mojo/examples/sample_app/DEPS index d5f25b3..48e8875 100644 --- a/mojo/examples/sample_app/DEPS +++ b/mojo/examples/sample_app/DEPS @@ -1,3 +1,2 @@ include_rules = [ - "+ui/events/event_constants.h", # pending enum support in mojom ] diff --git a/mojo/examples/sample_app/gles2_client_impl.cc b/mojo/examples/sample_app/gles2_client_impl.cc index d0b0c90..c62b47f 100644 --- a/mojo/examples/sample_app/gles2_client_impl.cc +++ b/mojo/examples/sample_app/gles2_client_impl.cc @@ -10,7 +10,6 @@ #include <stdlib.h> #include "mojo/public/c/gles2/gles2.h" -#include "ui/events/event_constants.h" namespace examples { namespace { @@ -50,18 +49,18 @@ void GLES2ClientImpl::SetSize(const mojo::Size& size) { void GLES2ClientImpl::HandleInputEvent(const mojo::Event& event) { switch (event.action) { - case ui::ET_MOUSE_PRESSED: - case ui::ET_TOUCH_PRESSED: - if (event.flags & ui::EF_RIGHT_MOUSE_BUTTON) + case mojo::EVENT_TYPE_MOUSE_PRESSED: + case mojo::EVENT_TYPE_TOUCH_PRESSED: + if (event.flags & mojo::EVENT_FLAGS_RIGHT_MOUSE_BUTTON) break; CancelAnimationFrames(); capture_point_ = *event.location; last_drag_point_ = capture_point_; drag_start_time_ = mojo::GetTimeTicksNow(); break; - case ui::ET_MOUSE_DRAGGED: - case ui::ET_TOUCH_MOVED: - if (event.flags & ui::EF_RIGHT_MOUSE_BUTTON) + case mojo::EVENT_TYPE_MOUSE_DRAGGED: + case mojo::EVENT_TYPE_TOUCH_MOVED: + if (event.flags & mojo::EVENT_FLAGS_RIGHT_MOUSE_BUTTON) break; if (!getting_animation_frames_) { int direction = event.location->y < last_drag_point_.y || @@ -75,9 +74,9 @@ void GLES2ClientImpl::HandleInputEvent(const mojo::Event& event) { last_drag_point_ = *event.location; } break; - case ui::ET_MOUSE_RELEASED: - case ui::ET_TOUCH_RELEASED: { - if (event.flags & ui::EF_RIGHT_MOUSE_BUTTON) { + case mojo::EVENT_TYPE_MOUSE_RELEASED: + case mojo::EVENT_TYPE_TOUCH_RELEASED: { + if (event.flags & mojo::EVENT_FLAGS_RIGHT_MOUSE_BUTTON) { cube_.set_color(GetRandomColor(), GetRandomColor(), GetRandomColor()); break; } diff --git a/mojo/examples/window_manager/window_manager.cc b/mojo/examples/window_manager/window_manager.cc index 0b08a52..1ef062c 100644 --- a/mojo/examples/window_manager/window_manager.cc +++ b/mojo/examples/window_manager/window_manager.cc @@ -374,7 +374,7 @@ class WindowManager : public ApplicationDelegate, } virtual void DispatchEvent(View* target, EventPtr event) OVERRIDE { // TODO(beng): More sophisticated focus handling than this is required! - if (event->action == ui::ET_MOUSE_PRESSED && + if (event->action == EVENT_TYPE_MOUSE_PRESSED && !IsDescendantOfKeyboard(target)) { target->node()->SetFocus(); } diff --git a/mojo/services/html_viewer/blink_input_events_type_converters.cc b/mojo/services/html_viewer/blink_input_events_type_converters.cc index 07a2673..542b13f 100644 --- a/mojo/services/html_viewer/blink_input_events_type_converters.cc +++ b/mojo/services/html_viewer/blink_input_events_type_converters.cc @@ -71,12 +71,12 @@ scoped_ptr<blink::WebInputEvent> TypeConverter<EventPtr, scoped_ptr<blink::WebInputEvent> >::ConvertTo( const EventPtr& event) { - if (event->action == ui::ET_MOUSE_PRESSED || - event->action == ui::ET_MOUSE_RELEASED || - event->action == ui::ET_MOUSE_ENTERED || - event->action == ui::ET_MOUSE_EXITED || - event->action == ui::ET_MOUSE_MOVED || - event->action == ui::ET_MOUSE_DRAGGED) { + if (event->action == EVENT_TYPE_MOUSE_PRESSED || + event->action == EVENT_TYPE_MOUSE_RELEASED || + event->action == EVENT_TYPE_MOUSE_ENTERED || + event->action == EVENT_TYPE_MOUSE_EXITED || + event->action == EVENT_TYPE_MOUSE_MOVED || + event->action == EVENT_TYPE_MOUSE_DRAGGED) { scoped_ptr<blink::WebMouseEvent> web_event(new blink::WebMouseEvent); web_event->x = event->location->x; web_event->y = event->location->y; @@ -94,18 +94,18 @@ TypeConverter<EventPtr, scoped_ptr<blink::WebInputEvent> >::ConvertTo( web_event->button = blink::WebMouseEvent::ButtonRight; switch (event->action) { - case ui::ET_MOUSE_PRESSED: + case EVENT_TYPE_MOUSE_PRESSED: web_event->type = blink::WebInputEvent::MouseDown; web_event->clickCount = GetClickCount(event->flags); break; - case ui::ET_MOUSE_RELEASED: + case EVENT_TYPE_MOUSE_RELEASED: web_event->type = blink::WebInputEvent::MouseUp; web_event->clickCount = GetClickCount(event->flags); break; - case ui::ET_MOUSE_ENTERED: - case ui::ET_MOUSE_EXITED: - case ui::ET_MOUSE_MOVED: - case ui::ET_MOUSE_DRAGGED: + case EVENT_TYPE_MOUSE_ENTERED: + case EVENT_TYPE_MOUSE_EXITED: + case EVENT_TYPE_MOUSE_MOVED: + case EVENT_TYPE_MOUSE_DRAGGED: web_event->type = blink::WebInputEvent::MouseMove; break; default: @@ -114,8 +114,8 @@ TypeConverter<EventPtr, scoped_ptr<blink::WebInputEvent> >::ConvertTo( } return web_event.PassAs<blink::WebInputEvent>(); - } else if ((event->action == ui::ET_KEY_PRESSED || - event->action == ui::ET_KEY_RELEASED) && + } else if ((event->action == EVENT_TYPE_KEY_PRESSED || + event->action == EVENT_TYPE_KEY_RELEASED) && event->key_data) { scoped_ptr<blink::WebKeyboardEvent> web_event(new blink::WebKeyboardEvent); @@ -129,11 +129,11 @@ TypeConverter<EventPtr, scoped_ptr<blink::WebInputEvent> >::ConvertTo( (event->key_data->key_code >= 32 && event->key_data->key_code < 127); switch (event->action) { - case ui::ET_KEY_PRESSED: + case EVENT_TYPE_KEY_PRESSED: web_event->type = is_char ? blink::WebInputEvent::Char : blink::WebInputEvent::RawKeyDown; break; - case ui::ET_KEY_RELEASED: + case EVENT_TYPE_KEY_RELEASED: web_event->type = blink::WebInputEvent::KeyUp; break; default: @@ -154,7 +154,7 @@ TypeConverter<EventPtr, scoped_ptr<blink::WebInputEvent> >::ConvertTo( web_event->setKeyIdentifierFromWindowsKeyCode(); return web_event.PassAs<blink::WebInputEvent>(); - } else if (event->action == ui::ET_MOUSEWHEEL) { + } else if (event->action == EVENT_TYPE_MOUSEWHEEL) { scoped_ptr<blink::WebMouseWheelEvent> web_event( new blink::WebMouseWheelEvent); web_event->type = blink::WebInputEvent::MouseWheel; diff --git a/mojo/services/public/cpp/input_events/input_events_type_converters.h b/mojo/services/public/cpp/input_events/input_events_type_converters.h index 00a03ac..64c1645 100644 --- a/mojo/services/public/cpp/input_events/input_events_type_converters.h +++ b/mojo/services/public/cpp/input_events/input_events_type_converters.h @@ -13,6 +13,13 @@ namespace mojo { template<> +class MOJO_INPUT_EVENTS_EXPORT TypeConverter<EventType, ui::EventType> { + public: + static EventType ConvertFrom(ui::EventType type); + static ui::EventType ConvertTo(EventType type); +}; + +template<> class MOJO_INPUT_EVENTS_EXPORT TypeConverter<EventPtr, ui::Event> { public: static EventPtr ConvertFrom(const ui::Event& input); diff --git a/mojo/services/public/cpp/input_events/lib/input_event_names.h b/mojo/services/public/cpp/input_events/lib/input_event_names.h new file mode 100644 index 0000000..3fd6ef6 --- /dev/null +++ b/mojo/services/public/cpp/input_events/lib/input_event_names.h @@ -0,0 +1,46 @@ +// 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. + +MOJO_INPUT_EVENT_NAME(UNKNOWN); +MOJO_INPUT_EVENT_NAME(MOUSE_PRESSED); +MOJO_INPUT_EVENT_NAME(MOUSE_DRAGGED); +MOJO_INPUT_EVENT_NAME(MOUSE_RELEASED); +MOJO_INPUT_EVENT_NAME(MOUSE_MOVED); +MOJO_INPUT_EVENT_NAME(MOUSE_ENTERED); +MOJO_INPUT_EVENT_NAME(MOUSE_EXITED); +MOJO_INPUT_EVENT_NAME(KEY_PRESSED); +MOJO_INPUT_EVENT_NAME(KEY_RELEASED); +MOJO_INPUT_EVENT_NAME(MOUSEWHEEL); +MOJO_INPUT_EVENT_NAME(MOUSE_CAPTURE_CHANGED); +MOJO_INPUT_EVENT_NAME(TOUCH_RELEASED); +MOJO_INPUT_EVENT_NAME(TOUCH_PRESSED); +MOJO_INPUT_EVENT_NAME(TOUCH_MOVED); +MOJO_INPUT_EVENT_NAME(TOUCH_CANCELLED); +MOJO_INPUT_EVENT_NAME(DROP_TARGET_EVENT); +MOJO_INPUT_EVENT_NAME(TRANSLATED_KEY_PRESS); +MOJO_INPUT_EVENT_NAME(TRANSLATED_KEY_RELEASE); +MOJO_INPUT_EVENT_NAME(GESTURE_SCROLL_BEGIN); +MOJO_INPUT_EVENT_NAME(GESTURE_SCROLL_END); +MOJO_INPUT_EVENT_NAME(GESTURE_SCROLL_UPDATE); +MOJO_INPUT_EVENT_NAME(GESTURE_TAP); +MOJO_INPUT_EVENT_NAME(GESTURE_TAP_DOWN); +MOJO_INPUT_EVENT_NAME(GESTURE_TAP_CANCEL); +MOJO_INPUT_EVENT_NAME(GESTURE_TAP_UNCONFIRMED); +MOJO_INPUT_EVENT_NAME(GESTURE_DOUBLE_TAP); +MOJO_INPUT_EVENT_NAME(GESTURE_BEGIN); +MOJO_INPUT_EVENT_NAME(GESTURE_END); +MOJO_INPUT_EVENT_NAME(GESTURE_TWO_FINGER_TAP); +MOJO_INPUT_EVENT_NAME(GESTURE_PINCH_BEGIN); +MOJO_INPUT_EVENT_NAME(GESTURE_PINCH_END); +MOJO_INPUT_EVENT_NAME(GESTURE_PINCH_UPDATE); +MOJO_INPUT_EVENT_NAME(GESTURE_LONG_PRESS); +MOJO_INPUT_EVENT_NAME(GESTURE_LONG_TAP); +MOJO_INPUT_EVENT_NAME(GESTURE_SWIPE); +MOJO_INPUT_EVENT_NAME(GESTURE_SHOW_PRESS); +MOJO_INPUT_EVENT_NAME(GESTURE_WIN8_EDGE_SWIPE); +MOJO_INPUT_EVENT_NAME(SCROLL); +MOJO_INPUT_EVENT_NAME(SCROLL_FLING_START); +MOJO_INPUT_EVENT_NAME(SCROLL_FLING_CANCEL); +MOJO_INPUT_EVENT_NAME(CANCEL_MODE); +MOJO_INPUT_EVENT_NAME(UMA_DATA); 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 index dbd8f70..cff22d4 100644 --- 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 @@ -5,16 +5,95 @@ #include "mojo/services/public/cpp/input_events/input_events_type_converters.h" #include "mojo/services/public/cpp/geometry/geometry_type_converters.h" +#include "mojo/services/public/interfaces/input_events/input_events.mojom.h" #include "ui/events/keycodes/keyboard_codes.h" namespace mojo { +COMPILE_ASSERT(static_cast<int32>(EVENT_FLAGS_NONE) == + static_cast<int32>(ui::EF_NONE), + event_flags_should_match); +COMPILE_ASSERT(static_cast<int32>(EVENT_FLAGS_CAPS_LOCK_DOWN) == + static_cast<int32>(ui::EF_CAPS_LOCK_DOWN), + event_flags_should_match); +COMPILE_ASSERT(static_cast<int32>(EVENT_FLAGS_SHIFT_DOWN) == + static_cast<int32>(ui::EF_SHIFT_DOWN), + event_flags_should_match); +COMPILE_ASSERT(static_cast<int32>(EVENT_FLAGS_CONTROL_DOWN) == + static_cast<int32>(ui::EF_CONTROL_DOWN), + event_flags_should_match); +COMPILE_ASSERT(static_cast<int32>(EVENT_FLAGS_ALT_DOWN) == + static_cast<int32>(ui::EF_ALT_DOWN), + event_flags_should_match); +COMPILE_ASSERT(static_cast<int32>(EVENT_FLAGS_LEFT_MOUSE_BUTTON) == + static_cast<int32>(ui::EF_LEFT_MOUSE_BUTTON), + event_flags_should_match); +COMPILE_ASSERT(static_cast<int32>(EVENT_FLAGS_MIDDLE_MOUSE_BUTTON) == + static_cast<int32>(ui::EF_MIDDLE_MOUSE_BUTTON), + event_flags_should_match); +COMPILE_ASSERT(static_cast<int32>(EVENT_FLAGS_RIGHT_MOUSE_BUTTON) == + static_cast<int32>(ui::EF_RIGHT_MOUSE_BUTTON), + event_flags_should_match); +COMPILE_ASSERT(static_cast<int32>(EVENT_FLAGS_COMMAND_DOWN) == + static_cast<int32>(ui::EF_COMMAND_DOWN), + event_flags_should_match); +COMPILE_ASSERT(static_cast<int32>(EVENT_FLAGS_EXTENDED) == + static_cast<int32>(ui::EF_EXTENDED), + event_flags_should_match); +COMPILE_ASSERT(static_cast<int32>(EVENT_FLAGS_IS_SYNTHESIZED) == + static_cast<int32>(ui::EF_IS_SYNTHESIZED), + event_flags_should_match); +COMPILE_ASSERT(static_cast<int32>(EVENT_FLAGS_ALTGR_DOWN) == + static_cast<int32>(ui::EF_ALTGR_DOWN), + event_flags_should_match); +COMPILE_ASSERT(static_cast<int32>(EVENT_FLAGS_MOD3_DOWN) == + static_cast<int32>(ui::EF_MOD3_DOWN), + event_flags_should_match); + + +// static +EventType TypeConverter<EventType, ui::EventType>::ConvertFrom( + ui::EventType type) { + +#define MOJO_INPUT_EVENT_NAME(name) case ui::ET_##name: return EVENT_TYPE_##name + + switch (type) { +#include "mojo/services/public/cpp/input_events/lib/input_event_names.h" + case ui::ET_LAST: + NOTREACHED(); + break; + } + +#undef MOJO_INPUT_EVENT_NAME + + NOTREACHED(); + return EVENT_TYPE_UNKNOWN; +} + +// static +ui::EventType TypeConverter<EventType, ui::EventType>::ConvertTo( + EventType type) { + +#define MOJO_INPUT_EVENT_NAME(name) case EVENT_TYPE_##name: return ui::ET_##name + + switch (type) { +#include "mojo/services/public/cpp/input_events/lib/input_event_names.h" + } + +#undef MOJO_INPUT_EVENT_NAME + + NOTREACHED(); + return ui::ET_UNKNOWN; +} + + // static EventPtr TypeConverter<EventPtr, ui::Event>::ConvertFrom( const ui::Event& input) { EventPtr event(Event::New()); - event->action = input.type(); - event->flags = input.flags(); + event->action = TypeConverter<EventType, ui::EventType>::ConvertFrom( + input.type()); + event->flags = EventFlags(input.flags()); event->time_stamp = input.time_stamp().ToInternalValue(); if (input.IsMouseEvent() || input.IsTouchEvent()) { @@ -59,34 +138,36 @@ scoped_ptr<ui::Event> TypeConverter<EventPtr, scoped_ptr<ui::Event> >::ConvertTo( const EventPtr& input) { scoped_ptr<ui::Event> ui_event; + ui::EventType ui_event_type = + TypeConverter<EventType, ui::EventType>::ConvertTo(input->action); switch (input->action) { - case ui::ET_KEY_PRESSED: - case ui::ET_KEY_RELEASED: + case EVENT_TYPE_KEY_PRESSED: + case EVENT_TYPE_KEY_RELEASED: ui_event.reset(new ui::KeyEvent( - static_cast<ui::EventType>(input->action), + ui_event_type, static_cast<ui::KeyboardCode>( input->key_data->key_code), - input->flags, + ui::EventFlags(input->flags), input->key_data->is_char)); break; - case ui::ET_MOUSE_PRESSED: - case ui::ET_MOUSE_DRAGGED: - case ui::ET_MOUSE_RELEASED: - case ui::ET_MOUSE_MOVED: - case ui::ET_MOUSE_ENTERED: - case ui::ET_MOUSE_EXITED: { + case EVENT_TYPE_MOUSE_PRESSED: + case EVENT_TYPE_MOUSE_DRAGGED: + case EVENT_TYPE_MOUSE_RELEASED: + case EVENT_TYPE_MOUSE_MOVED: + case EVENT_TYPE_MOUSE_ENTERED: + case EVENT_TYPE_MOUSE_EXITED: { const gfx::PointF location(TypeConverter<PointPtr, gfx::Point>::ConvertTo( input->location)); // TODO: last flags isn't right. Need to send changed_flags. ui_event.reset(new ui::MouseEvent( - static_cast<ui::EventType>(input->action), + ui_event_type, location, location, - input->flags, - input->flags)); + ui::EventFlags(input->flags), + ui::EventFlags(input->flags))); break; } - case ui::ET_MOUSEWHEEL: { + case EVENT_TYPE_MOUSEWHEEL: { const gfx::PointF location(TypeConverter<PointPtr, gfx::Point>::ConvertTo( input->location)); const gfx::Vector2d offset(input->wheel_data->x_offset, @@ -94,19 +175,19 @@ TypeConverter<EventPtr, scoped_ptr<ui::Event> >::ConvertTo( ui_event.reset(new ui::MouseWheelEvent(offset, location, location, - input->flags, - input->flags)); + ui::EventFlags(input->flags), + ui::EventFlags(input->flags))); break; } - case ui::ET_TOUCH_MOVED: - case ui::ET_TOUCH_PRESSED: - case ui::ET_TOUCH_CANCELLED: - case ui::ET_TOUCH_RELEASED: { + case EVENT_TYPE_TOUCH_MOVED: + case EVENT_TYPE_TOUCH_PRESSED: + case EVENT_TYPE_TOUCH_CANCELLED: + case EVENT_TYPE_TOUCH_RELEASED: { gfx::Point location(input->location->x, input->location->y); ui_event.reset(new ui::TouchEvent( - static_cast<ui::EventType>(input->action), + ui_event_type, location, - input->flags, + ui::EventFlags(input->flags), input->touch_data->pointer_id, base::TimeDelta::FromInternalValue(input->time_stamp), 0.f, 0.f, 0.f, 0.f)); diff --git a/mojo/services/public/interfaces/input_events/input_events.mojom b/mojo/services/public/interfaces/input_events/input_events.mojom index 850d26b..ce7df84 100644 --- a/mojo/services/public/interfaces/input_events/input_events.mojom +++ b/mojo/services/public/interfaces/input_events/input_events.mojom @@ -20,9 +20,73 @@ struct MouseWheelData { int32 y_offset; }; +// This mirrors ui::EventType +enum EventType { + UNKNOWN , + MOUSE_PRESSED, + MOUSE_DRAGGED, + MOUSE_RELEASED, + MOUSE_MOVED, + MOUSE_ENTERED, + MOUSE_EXITED, + KEY_PRESSED, + KEY_RELEASED, + MOUSEWHEEL, + MOUSE_CAPTURE_CHANGED, + TOUCH_RELEASED, + TOUCH_PRESSED, + TOUCH_MOVED, + TOUCH_CANCELLED, + DROP_TARGET_EVENT, + TRANSLATED_KEY_PRESS, + TRANSLATED_KEY_RELEASE, + GESTURE_SCROLL_BEGIN, + GESTURE_SCROLL_END, + GESTURE_SCROLL_UPDATE, + GESTURE_TAP, + GESTURE_TAP_DOWN, + GESTURE_TAP_CANCEL, + GESTURE_TAP_UNCONFIRMED, + GESTURE_DOUBLE_TAP, + GESTURE_BEGIN, + GESTURE_END, + GESTURE_TWO_FINGER_TAP, + GESTURE_PINCH_BEGIN, + GESTURE_PINCH_END, + GESTURE_PINCH_UPDATE, + GESTURE_LONG_PRESS, + GESTURE_LONG_TAP, + GESTURE_SWIPE, + GESTURE_SHOW_PRESS, + GESTURE_WIN8_EDGE_SWIPE, + SCROLL, + SCROLL_FLING_START, + SCROLL_FLING_CANCEL, + CANCEL_MODE, + UMA_DATA +}; + +// This mirrors ui::EventFlags +// TODO(morrita): Use shift operator once it is available. +enum EventFlags { + NONE = 0, + CAPS_LOCK_DOWN = 1, + SHIFT_DOWN = 2, + CONTROL_DOWN = 4, + ALT_DOWN = 8, + LEFT_MOUSE_BUTTON = 16, + MIDDLE_MOUSE_BUTTON = 32, + RIGHT_MOUSE_BUTTON = 64, + COMMAND_DOWN = 128, + EXTENDED = 256, + IS_SYNTHESIZED = 512, + ALTGR_DOWN = 1024, + MOD3_DOWN = 2048 +}; + struct Event { - int32 action; - int32 flags; + EventType action; + EventFlags flags; int64 time_stamp; Point location; KeyData key_data; diff --git a/mojo/services/view_manager/view_manager_unittest.cc b/mojo/services/view_manager/view_manager_unittest.cc index f0aa211..b2822a5 100644 --- a/mojo/services/view_manager/view_manager_unittest.cc +++ b/mojo/services/view_manager/view_manager_unittest.cc @@ -1279,7 +1279,7 @@ TEST_F(ViewManagerTest, OnViewInput) { // Dispatch an event to the view and verify its received. { EventPtr event(Event::New()); - event->action = 1; + event->action = static_cast<EventType>(1); connection_->view_manager()->DispatchOnViewInputEvent( BuildViewId(2, 11), event.Pass()); |