Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(91)

Side by Side Diff: remoting/host/input_injector_x11.cc

Issue 806223008: Fix input injector on Linux to release all keys before injecting text event. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 (std::set<int>::iterator it = pressed_keys_.begin();
Lambros 2014/12/22 23:05:11 nit: Prefer const_iterator Could use C++11 here: f
Sergey Ulanov 2014/12/23 00:13:28 Done.
334 it != pressed_keys_.end(); ++it) {
335 XTestFakeKeyEvent(display_, *it, False, CurrentTime);
336 }
337 pressed_keys_.clear();
338
330 const std::string text = event.text(); 339 const std::string text = event.text();
331 for (int32 index = 0; index < static_cast<int32>(text.size()); ++index) { 340 for (int32 index = 0; index < static_cast<int32>(text.size()); ++index) {
332 uint32_t code_point; 341 uint32_t code_point;
333 if (!base::ReadUnicodeCharacter( 342 if (!base::ReadUnicodeCharacter(
334 text.c_str(), text.size(), &index, &code_point)) { 343 text.c_str(), text.size(), &index, &code_point)) {
335 continue; 344 continue;
336 } 345 }
337 346
338 uint32_t keycode; 347 uint32_t keycode;
339 uint32_t modifiers; 348 uint32_t modifiers;
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
618 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, 627 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner,
619 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner) { 628 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner) {
620 scoped_ptr<InputInjectorX11> injector( 629 scoped_ptr<InputInjectorX11> injector(
621 new InputInjectorX11(main_task_runner)); 630 new InputInjectorX11(main_task_runner));
622 if (!injector->Init()) 631 if (!injector->Init())
623 return nullptr; 632 return nullptr;
624 return injector.Pass(); 633 return injector.Pass();
625 } 634 }
626 635
627 } // namespace remoting 636 } // namespace remoting
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698