| 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/x11_input_handler.h" | 5 #include "remoting/client/x11_input_handler.h" |
| 6 | 6 |
| 7 #include "base/message_loop.h" | 7 #include "base/message_loop.h" |
| 8 #include "remoting/client/client_context.h" | 8 #include "remoting/client/client_context.h" |
| 9 #include "remoting/client/x11_view.h" | 9 #include "remoting/client/x11_view.h" |
| 10 #include "remoting/jingle_glue/jingle_thread.h" | 10 #include "remoting/jingle_glue/jingle_thread.h" |
| 11 | 11 |
| 12 // Include Xlib at the end because it clashes with Status in | 12 // Include Xlib at the end because it clashes with Status in |
| 13 // base/tracked_objects.h. | 13 // base/tracked_objects.h. |
| 14 #include <X11/Xlib.h> | 14 #include <X11/Xlib.h> |
| 15 #include <X11/Xutil.h> | 15 #include <X11/Xutil.h> |
| 16 | 16 |
| 17 namespace remoting { | 17 namespace remoting { |
| 18 | 18 |
| 19 using protocol::KeyEvent; |
| 20 using protocol::MouseEvent; |
| 21 |
| 19 X11InputHandler::X11InputHandler(ClientContext* context, | 22 X11InputHandler::X11InputHandler(ClientContext* context, |
| 20 protocol::ConnectionToHost* connection, | 23 protocol::ConnectionToHost* connection, |
| 21 ChromotingView* view) | 24 ChromotingView* view) |
| 22 : InputHandler(context, connection, view) { | 25 : InputHandler(context, connection, view) { |
| 23 } | 26 } |
| 24 | 27 |
| 25 X11InputHandler::~X11InputHandler() { | 28 X11InputHandler::~X11InputHandler() { |
| 26 } | 29 } |
| 27 | 30 |
| 28 void X11InputHandler::Initialize() { | 31 void X11InputHandler::Initialize() { |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 KeySym keysym; | 84 KeySym keysym; |
| 82 XLookupString(&e->xkey, buffer, buffsize, &keysym, NULL); | 85 XLookupString(&e->xkey, buffer, buffsize, &keysym, NULL); |
| 83 SendKeyEvent(e->type == KeyPress, static_cast<int>(keysym)); | 86 SendKeyEvent(e->type == KeyPress, static_cast<int>(keysym)); |
| 84 } | 87 } |
| 85 | 88 |
| 86 void X11InputHandler::HandleMouseMoveEvent(int x, int y) { | 89 void X11InputHandler::HandleMouseMoveEvent(int x, int y) { |
| 87 SendMouseMoveEvent(x, y); | 90 SendMouseMoveEvent(x, y); |
| 88 } | 91 } |
| 89 | 92 |
| 90 void X11InputHandler::HandleMouseButtonEvent(bool button_down, int xbutton_id) { | 93 void X11InputHandler::HandleMouseButtonEvent(bool button_down, int xbutton_id) { |
| 91 MouseButton button = MouseButtonUndefined; | 94 MouseEvent::MouseButton button = MouseEvent::BUTTON_UNDEFINED; |
| 92 if (xbutton_id == 1) { | 95 if (xbutton_id == 1) { |
| 93 button = MouseButtonLeft; | 96 button = MouseEvent::BUTTON_LEFT; |
| 94 } else if (xbutton_id == 2) { | 97 } else if (xbutton_id == 2) { |
| 95 button = MouseButtonMiddle; | 98 button = MouseEvent::BUTTON_MIDDLE; |
| 96 } else if (xbutton_id == 3) { | 99 } else if (xbutton_id == 3) { |
| 97 button = MouseButtonRight; | 100 button = MouseEvent::BUTTON_RIGHT; |
| 98 } | 101 } |
| 99 | 102 |
| 100 if (button != MouseButtonUndefined) { | 103 if (button != MouseEvent::BUTTON_UNDEFINED) { |
| 101 SendMouseButtonEvent(button_down, button); | 104 SendMouseButtonEvent(button_down, button); |
| 102 } | 105 } |
| 103 } | 106 } |
| 104 | 107 |
| 105 } // namespace remoting | 108 } // namespace remoting |
| OLD | NEW |