Chromium Code Reviews| Index: ui/aura/remote_root_window_host_win.cc |
| =================================================================== |
| --- ui/aura/remote_root_window_host_win.cc (revision 186512) |
| +++ ui/aura/remote_root_window_host_win.cc (working copy) |
| @@ -29,6 +29,29 @@ |
| // The touch id to be used for touch events coming in from Windows Ash. |
| const int kRemoteWindowTouchId = 10; |
| +// Sets the keystate for the virtual key passed in to down or up. |
| +void SetKeyState(uint8* key_states, bool key_down, uint32 virtual_key_code) { |
| + DCHECK(key_states); |
| + |
| + if (key_down) |
| + key_states[virtual_key_code] |= 0x80; |
| + else |
| + key_states[virtual_key_code] &= 0x7F; |
| +} |
| + |
| +// Sets the keyboard states for the Shift/Control/Alt/Caps lock keys. |
| +void SetVirtualKeyStates(uint32 flags) { |
| + uint8 keyboard_state[256] = {0}; |
| + GetKeyboardState(keyboard_state); |
| + |
| + SetKeyState(keyboard_state, !!(flags & ui::EF_SHIFT_DOWN), VK_SHIFT); |
| + SetKeyState(keyboard_state, !!(flags & ui::EF_CONTROL_DOWN), VK_CONTROL); |
| + SetKeyState(keyboard_state, !!(flags & ui::EF_ALT_DOWN), VK_MENU); |
| + SetKeyState(keyboard_state, !!(flags & ui::EF_CAPS_LOCK_DOWN), VK_CAPITAL); |
| + |
| + SetKeyboardState(keyboard_state); |
| +} |
| + |
| } // namespace |
| void HandleOpenFile( |
| @@ -317,33 +340,24 @@ |
| uint32 repeat_count, |
| uint32 scan_code, |
| uint32 flags) { |
| - ui::KeyEvent event(ui::ET_KEY_PRESSED, |
| - ui::KeyboardCodeForWindowsKeyCode(vkey), |
| - flags, |
| - false); |
| - delegate_->OnHostKeyEvent(&event); |
| + DispatchKeyboardMessage(ui::ET_KEY_PRESSED, vkey, repeat_count, scan_code, |
| + flags, false); |
| } |
| void RemoteRootWindowHostWin::OnKeyUp(uint32 vkey, |
| uint32 repeat_count, |
| uint32 scan_code, |
| uint32 flags) { |
| - ui::KeyEvent event(ui::ET_KEY_RELEASED, |
| - ui::KeyboardCodeForWindowsKeyCode(vkey), |
| - flags, |
| - false); |
| - delegate_->OnHostKeyEvent(&event); |
| + DispatchKeyboardMessage(ui::ET_KEY_RELEASED, vkey, repeat_count, scan_code, |
| + flags, false); |
| } |
| void RemoteRootWindowHostWin::OnChar(uint32 key_code, |
| uint32 repeat_count, |
| uint32 scan_code, |
| uint32 flags) { |
| - ui::KeyEvent event(ui::ET_KEY_PRESSED, |
| - ui::KeyboardCodeForWindowsKeyCode(key_code), |
| - flags, |
| - true); |
| - delegate_->OnHostKeyEvent(&event); |
| + DispatchKeyboardMessage(ui::ET_KEY_PRESSED, key_code, repeat_count, |
| + scan_code, flags, true); |
| } |
| void RemoteRootWindowHostWin::OnVisibilityChanged(bool visible) { |
| @@ -405,4 +419,27 @@ |
| multi_file_open_completion_callback_.Reset(); |
| } |
| +void RemoteRootWindowHostWin::DispatchKeyboardMessage(ui::EventType type, |
| + uint32 vkey, |
| + uint32 repeat_count, |
| + uint32 scan_code, |
| + uint32 flags, |
| + bool is_character) { |
| + if (MessageLoop::current()->IsNested()) { |
| + SetVirtualKeyStates(flags); |
| + |
| + uint32 message = type == ui::ET_KEY_PRESSED ? WM_KEYDOWN : WM_KEYUP; |
| + PostThreadMessage(::GetCurrentThreadId(), |
|
cpu_(ooo_6.6-7.5)
2013/03/07 21:02:26
::PostThreadMessage(
ananta
2013/03/07 21:06:12
Done.
|
| + message, |
| + vkey, |
| + repeat_count | scan_code >> 15); |
| + } else { |
| + ui::KeyEvent event(type, |
| + ui::KeyboardCodeForWindowsKeyCode(vkey), |
| + flags, |
| + is_character); |
| + delegate_->OnHostKeyEvent(&event); |
| + } |
| +} |
| + |
| } // namespace aura |