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/event_executor.h" | 5 #include "remoting/host/event_executor.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 | 8 |
9 #include <X11/Xlib.h> | 9 #include <X11/Xlib.h> |
10 #include <X11/XF86keysym.h> | 10 #include <X11/XF86keysym.h> |
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
318 DCHECK(event.has_pressed()); | 318 DCHECK(event.has_pressed()); |
319 | 319 |
320 if (MessageLoop::current() != message_loop_) { | 320 if (MessageLoop::current() != message_loop_) { |
321 message_loop_->PostTask( | 321 message_loop_->PostTask( |
322 FROM_HERE, | 322 FROM_HERE, |
323 base::Bind(&EventExecutorLinux::InjectKeyEvent, base::Unretained(this), | 323 base::Bind(&EventExecutorLinux::InjectKeyEvent, base::Unretained(this), |
324 event)); | 324 event)); |
325 return; | 325 return; |
326 } | 326 } |
327 | 327 |
328 // Events which don't specify whether the key is pressed are invalid. | |
329 if (!event.has_pressed()) | |
330 return; | |
331 | |
332 int keycode = kInvalidKeycode; | 328 int keycode = kInvalidKeycode; |
333 if (event.has_usb_keycode()) { | 329 if (event.has_usb_keycode()) { |
334 keycode = UsbKeycodeToNativeKeycode(event.usb_keycode()); | 330 keycode = UsbKeycodeToNativeKeycode(event.usb_keycode()); |
335 VLOG(3) << "Converting USB keycode: " << std::hex << event.usb_keycode() | 331 VLOG(3) << "Converting USB keycode: " << std::hex << event.usb_keycode() |
336 << " to keycode: " << keycode << std::dec; | 332 << " to keycode: " << keycode << std::dec; |
337 } else if (event.has_keycode()) { | 333 } else if (event.has_keycode()) { |
338 // Fall back to keysym translation. | 334 // Fall back to keysym translation. |
339 // TODO(garykac) Remove this once we switch entirely over to USB keycodes. | 335 // TODO(garykac) Remove this once we switch entirely over to USB keycodes. |
340 int keysym = ChromotocolKeycodeToX11Keysym(event.keycode()); | 336 int keysym = ChromotocolKeycodeToX11Keysym(event.keycode()); |
341 keycode = XKeysymToKeycode(display_, keysym); | 337 keycode = XKeysymToKeycode(display_, keysym); |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
450 MessageLoop* message_loop, Capturer* capturer) { | 446 MessageLoop* message_loop, Capturer* capturer) { |
451 scoped_ptr<EventExecutorLinux> executor( | 447 scoped_ptr<EventExecutorLinux> executor( |
452 new EventExecutorLinux(message_loop, capturer)); | 448 new EventExecutorLinux(message_loop, capturer)); |
453 if (!executor->Init()) { | 449 if (!executor->Init()) { |
454 executor.reset(NULL); | 450 executor.reset(NULL); |
455 } | 451 } |
456 return executor.PassAs<protocol::HostEventStub>(); | 452 return executor.PassAs<protocol::HostEventStub>(); |
457 } | 453 } |
458 | 454 |
459 } // namespace remoting | 455 } // namespace remoting |
OLD | NEW |