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 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 void InjectClipboardEvent(const ClipboardEvent& event) override; | 104 void InjectClipboardEvent(const ClipboardEvent& event) override; |
105 | 105 |
106 // InputStub interface. | 106 // InputStub interface. |
107 void InjectKeyEvent(const KeyEvent& event) override; | 107 void InjectKeyEvent(const KeyEvent& event) override; |
108 void InjectTextEvent(const TextEvent& event) override; | 108 void InjectTextEvent(const TextEvent& event) override; |
109 void InjectMouseEvent(const MouseEvent& event) override; | 109 void InjectMouseEvent(const MouseEvent& event) override; |
110 void InjectTouchEvent(const TouchEvent& event) override; | 110 void InjectTouchEvent(const TouchEvent& event) override; |
111 | 111 |
112 // InputInjector interface. | 112 // InputInjector interface. |
113 void Start(scoped_ptr<protocol::ClipboardStub> client_clipboard) override; | 113 void Start(scoped_ptr<protocol::ClipboardStub> client_clipboard) override; |
| 114 bool CanInjectTouch() override; |
114 | 115 |
115 private: | 116 private: |
116 // The actual implementation resides in InputInjectorX11::Core class. | 117 // The actual implementation resides in InputInjectorX11::Core class. |
117 class Core : public base::RefCountedThreadSafe<Core> { | 118 class Core : public base::RefCountedThreadSafe<Core> { |
118 public: | 119 public: |
119 explicit Core(scoped_refptr<base::SingleThreadTaskRunner> task_runner); | 120 explicit Core(scoped_refptr<base::SingleThreadTaskRunner> task_runner); |
120 | 121 |
121 bool Init(); | 122 bool Init(); |
122 | 123 |
123 // Mirrors the ClipboardStub interface. | 124 // Mirrors the ClipboardStub interface. |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 | 224 |
224 void InputInjectorX11::InjectTouchEvent(const TouchEvent& event) { | 225 void InputInjectorX11::InjectTouchEvent(const TouchEvent& event) { |
225 NOTIMPLEMENTED() << "Raw touch event injection not implemented for X11."; | 226 NOTIMPLEMENTED() << "Raw touch event injection not implemented for X11."; |
226 } | 227 } |
227 | 228 |
228 void InputInjectorX11::Start( | 229 void InputInjectorX11::Start( |
229 scoped_ptr<protocol::ClipboardStub> client_clipboard) { | 230 scoped_ptr<protocol::ClipboardStub> client_clipboard) { |
230 core_->Start(client_clipboard.Pass()); | 231 core_->Start(client_clipboard.Pass()); |
231 } | 232 } |
232 | 233 |
| 234 bool InputInjectorX11::CanInjectTouch() { |
| 235 return false; |
| 236 } |
| 237 |
233 InputInjectorX11::Core::Core( | 238 InputInjectorX11::Core::Core( |
234 scoped_refptr<base::SingleThreadTaskRunner> task_runner) | 239 scoped_refptr<base::SingleThreadTaskRunner> task_runner) |
235 : task_runner_(task_runner), | 240 : task_runner_(task_runner), |
236 latest_mouse_position_(-1, -1), | 241 latest_mouse_position_(-1, -1), |
237 wheel_ticks_x_(0.0f), | 242 wheel_ticks_x_(0.0f), |
238 wheel_ticks_y_(0.0f), | 243 wheel_ticks_y_(0.0f), |
239 display_(XOpenDisplay(nullptr)), | 244 display_(XOpenDisplay(nullptr)), |
240 root_window_(BadValue), | 245 root_window_(BadValue), |
241 saved_auto_repeat_enabled_(false) { | 246 saved_auto_repeat_enabled_(false) { |
242 } | 247 } |
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
622 if (!task_runner_->BelongsToCurrentThread()) { | 627 if (!task_runner_->BelongsToCurrentThread()) { |
623 task_runner_->PostTask(FROM_HERE, base::Bind(&Core::Stop, this)); | 628 task_runner_->PostTask(FROM_HERE, base::Bind(&Core::Stop, this)); |
624 return; | 629 return; |
625 } | 630 } |
626 | 631 |
627 clipboard_.reset(); | 632 clipboard_.reset(); |
628 } | 633 } |
629 | 634 |
630 } // namespace | 635 } // namespace |
631 | 636 |
| 637 // static |
632 scoped_ptr<InputInjector> InputInjector::Create( | 638 scoped_ptr<InputInjector> InputInjector::Create( |
633 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, | 639 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, |
634 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner) { | 640 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner) { |
635 scoped_ptr<InputInjectorX11> injector( | 641 scoped_ptr<InputInjectorX11> injector( |
636 new InputInjectorX11(main_task_runner)); | 642 new InputInjectorX11(main_task_runner)); |
637 if (!injector->Init()) | 643 if (!injector->Init()) |
638 return nullptr; | 644 return nullptr; |
639 return injector.Pass(); | 645 return injector.Pass(); |
640 } | 646 } |
641 | 647 |
| 648 // static |
| 649 bool InputInjector::DefaultCanInjectTouch() { |
| 650 return false; |
| 651 } |
| 652 |
642 } // namespace remoting | 653 } // namespace remoting |
OLD | NEW |