| 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/host/event_executor_linux.h" | 5 #include "remoting/host/event_executor_linux.h" |
| 6 | 6 |
| 7 #include <X11/Xlib.h> | 7 #include <X11/Xlib.h> |
| 8 #include <X11/keysym.h> | 8 #include <X11/keysym.h> |
| 9 #include <X11/extensions/XTest.h> | 9 #include <X11/extensions/XTest.h> |
| 10 | 10 |
| 11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "base/message_loop.h" | 12 #include "base/message_loop.h" |
| 13 #include "base/task.h" | 13 #include "base/task.h" |
| 14 #include "remoting/proto/internal.pb.h" | 14 #include "remoting/proto/internal.pb.h" |
| 15 | 15 |
| 16 namespace remoting { | 16 namespace remoting { |
| 17 | 17 |
| 18 static int MouseButtonToX11ButtonNumber(MouseButton button) { | 18 using protocol::MouseEvent; |
| 19 using protocol::KeyEvent; |
| 20 |
| 21 static int MouseButtonToX11ButtonNumber( |
| 22 protocol::MouseEvent::MouseButton button) { |
| 19 switch (button) { | 23 switch (button) { |
| 20 case MouseButtonLeft: | 24 case MouseEvent::BUTTON_LEFT: |
| 21 return 1; | 25 return 1; |
| 22 | 26 |
| 23 case MouseButtonRight: | 27 case MouseEvent::BUTTON_RIGHT: |
| 24 return 2; | 28 return 2; |
| 25 | 29 |
| 26 case MouseButtonMiddle: | 30 case MouseEvent::BUTTON_MIDDLE: |
| 27 return 3; | 31 return 3; |
| 28 | 32 |
| 29 case MouseButtonUndefined: | 33 case MouseEvent::BUTTON_UNDEFINED: |
| 30 default: | 34 default: |
| 31 return -1; | 35 return -1; |
| 32 } | 36 } |
| 33 } | 37 } |
| 34 | 38 |
| 35 // TODO(ajwong): Move this to a central keycodes translation file. | 39 // TODO(ajwong): Move this to a central keycodes translation file. |
| 36 const int kPepperToX11Keysym[256] = { | 40 const int kPepperToX11Keysym[256] = { |
| 37 // 0x00 - 0x07 | 41 // 0x00 - 0x07 |
| 38 -1, -1, -1, -1, | 42 -1, -1, -1, -1, |
| 39 // 0x04 - 0x07 | 43 // 0x04 - 0x07 |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 195 | 199 |
| 196 return kPepperToX11Keysym[keycode]; | 200 return kPepperToX11Keysym[keycode]; |
| 197 } | 201 } |
| 198 | 202 |
| 199 class EventExecutorLinuxPimpl { | 203 class EventExecutorLinuxPimpl { |
| 200 public: | 204 public: |
| 201 explicit EventExecutorLinuxPimpl(EventExecutorLinux* executor); | 205 explicit EventExecutorLinuxPimpl(EventExecutorLinux* executor); |
| 202 ~EventExecutorLinuxPimpl(); | 206 ~EventExecutorLinuxPimpl(); |
| 203 | 207 |
| 204 bool Init(); // TODO(ajwong): Do we really want this to be synchronous? | 208 bool Init(); // TODO(ajwong): Do we really want this to be synchronous? |
| 209 |
| 205 void HandleMouse(const MouseEvent* message); | 210 void HandleMouse(const MouseEvent* message); |
| 206 void HandleKey(const KeyEvent* key_event); | 211 void HandleKey(const KeyEvent* key_event); |
| 207 | 212 |
| 208 private: | 213 private: |
| 209 void DeinitXlib(); | 214 void DeinitXlib(); |
| 210 | 215 |
| 211 // Reference to containing class so we can access friend functions. | 216 // Reference to containing class so we can access friend functions. |
| 212 // Not owned. | 217 // Not owned. |
| 213 EventExecutorLinux* executor_; | 218 EventExecutorLinux* executor_; |
| 214 | 219 |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 399 done->Run(); | 404 done->Run(); |
| 400 delete done; | 405 delete done; |
| 401 } | 406 } |
| 402 | 407 |
| 403 protocol::InputStub* CreateEventExecutor(MessageLoop* message_loop, | 408 protocol::InputStub* CreateEventExecutor(MessageLoop* message_loop, |
| 404 Capturer* capturer) { | 409 Capturer* capturer) { |
| 405 return new EventExecutorLinux(message_loop, capturer); | 410 return new EventExecutorLinux(message_loop, capturer); |
| 406 } | 411 } |
| 407 | 412 |
| 408 } // namespace remoting | 413 } // namespace remoting |
| OLD | NEW |