Changeset 134855 in webkit
- Timestamp:
- Nov 15, 2012 4:30:14 PM (11 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r134853 r134855 1 2012-11-15 Takashi Sakamoto <tasak@google.com> 2 3 [Win] key event's location does not work on Windows platform. 4 https://bugs.webkit.org/show_bug.cgi?id=89742 5 6 Reviewed by Brent Fulgham. 7 8 As WM_KEYDOWN, WM_KEYUP, WM_SYSKEYDOWN, and WM_SYSKEYUP doesn't 9 directly provide a virtual keycode which distinguish between left-hand 10 and right-hand keys. To obtain a virtual keycode, we have to look at 11 lparam, i.e. scancode and extended key bit. So if the given virtual 12 keycode is control, shift, or menu, use MapVirtualKey with scancode and 13 extended key bit and recreate a virtual keycode which distinguishes 14 between left-hand and right-hand. 15 16 No new tests, because left-hand keys, right-hand keys layout tests 17 have been already added. 18 19 * platform/win/KeyEventWin.cpp: 20 (WebCore::windowsKeycodeWithLocation): 21 Use wparam and lparam to recreate a virtual keycode which distinguishes 22 between left-hand and right-hand if the given wparam (=virtual keycode) 23 is control, shift, or menu. 24 (WebCore): 25 (WebCore::PlatformKeyboardEvent::PlatformKeyboardEvent): 26 Use the newly added function to obtain windows virtual keycode. 27 1 28 2012-11-15 Joe Mason <jmason@rim.com> 2 29 -
trunk/Source/WebCore/platform/win/KeyEventWin.cpp
r103643 r134855 29 29 #include <windows.h> 30 30 #include <wtf/ASCIICType.h> 31 32 #ifndef MAPVK_VSC_TO_VK_EX 33 #define MAPVK_VSC_TO_VK_EX 3 34 #endif 31 35 32 36 using namespace WTF; … … 185 189 } 186 190 191 static int windowsKeycodeWithLocation(WPARAM keycode, LPARAM keyData) 192 { 193 if (keycode != VK_CONTROL && keycode != VK_MENU && keycode != VK_SHIFT) 194 return keycode; 195 196 // If we don't need to support Windows XP or older Windows, 197 // it might be better to use MapVirtualKeyEx with scancode and 198 // extended keycode (i.e. 0xe0 or 0xe1). 199 if ((keyData >> 16) & KF_EXTENDED) { 200 switch (keycode) { 201 case VK_CONTROL: 202 return VK_RCONTROL; 203 case VK_SHIFT: 204 return VK_RSHIFT; 205 case VK_MENU: 206 return VK_RMENU; 207 default: 208 break; 209 } 210 } 211 212 int scancode = (keyData >> 16) & 0xFF; 213 int regeneratedVirtualKeyCode = ::MapVirtualKey(scancode, MAPVK_VSC_TO_VK_EX); 214 return regeneratedVirtualKeyCode ? regeneratedVirtualKeyCode : keycode; 215 } 216 187 217 static inline String singleCharacterString(UChar c) 188 218 { … … 195 225 , m_unmodifiedText((type == PlatformEvent::Char) ? singleCharacterString(code) : String()) 196 226 , m_keyIdentifier((type == PlatformEvent::Char) ? String() : keyIdentifierForWindowsKeyCode(code)) 197 , m_windowsVirtualKeyCode((type == RawKeyDown || type == KeyUp) ? code: 0)227 , m_windowsVirtualKeyCode((type == RawKeyDown || type == KeyUp) ? windowsKeycodeWithLocation(code, keyData) : 0) 198 228 , m_nativeVirtualKeyCode(m_windowsVirtualKeyCode) 199 229 , m_macCharCode(0)
Note: See TracChangeset
for help on using the changeset viewer.