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 <windows.h> | 7 #include <windows.h> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 return layout; | 107 return layout; |
108 } | 108 } |
109 | 109 |
110 void EventExecutorWin::HandleKey(const KeyEvent& event) { | 110 void EventExecutorWin::HandleKey(const KeyEvent& event) { |
111 // HostEventDispatcher should filter events missing the pressed field. | 111 // HostEventDispatcher should filter events missing the pressed field. |
112 DCHECK(event.has_pressed()); | 112 DCHECK(event.has_pressed()); |
113 | 113 |
114 // Reset the system idle suspend timeout. | 114 // Reset the system idle suspend timeout. |
115 SetThreadExecutionState(ES_SYSTEM_REQUIRED); | 115 SetThreadExecutionState(ES_SYSTEM_REQUIRED); |
116 | 116 |
117 // Events which don't specify whether the key is pressed are invalid. | |
118 if (!event.has_pressed()) | |
119 return; | |
120 | |
121 // The mapping between scancodes and VKEY values depends on the foreground | 117 // The mapping between scancodes and VKEY values depends on the foreground |
122 // window's current keyboard layout. | 118 // window's current keyboard layout. |
123 HKL layout = GetForegroundKeyboardLayout(); | 119 HKL layout = GetForegroundKeyboardLayout(); |
124 | 120 |
125 int key = event.keycode(); | 121 int key = event.keycode(); |
126 bool down = event.pressed(); | 122 bool down = event.pressed(); |
127 int scancode = kInvalidKeycode; | 123 int scancode = kInvalidKeycode; |
128 if (event.has_usb_keycode()) { | 124 if (event.has_usb_keycode()) { |
129 // If the event contains a USB-style code, map to a Windows scancode, and | 125 // If the event contains a USB-style code, map to a Windows scancode, and |
130 // look up the corresponding VKEY under the foreground layout. | 126 // look up the corresponding VKEY under the foreground layout. |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
247 | 243 |
248 } // namespace | 244 } // namespace |
249 | 245 |
250 scoped_ptr<protocol::HostEventStub> EventExecutor::Create( | 246 scoped_ptr<protocol::HostEventStub> EventExecutor::Create( |
251 MessageLoop* message_loop, Capturer* capturer) { | 247 MessageLoop* message_loop, Capturer* capturer) { |
252 return scoped_ptr<protocol::HostEventStub>( | 248 return scoped_ptr<protocol::HostEventStub>( |
253 new EventExecutorWin(message_loop, capturer)); | 249 new EventExecutorWin(message_loop, capturer)); |
254 } | 250 } |
255 | 251 |
256 } // namespace remoting | 252 } // namespace remoting |
OLD | NEW |