Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(200)

Unified Diff: remoting/client/plugin/pepper_input_handler.cc

Issue 8985007: Refactoring of the client-side input pipeline and scaling dimension management. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 1fe6f6e543636ef8f19e70954a9797661fa6a28e..3857c56a25579e7e5901d82794b890eac94a3da7 100644
--- a/remoting/client/plugin/pepper_input_handler.cc
+++ b/remoting/client/plugin/pepper_input_handler.cc
@@ -4,39 +4,105 @@
#include "remoting/client/plugin/pepper_input_handler.h"
+#include "base/logging.h"
#include "ppapi/cpp/input_event.h"
#include "ppapi/cpp/point.h"
-#include "remoting/client/plugin/pepper_view_proxy.h"
+#include "remoting/proto/event.pb.h"
namespace remoting {
-using protocol::MouseEvent;
-
-PepperInputHandler::PepperInputHandler(ClientContext* context,
- protocol::ConnectionToHost* connection,
- PepperViewProxy* view)
- : InputHandler(context, connection, view),
- pepper_view_(view),
- wheel_ticks_x_(0),
- wheel_ticks_y_(0) {
+PepperInputHandler::PepperInputHandler(protocol::InputStub* input_stub)
+ : input_stub_(input_stub), wheel_ticks_x_(0), wheel_ticks_y_(0)
+{
}
PepperInputHandler::~PepperInputHandler() {
}
-void PepperInputHandler::Initialize() {
-}
-
-void PepperInputHandler::HandleKeyEvent(bool keydown,
- const pp::KeyboardInputEvent& event) {
- SendKeyEvent(keydown, event.GetKeyCode());
-}
+bool PepperInputHandler::HandleInputEvent(const pp::InputEvent& event) {
+ switch (event.GetType()) {
+ 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.
+ return true;
+ }
+
+ case PP_INPUTEVENT_TYPE_KEYDOWN:
+ case PP_INPUTEVENT_TYPE_KEYUP: {
+ pp::KeyboardInputEvent pp_key_event(event);
+ protocol::KeyEvent key_event;
+ key_event.set_keycode(pp_key_event.GetKeyCode());
+ key_event.set_pressed(event.GetType() == PP_INPUTEVENT_TYPE_KEYDOWN);
+ input_stub_->InjectKeyEvent(key_event);
+ return true;
+ }
+
+ case PP_INPUTEVENT_TYPE_MOUSEDOWN:
+ case PP_INPUTEVENT_TYPE_MOUSEUP: {
+ pp::MouseInputEvent pp_mouse_event(event);
+ protocol::MouseEvent mouse_event;
+ switch (pp_mouse_event.GetButton()) {
+ case PP_INPUTEVENT_MOUSEBUTTON_LEFT:
+ mouse_event.set_button(protocol::MouseEvent::BUTTON_LEFT);
+ break;
+ case PP_INPUTEVENT_MOUSEBUTTON_MIDDLE:
+ mouse_event.set_button(protocol::MouseEvent::BUTTON_MIDDLE);
+ break;
+ case PP_INPUTEVENT_MOUSEBUTTON_RIGHT:
+ mouse_event.set_button(protocol::MouseEvent::BUTTON_RIGHT);
+ break;
+ case PP_INPUTEVENT_MOUSEBUTTON_NONE:
+ break;
+ }
+ if (mouse_event.has_button()) {
+ bool is_down = (event.GetType() == PP_INPUTEVENT_TYPE_MOUSEDOWN);
+ mouse_event.set_button_down(is_down);
+ input_stub_->InjectMouseEvent(mouse_event);
+ }
+ return true;
+ }
+
+ case PP_INPUTEVENT_TYPE_MOUSEMOVE:
+ case PP_INPUTEVENT_TYPE_MOUSEENTER:
+ case PP_INPUTEVENT_TYPE_MOUSELEAVE: {
+ pp::MouseInputEvent pp_mouse_event(event);
+ protocol::MouseEvent mouse_event;
+ mouse_event.set_x(pp_mouse_event.GetPosition().x());
+ mouse_event.set_y(pp_mouse_event.GetPosition().y());
+ input_stub_->InjectMouseEvent(mouse_event);
+ return true;
+ }
+
+ case PP_INPUTEVENT_TYPE_WHEEL: {
+ pp::WheelInputEvent pp_wheel_event(event);
+
+ pp::FloatPoint ticks = pp_wheel_event.GetTicks();
+ wheel_ticks_x_ += ticks.x();
+ wheel_ticks_y_ += ticks.y();
+
+ int ticks_x = static_cast<int>(wheel_ticks_x_);
+ int ticks_y = static_cast<int>(wheel_ticks_y_);
+ if (ticks_x != 0 || ticks_y != 0) {
+ wheel_ticks_x_ -= ticks_x;
+ wheel_ticks_y_ -= ticks_y;
+ protocol::MouseEvent mouse_event;
+ mouse_event.set_wheel_offset_x(wheel_ticks_x_);
+ mouse_event.set_wheel_offset_y(wheel_ticks_y_);
+ input_stub_->InjectMouseEvent(mouse_event);
+ }
+ return true;
+ }
+
+ default: {
+ LOG(INFO) << "Unhandled input event: " << event.GetType();
+ break;
+ }
+ }
-void PepperInputHandler::HandleCharacterEvent(
- const pp::KeyboardInputEvent& event) {
- // TODO(garykac): Coordinate key and char events.
+ return false;
}
+#if 0
Sergey Ulanov 2011/12/20 00:05:35 Remove this code?
Wez 2011/12/20 07:14:14 Done.
void PepperInputHandler::HandleMouseMoveEvent(
const pp::MouseInputEvent& event) {
SkIPoint p(SkIPoint::Make(event.GetPosition().x(), event.GetPosition().y()));
@@ -52,43 +118,6 @@ void PepperInputHandler::HandleMouseMoveEvent(
SendMouseMoveEvent(p.x() / horizontal_ratio, p.y() / vertical_ratio);
}
-
-void PepperInputHandler::HandleMouseButtonEvent(
- bool button_down,
- const pp::MouseInputEvent& event) {
- MouseEvent::MouseButton button = MouseEvent::BUTTON_UNDEFINED;
- switch (event.GetButton()) {
- case PP_INPUTEVENT_MOUSEBUTTON_LEFT:
- button = MouseEvent::BUTTON_LEFT;
- break;
- case PP_INPUTEVENT_MOUSEBUTTON_MIDDLE:
- button = MouseEvent::BUTTON_MIDDLE;
- break;
- case PP_INPUTEVENT_MOUSEBUTTON_RIGHT:
- button = MouseEvent::BUTTON_RIGHT;
- break;
- case PP_INPUTEVENT_MOUSEBUTTON_NONE:
- // Leave button undefined.
- break;
- }
-
- if (button != MouseEvent::BUTTON_UNDEFINED) {
- SendMouseButtonEvent(button_down, button);
- }
-}
-
-void PepperInputHandler::HandleMouseWheelEvent(
- const pp::WheelInputEvent& event) {
- pp::FloatPoint ticks = event.GetTicks();
- wheel_ticks_x_ += ticks.x();
- wheel_ticks_y_ += ticks.y();
- int ticks_x = static_cast<int>(wheel_ticks_x_);
- int ticks_y = static_cast<int>(wheel_ticks_y_);
- if (ticks_x != 0 || ticks_y != 0) {
- wheel_ticks_x_ -= ticks_x;
- wheel_ticks_y_ -= ticks_y;
- SendMouseWheelEvent(ticks_x, ticks_y);
- }
-}
+#endif
} // namespace remoting

Powered by Google App Engine
This is Rietveld 408576698