OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "remoting/client/plugin/pepper_input_handler.h" | 5 #include "remoting/client/plugin/pepper_input_handler.h" |
6 | 6 |
7 #include "ppapi/c/pp_input_event.h" | 7 #include "ppapi/cpp/input_event.h" |
8 #include "remoting/client/chromoting_view.h" | 8 #include "ppapi/cpp/point.h" |
9 #include "ui/gfx/point.h" | 9 #include "remoting/client/plugin/pepper_view_proxy.h" |
10 | 10 |
11 namespace remoting { | 11 namespace remoting { |
12 | 12 |
13 using protocol::KeyEvent; | 13 using protocol::KeyEvent; |
14 using protocol::MouseEvent; | 14 using protocol::MouseEvent; |
15 | 15 |
16 PepperInputHandler::PepperInputHandler(ClientContext* context, | 16 PepperInputHandler::PepperInputHandler(ClientContext* context, |
17 protocol::ConnectionToHost* connection, | 17 protocol::ConnectionToHost* connection, |
18 ChromotingView* view) | 18 ChromotingView* view) |
19 : InputHandler(context, connection, view) { | 19 : InputHandler(context, connection, view) { |
20 } | 20 } |
21 | 21 |
22 PepperInputHandler::~PepperInputHandler() { | 22 PepperInputHandler::~PepperInputHandler() { |
23 } | 23 } |
24 | 24 |
25 void PepperInputHandler::Initialize() { | 25 void PepperInputHandler::Initialize() { |
26 } | 26 } |
27 | 27 |
28 void PepperInputHandler::HandleKeyEvent(bool keydown, | 28 void PepperInputHandler::HandleKeyEvent(bool keydown, |
29 const PP_InputEvent_Key& event) { | 29 const pp::KeyboardInputEvent& event) { |
30 SendKeyEvent(keydown, event.key_code); | 30 SendKeyEvent(keydown, event.GetKeyCode()); |
31 } | 31 } |
32 | 32 |
33 void PepperInputHandler::HandleCharacterEvent( | 33 void PepperInputHandler::HandleCharacterEvent( |
34 const PP_InputEvent_Character& event) { | 34 const pp::KeyboardInputEvent& event) { |
35 // TODO(garykac): Coordinate key and char events. | 35 // TODO(garykac): Coordinate key and char events. |
36 } | 36 } |
37 | 37 |
38 void PepperInputHandler::HandleMouseMoveEvent( | 38 void PepperInputHandler::HandleMouseMoveEvent( |
39 const PP_InputEvent_Mouse& event) { | 39 const pp::MouseInputEvent& event) { |
40 gfx::Point p(static_cast<int>(event.x), static_cast<int>(event.y)); | |
41 // Pepper gives co-ordinates in the plugin instance's co-ordinate system, | 40 // Pepper gives co-ordinates in the plugin instance's co-ordinate system, |
42 // which may be different from the host desktop's co-ordinate system. | 41 // which may be different from the host desktop's co-ordinate system. |
43 p = view_->ConvertScreenToHost(p); | 42 PepperViewProxy* pepper_view = static_cast<PepperViewProxy*>(view_); |
43 pp::Point p = pepper_view->ConvertScreenToHost(event.GetMousePosition()); | |
Wez
2011/07/20 00:58:35
ConvertScreenToHost accepts & returns a gfx::Point
garykac
2011/07/20 18:55:28
err.. not any more.
| |
44 SendMouseMoveEvent(p.x(), p.y()); | 44 SendMouseMoveEvent(p.x(), p.y()); |
45 } | 45 } |
46 | 46 |
47 void PepperInputHandler::HandleMouseButtonEvent( | 47 void PepperInputHandler::HandleMouseButtonEvent( |
48 bool button_down, | 48 bool button_down, |
49 const PP_InputEvent_Mouse& event) { | 49 const pp::MouseInputEvent& event) { |
50 MouseEvent::MouseButton button = MouseEvent::BUTTON_UNDEFINED; | 50 MouseEvent::MouseButton button = MouseEvent::BUTTON_UNDEFINED; |
51 if (event.button == PP_INPUTEVENT_MOUSEBUTTON_LEFT) { | 51 if (event.GetMouseButton() == PP_INPUTEVENT_MOUSEBUTTON_LEFT) { |
dmac
2011/07/20 00:34:31
Would a switch on event.GetMouseButton() be more r
Wez
2011/07/20 00:58:35
Although we still need to cope with cases we don't
garykac
2011/07/20 18:55:28
Done.
garykac
2011/07/20 18:55:28
word
| |
52 button = MouseEvent::BUTTON_LEFT; | 52 button = MouseEvent::BUTTON_LEFT; |
53 } else if (event.button == PP_INPUTEVENT_MOUSEBUTTON_MIDDLE) { | 53 } else if (event.GetMouseButton() == PP_INPUTEVENT_MOUSEBUTTON_MIDDLE) { |
54 button = MouseEvent::BUTTON_MIDDLE; | 54 button = MouseEvent::BUTTON_MIDDLE; |
55 } else if (event.button == PP_INPUTEVENT_MOUSEBUTTON_RIGHT) { | 55 } else if (event.GetMouseButton() == PP_INPUTEVENT_MOUSEBUTTON_RIGHT) { |
56 button = MouseEvent::BUTTON_RIGHT; | 56 button = MouseEvent::BUTTON_RIGHT; |
57 } | 57 } |
58 | 58 |
59 if (button != MouseEvent::BUTTON_UNDEFINED) { | 59 if (button != MouseEvent::BUTTON_UNDEFINED) { |
60 SendMouseButtonEvent(button_down, button); | 60 SendMouseButtonEvent(button_down, button); |
61 } | 61 } |
62 } | 62 } |
63 | 63 |
64 } // namespace remoting | 64 } // namespace remoting |
OLD | NEW |