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

Unified Diff: ui/aura/remote_root_window_host_win.cc

Issue 12558008: Ensure that menus put in Chrome ASH on Windows 8 are operatable using the keyboard. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 7 years, 9 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 side-by-side diff with in-line comments
Download patch
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

Powered by Google App Engine
This is Rietveld 408576698