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

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

Issue 494813002: events: keycodes: Remove the stateless singleton instance of KeycodeConverter (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 3 months 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 | Annotate | Revision Log
« no previous file with comments | « remoting/client/plugin/pepper_input_handler.cc ('k') | remoting/host/input_injector_mac.cc » ('j') | 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 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 // HostEventDispatcher should filter events missing the pressed field. 269 // HostEventDispatcher should filter events missing the pressed field.
270 if (!event.has_pressed() || !event.has_usb_keycode()) 270 if (!event.has_pressed() || !event.has_usb_keycode())
271 return; 271 return;
272 272
273 if (!task_runner_->BelongsToCurrentThread()) { 273 if (!task_runner_->BelongsToCurrentThread()) {
274 task_runner_->PostTask(FROM_HERE, 274 task_runner_->PostTask(FROM_HERE,
275 base::Bind(&Core::InjectKeyEvent, this, event)); 275 base::Bind(&Core::InjectKeyEvent, this, event));
276 return; 276 return;
277 } 277 }
278 278
279 ui::KeycodeConverter* key_converter = ui::KeycodeConverter::GetInstance(); 279 int keycode =
280 int keycode = key_converter->UsbKeycodeToNativeKeycode(event.usb_keycode()); 280 ui::KeycodeConverter::UsbKeycodeToNativeKeycode(event.usb_keycode());
281 281
282 VLOG(3) << "Converting USB keycode: " << std::hex << event.usb_keycode() 282 VLOG(3) << "Converting USB keycode: " << std::hex << event.usb_keycode()
283 << " to keycode: " << keycode << std::dec; 283 << " to keycode: " << keycode << std::dec;
284 284
285 // Ignore events which can't be mapped. 285 // Ignore events which can't be mapped.
286 if (keycode == key_converter->InvalidNativeKeycode()) 286 if (keycode == ui::KeycodeConverter::InvalidNativeKeycode())
287 return; 287 return;
288 288
289 if (event.pressed()) { 289 if (event.pressed()) {
290 if (pressed_keys_.find(keycode) != pressed_keys_.end()) { 290 if (pressed_keys_.find(keycode) != pressed_keys_.end()) {
291 // Key is already held down, so lift the key up to ensure this repeated 291 // Key is already held down, so lift the key up to ensure this repeated
292 // press takes effect. 292 // press takes effect.
293 XTestFakeKeyEvent(display_, keycode, False, CurrentTime); 293 XTestFakeKeyEvent(display_, keycode, False, CurrentTime);
294 } 294 }
295 295
296 if (pressed_keys_.empty()) { 296 if (pressed_keys_.empty()) {
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after
605 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, 605 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner,
606 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner) { 606 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner) {
607 scoped_ptr<InputInjectorLinux> injector( 607 scoped_ptr<InputInjectorLinux> injector(
608 new InputInjectorLinux(main_task_runner)); 608 new InputInjectorLinux(main_task_runner));
609 if (!injector->Init()) 609 if (!injector->Init())
610 return scoped_ptr<InputInjector>(); 610 return scoped_ptr<InputInjector>();
611 return injector.PassAs<InputInjector>(); 611 return injector.PassAs<InputInjector>();
612 } 612 }
613 613
614 } // namespace remoting 614 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/client/plugin/pepper_input_handler.cc ('k') | remoting/host/input_injector_mac.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698