| 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 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 320 XFlush(display_); | 320 XFlush(display_); |
| 321 } | 321 } |
| 322 | 322 |
| 323 void InputInjectorX11::Core::InjectTextEvent(const TextEvent& event) { | 323 void InputInjectorX11::Core::InjectTextEvent(const TextEvent& event) { |
| 324 if (!task_runner_->BelongsToCurrentThread()) { | 324 if (!task_runner_->BelongsToCurrentThread()) { |
| 325 task_runner_->PostTask(FROM_HERE, | 325 task_runner_->PostTask(FROM_HERE, |
| 326 base::Bind(&Core::InjectTextEvent, this, event)); | 326 base::Bind(&Core::InjectTextEvent, this, event)); |
| 327 return; | 327 return; |
| 328 } | 328 } |
| 329 | 329 |
| 330 // Release all keys before injecting text event. This is necessary to avoid |
| 331 // any interference with the currently pressed keys. E.g. if Shift is pressed |
| 332 // when TextEvent is received. |
| 333 for (int key : pressed_keys_) { |
| 334 XTestFakeKeyEvent(display_, key, False, CurrentTime); |
| 335 } |
| 336 pressed_keys_.clear(); |
| 337 |
| 330 const std::string text = event.text(); | 338 const std::string text = event.text(); |
| 331 for (int32 index = 0; index < static_cast<int32>(text.size()); ++index) { | 339 for (int32 index = 0; index < static_cast<int32>(text.size()); ++index) { |
| 332 uint32_t code_point; | 340 uint32_t code_point; |
| 333 if (!base::ReadUnicodeCharacter( | 341 if (!base::ReadUnicodeCharacter( |
| 334 text.c_str(), text.size(), &index, &code_point)) { | 342 text.c_str(), text.size(), &index, &code_point)) { |
| 335 continue; | 343 continue; |
| 336 } | 344 } |
| 337 | 345 |
| 338 uint32_t keycode; | 346 uint32_t keycode; |
| 339 uint32_t modifiers; | 347 uint32_t modifiers; |
| (...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 618 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, | 626 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, |
| 619 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner) { | 627 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner) { |
| 620 scoped_ptr<InputInjectorX11> injector( | 628 scoped_ptr<InputInjectorX11> injector( |
| 621 new InputInjectorX11(main_task_runner)); | 629 new InputInjectorX11(main_task_runner)); |
| 622 if (!injector->Init()) | 630 if (!injector->Init()) |
| 623 return nullptr; | 631 return nullptr; |
| 624 return injector.Pass(); | 632 return injector.Pass(); |
| 625 } | 633 } |
| 626 | 634 |
| 627 } // namespace remoting | 635 } // namespace remoting |
| OLD | NEW |