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/cpp/input_event.h" | 7 #include "ppapi/cpp/input_event.h" |
8 #include "ppapi/cpp/point.h" | 8 #include "ppapi/cpp/point.h" |
9 #include "remoting/client/plugin/pepper_view_proxy.h" | 9 #include "remoting/client/plugin/pepper_view_proxy.h" |
10 | 10 |
11 namespace remoting { | 11 namespace remoting { |
12 | 12 |
13 using pp::KeyboardInputEvent; | |
14 using pp::MouseInputEvent; | |
15 using protocol::KeyEvent; | |
16 using protocol::MouseEvent; | 13 using protocol::MouseEvent; |
17 | 14 |
18 PepperInputHandler::PepperInputHandler(ClientContext* context, | 15 PepperInputHandler::PepperInputHandler(ClientContext* context, |
19 protocol::ConnectionToHost* connection, | 16 protocol::ConnectionToHost* connection, |
20 PepperViewProxy* view) | 17 PepperViewProxy* view) |
21 : InputHandler(context, connection, view), | 18 : InputHandler(context, connection, view), |
22 pepper_view_(view) { | 19 pepper_view_(view), |
20 wheel_ticks_x_(0), | |
21 wheel_ticks_y_(0) { | |
23 } | 22 } |
24 | 23 |
25 PepperInputHandler::~PepperInputHandler() { | 24 PepperInputHandler::~PepperInputHandler() { |
26 } | 25 } |
27 | 26 |
28 void PepperInputHandler::Initialize() { | 27 void PepperInputHandler::Initialize() { |
29 } | 28 } |
30 | 29 |
31 void PepperInputHandler::HandleKeyEvent(bool keydown, | 30 void PepperInputHandler::HandleKeyEvent(bool keydown, |
32 const pp::KeyboardInputEvent& event) { | 31 const pp::KeyboardInputEvent& event) { |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
71 case PP_INPUTEVENT_MOUSEBUTTON_NONE: | 70 case PP_INPUTEVENT_MOUSEBUTTON_NONE: |
72 // Leave button undefined. | 71 // Leave button undefined. |
73 break; | 72 break; |
74 } | 73 } |
75 | 74 |
76 if (button != MouseEvent::BUTTON_UNDEFINED) { | 75 if (button != MouseEvent::BUTTON_UNDEFINED) { |
77 SendMouseButtonEvent(button_down, button); | 76 SendMouseButtonEvent(button_down, button); |
78 } | 77 } |
79 } | 78 } |
80 | 79 |
80 void PepperInputHandler::HandleMouseWheelEvent( | |
81 const pp::WheelInputEvent& event) { | |
82 pp::FloatPoint ticks = event.GetTicks(); | |
Lambros
2011/10/14 21:00:25
Can GetTicks() be negative? You seem to have code
Lambros
2011/10/14 21:08:45
Sorry, ignore my comment. static_cast<int> does r
| |
83 wheel_ticks_x_ += ticks.x(); | |
84 wheel_ticks_y_ += ticks.y(); | |
85 int ticks_x = static_cast<int>(wheel_ticks_x_); | |
86 int ticks_y = static_cast<int>(wheel_ticks_y_); | |
87 if (ticks_x != 0 || ticks_y != 0) { | |
88 wheel_ticks_x_ -= ticks_x; | |
89 wheel_ticks_y_ -= ticks_y; | |
90 SendMouseWheelEvent(ticks_x, ticks_y); | |
91 } | |
92 } | |
93 | |
81 } // namespace remoting | 94 } // namespace remoting |
OLD | NEW |