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 <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 #include <X11/extensions/XInput.h> | 9 #include <X11/extensions/XInput.h> |
10 #include <X11/extensions/XTest.h> | 10 #include <X11/extensions/XTest.h> |
11 #include <X11/Xlib.h> | 11 #include <X11/Xlib.h> |
12 #include <X11/XKBlib.h> | 12 #include <X11/XKBlib.h> |
13 #undef Status // Xlib.h #defines this, which breaks protobuf headers. | 13 #undef Status // Xlib.h #defines this, which breaks protobuf headers. |
14 | 14 |
15 #include <set> | 15 #include <set> |
| 16 #include <utility> |
16 | 17 |
17 #include "base/bind.h" | 18 #include "base/bind.h" |
18 #include "base/compiler_specific.h" | 19 #include "base/compiler_specific.h" |
19 #include "base/location.h" | 20 #include "base/location.h" |
20 #include "base/macros.h" | 21 #include "base/macros.h" |
21 #include "base/single_thread_task_runner.h" | 22 #include "base/single_thread_task_runner.h" |
22 #include "base/strings/utf_string_conversion_utils.h" | 23 #include "base/strings/utf_string_conversion_utils.h" |
23 #include "build/build_config.h" | 24 #include "build/build_config.h" |
24 #include "remoting/base/logging.h" | 25 #include "remoting/base/logging.h" |
25 #include "remoting/host/clipboard.h" | 26 #include "remoting/host/clipboard.h" |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
235 void InputInjectorX11::InjectMouseEvent(const MouseEvent& event) { | 236 void InputInjectorX11::InjectMouseEvent(const MouseEvent& event) { |
236 core_->InjectMouseEvent(event); | 237 core_->InjectMouseEvent(event); |
237 } | 238 } |
238 | 239 |
239 void InputInjectorX11::InjectTouchEvent(const TouchEvent& event) { | 240 void InputInjectorX11::InjectTouchEvent(const TouchEvent& event) { |
240 NOTIMPLEMENTED() << "Raw touch event injection not implemented for X11."; | 241 NOTIMPLEMENTED() << "Raw touch event injection not implemented for X11."; |
241 } | 242 } |
242 | 243 |
243 void InputInjectorX11::Start( | 244 void InputInjectorX11::Start( |
244 scoped_ptr<protocol::ClipboardStub> client_clipboard) { | 245 scoped_ptr<protocol::ClipboardStub> client_clipboard) { |
245 core_->Start(client_clipboard.Pass()); | 246 core_->Start(std::move(client_clipboard)); |
246 } | 247 } |
247 | 248 |
248 InputInjectorX11::Core::Core( | 249 InputInjectorX11::Core::Core( |
249 scoped_refptr<base::SingleThreadTaskRunner> task_runner) | 250 scoped_refptr<base::SingleThreadTaskRunner> task_runner) |
250 : task_runner_(task_runner), | 251 : task_runner_(task_runner), |
251 latest_mouse_position_(-1, -1), | 252 latest_mouse_position_(-1, -1), |
252 wheel_ticks_x_(0.0f), | 253 wheel_ticks_x_(0.0f), |
253 wheel_ticks_y_(0.0f), | 254 wheel_ticks_y_(0.0f), |
254 display_(XOpenDisplay(nullptr)), | 255 display_(XOpenDisplay(nullptr)), |
255 root_window_(BadValue), | 256 root_window_(BadValue), |
(...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
622 scoped_ptr<protocol::ClipboardStub> client_clipboard) { | 623 scoped_ptr<protocol::ClipboardStub> client_clipboard) { |
623 if (!task_runner_->BelongsToCurrentThread()) { | 624 if (!task_runner_->BelongsToCurrentThread()) { |
624 task_runner_->PostTask( | 625 task_runner_->PostTask( |
625 FROM_HERE, | 626 FROM_HERE, |
626 base::Bind(&Core::Start, this, base::Passed(&client_clipboard))); | 627 base::Bind(&Core::Start, this, base::Passed(&client_clipboard))); |
627 return; | 628 return; |
628 } | 629 } |
629 | 630 |
630 InitMouseButtonMap(); | 631 InitMouseButtonMap(); |
631 | 632 |
632 clipboard_->Start(client_clipboard.Pass()); | 633 clipboard_->Start(std::move(client_clipboard)); |
633 } | 634 } |
634 | 635 |
635 void InputInjectorX11::Core::Stop() { | 636 void InputInjectorX11::Core::Stop() { |
636 if (!task_runner_->BelongsToCurrentThread()) { | 637 if (!task_runner_->BelongsToCurrentThread()) { |
637 task_runner_->PostTask(FROM_HERE, base::Bind(&Core::Stop, this)); | 638 task_runner_->PostTask(FROM_HERE, base::Bind(&Core::Stop, this)); |
638 return; | 639 return; |
639 } | 640 } |
640 | 641 |
641 clipboard_.reset(); | 642 clipboard_.reset(); |
642 } | 643 } |
643 | 644 |
644 } // namespace | 645 } // namespace |
645 | 646 |
646 // static | 647 // static |
647 scoped_ptr<InputInjector> InputInjector::Create( | 648 scoped_ptr<InputInjector> InputInjector::Create( |
648 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, | 649 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, |
649 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner) { | 650 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner) { |
650 scoped_ptr<InputInjectorX11> injector( | 651 scoped_ptr<InputInjectorX11> injector( |
651 new InputInjectorX11(main_task_runner)); | 652 new InputInjectorX11(main_task_runner)); |
652 if (!injector->Init()) | 653 if (!injector->Init()) |
653 return nullptr; | 654 return nullptr; |
654 return injector.Pass(); | 655 return std::move(injector); |
655 } | 656 } |
656 | 657 |
657 // static | 658 // static |
658 bool InputInjector::SupportsTouchEvents() { | 659 bool InputInjector::SupportsTouchEvents() { |
659 return false; | 660 return false; |
660 } | 661 } |
661 | 662 |
662 } // namespace remoting | 663 } // namespace remoting |
OLD | NEW |