Chromium Code Reviews| Index: remoting/client/plugin/pepper_input_handler.cc |
| diff --git a/remoting/client/plugin/pepper_input_handler.cc b/remoting/client/plugin/pepper_input_handler.cc |
| index 157efe5eaba5253a699addc563c6799a95ae28d4..94b303dc7554d14770f5a00964830c34e887ed86 100644 |
| --- a/remoting/client/plugin/pepper_input_handler.cc |
| +++ b/remoting/client/plugin/pepper_input_handler.cc |
| @@ -10,6 +10,7 @@ |
| #include "ppapi/cpp/module_impl.h" |
| #include "ppapi/cpp/mouse_cursor.h" |
| #include "ppapi/cpp/point.h" |
| +#include "ppapi/cpp/touch_point.h" |
| #include "ppapi/cpp/var.h" |
| #include "remoting/proto/event.pb.h" |
| #include "ui/events/keycodes/dom4/keycode_converter.h" |
| @@ -32,6 +33,47 @@ uint32_t MakeLockStates(const pp::InputEvent& event) { |
| return lock_states; |
| } |
| +// Crates protocol::TouchEvent instance from |pp_touch_event|. |
|
Wez
2015/01/21 03:08:37
s/Creates/Creates
Rintaro Kuroiwa
2015/01/28 01:12:29
Done.
|
| +// Note that only the changed touches are added to the instance. |
|
Wez
2015/01/21 03:08:37
s/instance/TouchEvent
Rintaro Kuroiwa
2015/01/28 01:12:29
Done.
|
| +protocol::TouchEvent MakeTouchEvent(const pp::TouchInputEvent& pp_touch_event) { |
| + using protocol::TouchEvent; |
|
Wez
2015/01/21 03:08:37
nit: Blank line after this "using", since it's not
Rintaro Kuroiwa
2015/01/28 01:12:29
Not saving any lines, removing :)
|
| + TouchEvent touch_event; |
| + TouchEvent::Point::TouchPointEventType type; |
| + switch (pp_touch_event.GetType()) { |
| + case PP_INPUTEVENT_TYPE_TOUCHSTART: |
| + type = TouchEvent::Point::TOUCH_POINT_START; |
| + break; |
| + case PP_INPUTEVENT_TYPE_TOUCHMOVE: |
| + type = TouchEvent::Point::TOUCH_POINT_MOVE; |
| + break; |
| + case PP_INPUTEVENT_TYPE_TOUCHEND: |
| + type = TouchEvent::Point::TOUCH_POINT_END; |
| + break; |
| + case PP_INPUTEVENT_TYPE_TOUCHCANCEL: |
| + type = TouchEvent::Point::TOUCH_POINT_CANCEL; |
| + break; |
| + default: |
| + NOTIMPLEMENTED() << "Unknown event type: " << pp_touch_event.GetType(); |
| + return touch_event; |
| + } |
| + |
| + for (uint32_t i = 0; |
| + i < pp_touch_event.GetTouchCount(PP_TOUCHLIST_TYPE_CHANGEDTOUCHES); |
| + ++i) { |
| + pp::TouchPoint pp_point = |
| + pp_touch_event.GetTouchByIndex(PP_TOUCHLIST_TYPE_CHANGEDTOUCHES, i); |
| + TouchEvent::Point* point = touch_event.add_touch_points(); |
| + point->set_event_type(type); |
| + point->set_id(pp_point.id()); |
| + point->set_x(pp_point.position().x()); |
| + point->set_y(pp_point.position().y()); |
| + point->set_radius_x(pp_point.radii().x()); |
| + point->set_radius_y(pp_point.radii().y()); |
| + } |
| + |
| + return touch_event; |
| +} |
| + |
| // Builds a protocol::KeyEvent from the supplied PPAPI event. |
| protocol::KeyEvent MakeKeyEvent(const pp::KeyboardInputEvent& pp_key_event) { |
| protocol::KeyEvent key_event; |
| @@ -64,6 +106,7 @@ PepperInputHandler::PepperInputHandler() |
| has_focus_(false), |
| send_mouse_input_when_unfocused_(false), |
| send_mouse_move_deltas_(false), |
| + send_touch_events_(false), |
| wheel_delta_x_(0), |
| wheel_delta_y_(0), |
| wheel_ticks_x_(0), |
| @@ -72,6 +115,18 @@ PepperInputHandler::PepperInputHandler() |
| bool PepperInputHandler::HandleInputEvent(const pp::InputEvent& event) { |
| switch (event.GetType()) { |
| + // Touch input cases. |
| + case PP_INPUTEVENT_TYPE_TOUCHSTART: |
| + case PP_INPUTEVENT_TYPE_TOUCHMOVE: |
| + case PP_INPUTEVENT_TYPE_TOUCHEND: |
| + case PP_INPUTEVENT_TYPE_TOUCHCANCEL: { |
| + if (!send_touch_events_) |
| + return false; |
| + pp::TouchInputEvent pp_touch_event(event); |
| + input_stub_->InjectTouchEvent(MakeTouchEvent(pp_touch_event)); |
| + return true; |
| + } |
| + |
| case PP_INPUTEVENT_TYPE_CONTEXTMENU: { |
| // We need to return true here or else we'll get a local (plugin) context |
| // menu instead of the mouseup event for the right click. |