| 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> |
| 8 #include <stdint.h> |
| 7 #include <X11/extensions/XInput.h> | 9 #include <X11/extensions/XInput.h> |
| 8 #include <X11/extensions/XTest.h> | 10 #include <X11/extensions/XTest.h> |
| 9 #include <X11/Xlib.h> | 11 #include <X11/Xlib.h> |
| 10 #include <X11/XKBlib.h> | 12 #include <X11/XKBlib.h> |
| 11 #undef Status // Xlib.h #defines this, which breaks protobuf headers. | 13 #undef Status // Xlib.h #defines this, which breaks protobuf headers. |
| 12 | 14 |
| 13 #include <set> | 15 #include <set> |
| 14 | 16 |
| 15 #include "base/basictypes.h" | |
| 16 #include "base/bind.h" | 17 #include "base/bind.h" |
| 17 #include "base/compiler_specific.h" | 18 #include "base/compiler_specific.h" |
| 18 #include "base/location.h" | 19 #include "base/location.h" |
| 20 #include "base/macros.h" |
| 19 #include "base/single_thread_task_runner.h" | 21 #include "base/single_thread_task_runner.h" |
| 20 #include "base/strings/utf_string_conversion_utils.h" | 22 #include "base/strings/utf_string_conversion_utils.h" |
| 23 #include "build/build_config.h" |
| 21 #include "remoting/base/logging.h" | 24 #include "remoting/base/logging.h" |
| 22 #if defined(OS_CHROMEOS) | |
| 23 #include "remoting/host/chromeos/point_transformer.h" | |
| 24 #endif | |
| 25 #include "remoting/host/clipboard.h" | 25 #include "remoting/host/clipboard.h" |
| 26 #include "remoting/host/linux/unicode_to_keysym.h" | 26 #include "remoting/host/linux/unicode_to_keysym.h" |
| 27 #include "remoting/host/linux/x11_util.h" | 27 #include "remoting/host/linux/x11_util.h" |
| 28 #include "remoting/proto/internal.pb.h" | 28 #include "remoting/proto/internal.pb.h" |
| 29 #include "third_party/webrtc/modules/desktop_capture/desktop_geometry.h" | 29 #include "third_party/webrtc/modules/desktop_capture/desktop_geometry.h" |
| 30 #include "ui/events/keycodes/dom/dom_code.h" | 30 #include "ui/events/keycodes/dom/dom_code.h" |
| 31 #include "ui/events/keycodes/dom/keycode_converter.h" | 31 #include "ui/events/keycodes/dom/keycode_converter.h" |
| 32 | 32 |
| 33 #if defined(OS_CHROMEOS) |
| 34 #include "remoting/host/chromeos/point_transformer.h" |
| 35 #endif |
| 36 |
| 33 namespace remoting { | 37 namespace remoting { |
| 34 | 38 |
| 35 namespace { | 39 namespace { |
| 36 | 40 |
| 37 using protocol::ClipboardEvent; | 41 using protocol::ClipboardEvent; |
| 38 using protocol::KeyEvent; | 42 using protocol::KeyEvent; |
| 39 using protocol::TextEvent; | 43 using protocol::TextEvent; |
| 40 using protocol::MouseEvent; | 44 using protocol::MouseEvent; |
| 41 using protocol::TouchEvent; | 45 using protocol::TouchEvent; |
| 42 | 46 |
| (...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 345 | 349 |
| 346 // Release all keys before injecting text event. This is necessary to avoid | 350 // Release all keys before injecting text event. This is necessary to avoid |
| 347 // any interference with the currently pressed keys. E.g. if Shift is pressed | 351 // any interference with the currently pressed keys. E.g. if Shift is pressed |
| 348 // when TextEvent is received. | 352 // when TextEvent is received. |
| 349 for (int key : pressed_keys_) { | 353 for (int key : pressed_keys_) { |
| 350 XTestFakeKeyEvent(display_, key, False, CurrentTime); | 354 XTestFakeKeyEvent(display_, key, False, CurrentTime); |
| 351 } | 355 } |
| 352 pressed_keys_.clear(); | 356 pressed_keys_.clear(); |
| 353 | 357 |
| 354 const std::string text = event.text(); | 358 const std::string text = event.text(); |
| 355 for (int32 index = 0; index < static_cast<int32>(text.size()); ++index) { | 359 for (int32_t index = 0; index < static_cast<int32_t>(text.size()); ++index) { |
| 356 uint32_t code_point; | 360 uint32_t code_point; |
| 357 if (!base::ReadUnicodeCharacter( | 361 if (!base::ReadUnicodeCharacter( |
| 358 text.c_str(), text.size(), &index, &code_point)) { | 362 text.c_str(), text.size(), &index, &code_point)) { |
| 359 continue; | 363 continue; |
| 360 } | 364 } |
| 361 | 365 |
| 362 uint32_t keycode; | 366 uint32_t keycode; |
| 363 uint32_t modifiers; | 367 uint32_t modifiers; |
| 364 if (!FindKeycodeForUnicode(display_, code_point, &keycode, &modifiers)) | 368 if (!FindKeycodeForUnicode(display_, code_point, &keycode, &modifiers)) |
| 365 continue; | 369 continue; |
| (...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 649 return nullptr; | 653 return nullptr; |
| 650 return injector.Pass(); | 654 return injector.Pass(); |
| 651 } | 655 } |
| 652 | 656 |
| 653 // static | 657 // static |
| 654 bool InputInjector::SupportsTouchEvents() { | 658 bool InputInjector::SupportsTouchEvents() { |
| 655 return false; | 659 return false; |
| 656 } | 660 } |
| 657 | 661 |
| 658 } // namespace remoting | 662 } // namespace remoting |
| OLD | NEW |