diff options
author | garykac@chromium.org <garykac@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-09-07 21:42:43 +0000 |
---|---|---|
committer | garykac@chromium.org <garykac@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-09-07 21:42:43 +0000 |
commit | c073282650b32fc28aa93124d11c1fee579d79da (patch) | |
tree | ef2bc69ff0eeaba57f45f89194df29783f9af185 | |
parent | 4f62f65655d12df9d111f7dc2ed6fbcadf252d7f (diff) | |
download | chromium_src-c073282650b32fc28aa93124d11c1fee579d79da.zip chromium_src-c073282650b32fc28aa93124d11c1fee579d79da.tar.gz chromium_src-c073282650b32fc28aa93124d11c1fee579d79da.tar.bz2 |
Add mouse/keyboard event support to Chromoting client (Pepper and X11).
BUG=50247
TEST=none
Review URL: http://codereview.chromium.org/3341005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@58761 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | remoting/client/input_handler.cc | 10 | ||||
-rw-r--r-- | remoting/client/input_handler.h | 1 | ||||
-rw-r--r-- | remoting/client/plugin/chromoting_instance.cc | 16 | ||||
-rw-r--r-- | remoting/client/plugin/pepper_input_handler.cc | 9 | ||||
-rw-r--r-- | remoting/client/plugin/pepper_input_handler.h | 3 | ||||
-rw-r--r-- | remoting/client/x11_input_handler.cc | 12 | ||||
-rw-r--r-- | remoting/client/x11_input_handler.h | 4 |
7 files changed, 49 insertions, 6 deletions
diff --git a/remoting/client/input_handler.cc b/remoting/client/input_handler.cc index dd0fd7a..7f6f7ab 100644 --- a/remoting/client/input_handler.cc +++ b/remoting/client/input_handler.cc @@ -20,6 +20,16 @@ InputHandler::InputHandler(ClientContext* context, mouse_y_(0) { } +void InputHandler::SendKeyEvent(bool press, int keycode) { + ChromotingClientMessage msg; + + KeyEvent *event = msg.mutable_key_event(); + event->set_key(keycode); + event->set_pressed(press); + + connection_->SendEvent(msg); +} + void InputHandler::SendMouseMoveEvent(int x, int y) { ChromotingClientMessage msg; diff --git a/remoting/client/input_handler.h b/remoting/client/input_handler.h index ef9659d..61b9bb9 100644 --- a/remoting/client/input_handler.h +++ b/remoting/client/input_handler.h @@ -25,6 +25,7 @@ class InputHandler { virtual void Initialize() = 0; protected: + void SendKeyEvent(bool press, int keycode); void SendMouseMoveEvent(int x, int y); void SendMouseButtonEvent(bool down, MouseButton button); diff --git a/remoting/client/plugin/chromoting_instance.cc b/remoting/client/plugin/chromoting_instance.cc index edde1f3..71f3563 100644 --- a/remoting/client/plugin/chromoting_instance.cc +++ b/remoting/client/plugin/chromoting_instance.cc @@ -121,20 +121,26 @@ bool ChromotingInstance::HandleEvent(const PP_Event& event) { switch (event.type) { case PP_EVENT_TYPE_MOUSEDOWN: pih->HandleMouseButtonEvent(true, event.u.mouse); - break; + return true; + case PP_EVENT_TYPE_MOUSEUP: pih->HandleMouseButtonEvent(false, event.u.mouse); - break; + return true; + case PP_EVENT_TYPE_MOUSEMOVE: case PP_EVENT_TYPE_MOUSEENTER: case PP_EVENT_TYPE_MOUSELEAVE: pih->HandleMouseMoveEvent(event.u.mouse); - break; + return true; case PP_EVENT_TYPE_KEYDOWN: + case PP_EVENT_TYPE_KEYUP: + pih->HandleKeyEvent(event.type == PP_EVENT_TYPE_KEYDOWN, event.u.key); + return true; + case PP_EVENT_TYPE_CHAR: - // client_->handle_char_event(npevent); - break; + pih->HandleCharacterEvent(event.u.character); + return true; default: break; diff --git a/remoting/client/plugin/pepper_input_handler.cc b/remoting/client/plugin/pepper_input_handler.cc index 40f299e..2ba1603 100644 --- a/remoting/client/plugin/pepper_input_handler.cc +++ b/remoting/client/plugin/pepper_input_handler.cc @@ -18,6 +18,15 @@ PepperInputHandler::~PepperInputHandler() { void PepperInputHandler::Initialize() { } +void PepperInputHandler::HandleKeyEvent(bool keydown, + const PP_Event_Key& event) { + SendKeyEvent(keydown, event.normalizedKeyCode); +} + +void PepperInputHandler::HandleCharacterEvent(const PP_Event_Character& event) { + // TODO(garykac): Coordinate key and char events. +} + void PepperInputHandler::HandleMouseMoveEvent(const PP_Event_Mouse& event) { SendMouseMoveEvent(static_cast<int>(event.x), static_cast<int>(event.y)); diff --git a/remoting/client/plugin/pepper_input_handler.h b/remoting/client/plugin/pepper_input_handler.h index 385cb8a..dd2a76e 100644 --- a/remoting/client/plugin/pepper_input_handler.h +++ b/remoting/client/plugin/pepper_input_handler.h @@ -20,6 +20,9 @@ class PepperInputHandler : public InputHandler { void Initialize(); + void HandleKeyEvent(bool keydown, const PP_Event_Key& event); + void HandleCharacterEvent(const PP_Event_Character& event); + void HandleMouseMoveEvent(const PP_Event_Mouse& event); void HandleMouseButtonEvent(bool button_down, const PP_Event_Mouse& event); diff --git a/remoting/client/x11_input_handler.cc b/remoting/client/x11_input_handler.cc index f7900ca..bd63af9 100644 --- a/remoting/client/x11_input_handler.cc +++ b/remoting/client/x11_input_handler.cc @@ -12,6 +12,7 @@ // Include Xlib at the end because it clashes with Status in // base/tracked_objects.h. #include <X11/Xlib.h> +#include <X11/Xutil.h> namespace remoting { @@ -42,7 +43,7 @@ void X11InputHandler::DoProcessX11Events() { break; case KeyPress: case KeyRelease: - // TODO(garykac) Implement. + HandleKeyEvent(&e); break; case ButtonPress: HandleMouseButtonEvent(true, e.xbutton.button); @@ -73,6 +74,15 @@ void X11InputHandler::ScheduleX11EventHandler() { kProcessEventsInterval); } +void X11InputHandler::HandleKeyEvent(void* event) { + XEvent* e = reinterpret_cast<XEvent*>(event); + char buffer[128]; + int buffsize = sizeof(buffer) - 1; + KeySym keysym; + XLookupString(&e->xkey, buffer, buffsize, &keysym, NULL); + SendKeyEvent(e->type == KeyPress, static_cast<int>(keysym)); +} + void X11InputHandler::HandleMouseMoveEvent(int x, int y) { SendMouseMoveEvent(x, y); } diff --git a/remoting/client/x11_input_handler.h b/remoting/client/x11_input_handler.h index eedaf54..e84e4b9 100644 --- a/remoting/client/x11_input_handler.h +++ b/remoting/client/x11_input_handler.h @@ -27,6 +27,10 @@ class X11InputHandler : public InputHandler { void ScheduleX11EventHandler(); + // This is really an XEvent, but if we include Xlib.h in this file, it will + // cause conflicts with other headers. See note at top of + // x11_input_handler.cc. + void HandleKeyEvent(void* event); void HandleMouseMoveEvent(int x, int y); void HandleMouseButtonEvent(bool button_down, int xbutton_id); |