| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/input_injector.h" | 5 #include "remoting/host/input_injector.h" |
| 6 | 6 |
| 7 #include <X11/extensions/XInput.h> | 7 #include <X11/extensions/XInput.h> |
| 8 #include <X11/extensions/XTest.h> | 8 #include <X11/extensions/XTest.h> |
| 9 #include <X11/Xlib.h> | 9 #include <X11/Xlib.h> |
| 10 #include <X11/XKBlib.h> | 10 #include <X11/XKBlib.h> |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 #include "ui/events/keycodes/dom4/keycode_converter.h" | 28 #include "ui/events/keycodes/dom4/keycode_converter.h" |
| 29 | 29 |
| 30 namespace remoting { | 30 namespace remoting { |
| 31 | 31 |
| 32 namespace { | 32 namespace { |
| 33 | 33 |
| 34 using protocol::ClipboardEvent; | 34 using protocol::ClipboardEvent; |
| 35 using protocol::KeyEvent; | 35 using protocol::KeyEvent; |
| 36 using protocol::TextEvent; | 36 using protocol::TextEvent; |
| 37 using protocol::MouseEvent; | 37 using protocol::MouseEvent; |
| 38 using protocol::TouchEvent; |
| 38 | 39 |
| 39 bool FindKeycodeForKeySym(Display* display, | 40 bool FindKeycodeForKeySym(Display* display, |
| 40 KeySym key_sym, | 41 KeySym key_sym, |
| 41 uint32_t* keycode, | 42 uint32_t* keycode, |
| 42 uint32_t* modifiers) { | 43 uint32_t* modifiers) { |
| 43 *keycode = XKeysymToKeycode(display, key_sym); | 44 *keycode = XKeysymToKeycode(display, key_sym); |
| 44 | 45 |
| 45 const uint32_t kModifiersToTry[] = { | 46 const uint32_t kModifiersToTry[] = { |
| 46 0, | 47 0, |
| 47 ShiftMask, | 48 ShiftMask, |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 | 100 |
| 100 bool Init(); | 101 bool Init(); |
| 101 | 102 |
| 102 // Clipboard stub interface. | 103 // Clipboard stub interface. |
| 103 void InjectClipboardEvent(const ClipboardEvent& event) override; | 104 void InjectClipboardEvent(const ClipboardEvent& event) override; |
| 104 | 105 |
| 105 // InputStub interface. | 106 // InputStub interface. |
| 106 void InjectKeyEvent(const KeyEvent& event) override; | 107 void InjectKeyEvent(const KeyEvent& event) override; |
| 107 void InjectTextEvent(const TextEvent& event) override; | 108 void InjectTextEvent(const TextEvent& event) override; |
| 108 void InjectMouseEvent(const MouseEvent& event) override; | 109 void InjectMouseEvent(const MouseEvent& event) override; |
| 110 void InjectTouchEvent(const TouchEvent& event) override; |
| 109 | 111 |
| 110 // InputInjector interface. | 112 // InputInjector interface. |
| 111 void Start(scoped_ptr<protocol::ClipboardStub> client_clipboard) override; | 113 void Start(scoped_ptr<protocol::ClipboardStub> client_clipboard) override; |
| 112 | 114 |
| 113 private: | 115 private: |
| 114 // The actual implementation resides in InputInjectorX11::Core class. | 116 // The actual implementation resides in InputInjectorX11::Core class. |
| 115 class Core : public base::RefCountedThreadSafe<Core> { | 117 class Core : public base::RefCountedThreadSafe<Core> { |
| 116 public: | 118 public: |
| 117 explicit Core(scoped_refptr<base::SingleThreadTaskRunner> task_runner); | 119 explicit Core(scoped_refptr<base::SingleThreadTaskRunner> task_runner); |
| 118 | 120 |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 } | 214 } |
| 213 | 215 |
| 214 void InputInjectorX11::InjectTextEvent(const TextEvent& event) { | 216 void InputInjectorX11::InjectTextEvent(const TextEvent& event) { |
| 215 core_->InjectTextEvent(event); | 217 core_->InjectTextEvent(event); |
| 216 } | 218 } |
| 217 | 219 |
| 218 void InputInjectorX11::InjectMouseEvent(const MouseEvent& event) { | 220 void InputInjectorX11::InjectMouseEvent(const MouseEvent& event) { |
| 219 core_->InjectMouseEvent(event); | 221 core_->InjectMouseEvent(event); |
| 220 } | 222 } |
| 221 | 223 |
| 224 void InputInjectorX11::InjectTouchEvent(const TouchEvent& event) { |
| 225 NOTIMPLEMENTED() << "Raw touch event injection not implemented for X11."; |
| 226 } |
| 227 |
| 222 void InputInjectorX11::Start( | 228 void InputInjectorX11::Start( |
| 223 scoped_ptr<protocol::ClipboardStub> client_clipboard) { | 229 scoped_ptr<protocol::ClipboardStub> client_clipboard) { |
| 224 core_->Start(client_clipboard.Pass()); | 230 core_->Start(client_clipboard.Pass()); |
| 225 } | 231 } |
| 226 | 232 |
| 227 InputInjectorX11::Core::Core( | 233 InputInjectorX11::Core::Core( |
| 228 scoped_refptr<base::SingleThreadTaskRunner> task_runner) | 234 scoped_refptr<base::SingleThreadTaskRunner> task_runner) |
| 229 : task_runner_(task_runner), | 235 : task_runner_(task_runner), |
| 230 latest_mouse_position_(-1, -1), | 236 latest_mouse_position_(-1, -1), |
| 231 wheel_ticks_x_(0.0f), | 237 wheel_ticks_x_(0.0f), |
| (...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 627 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, | 633 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, |
| 628 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner) { | 634 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner) { |
| 629 scoped_ptr<InputInjectorX11> injector( | 635 scoped_ptr<InputInjectorX11> injector( |
| 630 new InputInjectorX11(main_task_runner)); | 636 new InputInjectorX11(main_task_runner)); |
| 631 if (!injector->Init()) | 637 if (!injector->Init()) |
| 632 return nullptr; | 638 return nullptr; |
| 633 return injector.Pass(); | 639 return injector.Pass(); |
| 634 } | 640 } |
| 635 | 641 |
| 636 } // namespace remoting | 642 } // namespace remoting |
| OLD | NEW |