diff options
author | ananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-02-17 08:21:35 +0000 |
---|---|---|
committer | ananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-02-17 08:21:35 +0000 |
commit | a15d4a42a5b5e1fc2390c45188c4d8fa3c381a3f (patch) | |
tree | b051c7d0daf57be61d3f226437d0775df84cb21f /chrome_frame/test/simulate_input.cc | |
parent | 2e59325fed2416cd23d0b418cd46e302148aa584 (diff) | |
download | chromium_src-a15d4a42a5b5e1fc2390c45188c4d8fa3c381a3f.zip chromium_src-a15d4a42a5b5e1fc2390c45188c4d8fa3c381a3f.tar.gz chromium_src-a15d4a42a5b5e1fc2390c45188c4d8fa3c381a3f.tar.bz2 |
We need to support the following accelerators in the ChromeFrame Active document, to ensure that the following
accelerators navigate backwards and forwards in IE history.
1. VK_BACK and Alt + VK_LEFT to navigate back.
2. Shift + VK_BACK and Alt + VK_RIGHT to navigate forward.
This CL adds support for this. We load the accelerator table in our Active document and when we receive an
accelerator from Chrome, we first call the Windows API TranslateAccelerator to translate any accelerators
and then continue with the default handling. Added handlers for navigating back and forward.
Test=covered by unit test.
Fixes bug http://code.google.com/p/chromium/issues/detail?id=35629
Bug=35629
Review URL: http://codereview.chromium.org/600117
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@39208 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome_frame/test/simulate_input.cc')
-rw-r--r-- | chrome_frame/test/simulate_input.cc | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/chrome_frame/test/simulate_input.cc b/chrome_frame/test/simulate_input.cc index 82002a9..082b58b 100644 --- a/chrome_frame/test/simulate_input.cc +++ b/chrome_frame/test/simulate_input.cc @@ -121,7 +121,7 @@ void SendChar(wchar_t c, bool control, bool alt) { // Sends a keystroke to the currently active application with optional // modifiers set. -bool SendMnemonic(WORD mnemonic_char, bool shift_pressed, bool control_pressed, +void SendMnemonic(WORD mnemonic_char, bool shift_pressed, bool control_pressed, bool alt_pressed, bool extended, bool unicode) { INPUT keys[4] = {0}; // Keyboard events int key_count = 0; // Number of generated events @@ -129,41 +129,52 @@ bool SendMnemonic(WORD mnemonic_char, bool shift_pressed, bool control_pressed, if (shift_pressed) { keys[key_count].type = INPUT_KEYBOARD; keys[key_count].ki.wVk = VK_SHIFT; + keys[key_count].ki.wScan = MapVirtualKey(VK_SHIFT, 0); key_count++; } if (control_pressed) { keys[key_count].type = INPUT_KEYBOARD; keys[key_count].ki.wVk = VK_CONTROL; + keys[key_count].ki.wScan = MapVirtualKey(VK_CONTROL, 0); key_count++; } if (alt_pressed) { keys[key_count].type = INPUT_KEYBOARD; keys[key_count].ki.wVk = VK_MENU; + keys[key_count].ki.wScan = MapVirtualKey(VK_MENU, 0); key_count++; } keys[key_count].type = INPUT_KEYBOARD; keys[key_count].ki.wVk = mnemonic_char; + keys[key_count].ki.wScan = MapVirtualKey(mnemonic_char, 0); + if (extended) keys[key_count].ki.dwFlags |= KEYEVENTF_EXTENDEDKEY; if (unicode) keys[key_count].ki.dwFlags |= KEYEVENTF_UNICODE; key_count++; + bool should_sleep = key_count > 1; + // Send key downs for (int i = 0; i < key_count; i++) { SendInput(1, &keys[ i ], sizeof(keys[0])); keys[i].ki.dwFlags |= KEYEVENTF_KEYUP; + if (should_sleep) { + Sleep(100); + } } // Now send key ups in reverse order for (int i = key_count; i; i--) { SendInput(1, &keys[ i - 1 ], sizeof(keys[0])); + if (should_sleep) { + Sleep(100); + } } - - return true; } void SetKeyboardFocusToWindow(HWND window) { @@ -215,8 +226,8 @@ void SendMouseClick(HWND window, int x, int y, MouseButton button) { ::SendInput(1, &input_info, sizeof(INPUT)); } -bool SendExtendedKey(WORD key, bool shift, bool control, bool alt) { - return SendMnemonic(key, shift, control, alt, true, false); +void SendExtendedKey(WORD key, bool shift, bool control, bool alt) { + SendMnemonic(key, shift, control, alt, true, false); } } // namespace simulate_input |