| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/input_handler.h" | 5 #include "remoting/client/input_handler.h" |
| 6 | 6 |
| 7 #include "remoting/client/chromoting_view.h" | 7 #include "remoting/client/chromoting_view.h" |
| 8 #include "remoting/proto/event.pb.h" | 8 #include "remoting/proto/event.pb.h" |
| 9 #include "remoting/protocol/connection_to_host.h" | 9 #include "remoting/protocol/connection_to_host.h" |
| 10 | 10 |
| 11 namespace remoting { | 11 namespace remoting { |
| 12 | 12 |
| 13 using protocol::KeyEvent; |
| 14 using protocol::MouseEvent; |
| 15 |
| 13 InputHandler::InputHandler(ClientContext* context, | 16 InputHandler::InputHandler(ClientContext* context, |
| 14 protocol::ConnectionToHost* connection, | 17 protocol::ConnectionToHost* connection, |
| 15 ChromotingView* view) | 18 ChromotingView* view) |
| 16 : context_(context), | 19 : context_(context), |
| 17 connection_(connection), | 20 connection_(connection), |
| 18 view_(view) { | 21 view_(view) { |
| 19 } | 22 } |
| 20 | 23 |
| 21 void InputHandler::SendKeyEvent(bool press, int keycode) { | 24 void InputHandler::SendKeyEvent(bool press, int keycode) { |
| 22 KeyEvent* event = new KeyEvent(); | 25 KeyEvent* event = new KeyEvent(); |
| 23 event->set_key(keycode); | 26 event->set_key(keycode); |
| 24 event->set_pressed(press); | 27 event->set_pressed(press); |
| 25 | 28 |
| 26 protocol::InputStub* stub = connection_->input_stub(); | 29 protocol::InputStub* stub = connection_->input_stub(); |
| 27 stub->InjectKeyEvent(event, new DeleteTask<KeyEvent>(event)); | 30 stub->InjectKeyEvent(event, new DeleteTask<KeyEvent>(event)); |
| 28 } | 31 } |
| 29 | 32 |
| 30 void InputHandler::SendMouseMoveEvent(int x, int y) { | 33 void InputHandler::SendMouseMoveEvent(int x, int y) { |
| 31 MouseEvent* event = new MouseEvent(); | 34 MouseEvent* event = new MouseEvent(); |
| 32 event->set_x(x); | 35 event->set_x(x); |
| 33 event->set_y(y); | 36 event->set_y(y); |
| 34 | 37 |
| 35 protocol::InputStub* stub = connection_->input_stub(); | 38 protocol::InputStub* stub = connection_->input_stub(); |
| 36 stub->InjectMouseEvent(event, new DeleteTask<MouseEvent>(event)); | 39 stub->InjectMouseEvent(event, new DeleteTask<MouseEvent>(event)); |
| 37 } | 40 } |
| 38 | 41 |
| 39 void InputHandler::SendMouseButtonEvent(bool button_down, | 42 void InputHandler::SendMouseButtonEvent(bool button_down, |
| 40 MouseButton button) { | 43 MouseEvent::MouseButton button) { |
| 41 MouseEvent* event = new MouseEvent(); | 44 MouseEvent* event = new MouseEvent(); |
| 42 event->set_button(button); | 45 event->set_button(button); |
| 43 event->set_button_down(button_down); | 46 event->set_button_down(button_down); |
| 44 | 47 |
| 45 protocol::InputStub* stub = connection_->input_stub(); | 48 protocol::InputStub* stub = connection_->input_stub(); |
| 46 stub->InjectMouseEvent(event, new DeleteTask<MouseEvent>(event)); | 49 stub->InjectMouseEvent(event, new DeleteTask<MouseEvent>(event)); |
| 47 } | 50 } |
| 48 | 51 |
| 49 } // namespace remoting | 52 } // namespace remoting |
| OLD | NEW |