| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 "config.h" | 5 #include "config.h" |
| 6 | 6 |
| 7 #include "webkit/glue/webinputevent.h" | 7 #include "webkit/glue/webinputevent.h" |
| 8 | 8 |
| 9 #include "webkit/glue/event_conversion.h" | 9 #include "base/string_util.h" |
| 10 #include "webkit/glue/webinputevent_utils.h" |
| 10 | 11 |
| 11 #undef LOG | 12 #undef LOG |
| 12 #include "base/logging.h" | 13 #include "base/logging.h" |
| 13 | 14 |
| 14 static const unsigned long kDefaultScrollLinesPerWheelDelta = 3; | 15 static const unsigned long kDefaultScrollLinesPerWheelDelta = 3; |
| 15 | 16 |
| 16 // WebMouseEvent -------------------------------------------------------------- | 17 // WebMouseEvent -------------------------------------------------------------- |
| 17 | 18 |
| 18 static LPARAM GetRelativeCursorPos(HWND hwnd) { | 19 static LPARAM GetRelativeCursorPos(HWND hwnd) { |
| 19 POINT pos = {-1, -1}; | 20 POINT pos = {-1, -1}; |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 default: | 171 default: |
| 171 break; | 172 break; |
| 172 } | 173 } |
| 173 | 174 |
| 174 // Touchpads (or trackpoints) send the following messages in scrolling | 175 // Touchpads (or trackpoints) send the following messages in scrolling |
| 175 // horizontally. | 176 // horizontally. |
| 176 // * Scrolling left | 177 // * Scrolling left |
| 177 // message == WM_HSCROLL, wparam == SB_LINELEFT (== SB_LINEUP). | 178 // message == WM_HSCROLL, wparam == SB_LINELEFT (== SB_LINEUP). |
| 178 // * Scrolling right | 179 // * Scrolling right |
| 179 // message == WM_HSCROLL, wparam == SB_LINERIGHT (== SB_LINEDOWN). | 180 // message == WM_HSCROLL, wparam == SB_LINERIGHT (== SB_LINEDOWN). |
| 180 if (WM_HSCROLL == message) {» | 181 if (WM_HSCROLL == message) { |
| 181 key_state |= MK_SHIFT;» | 182 key_state |= MK_SHIFT; |
| 182 wheel_delta = -wheel_delta;» | 183 wheel_delta = -wheel_delta; |
| 183 } | 184 } |
| 184 | 185 |
| 185 // Use GetAsyncKeyState for key state since we are synthesizing | 186 // Use GetAsyncKeyState for key state since we are synthesizing |
| 186 // the input | 187 // the input |
| 187 get_key_state = GetAsyncKeyState; | 188 get_key_state = GetAsyncKeyState; |
| 188 } else { | 189 } else { |
| 189 // TODO(hbono): we should add a new variable which indicates scroll | 190 // TODO(hbono): we should add a new variable which indicates scroll |
| 190 // direction and remove this key_state hack. | 191 // direction and remove this key_state hack. |
| 191 if (WM_MOUSEHWHEEL == message) | 192 if (WM_MOUSEHWHEEL == message) |
| 192 key_state |= MK_SHIFT; | 193 key_state |= MK_SHIFT; |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 303 | 304 |
| 304 WebKeyboardEvent::WebKeyboardEvent(HWND hwnd, UINT message, WPARAM wparam, | 305 WebKeyboardEvent::WebKeyboardEvent(HWND hwnd, UINT message, WPARAM wparam, |
| 305 LPARAM lparam) { | 306 LPARAM lparam) { |
| 306 system_key = false; | 307 system_key = false; |
| 307 | 308 |
| 308 actual_message.hwnd = hwnd; | 309 actual_message.hwnd = hwnd; |
| 309 actual_message.message = message; | 310 actual_message.message = message; |
| 310 actual_message.wParam = wparam; | 311 actual_message.wParam = wparam; |
| 311 actual_message.lParam = lparam; | 312 actual_message.lParam = lparam; |
| 312 | 313 |
| 313 key_code = static_cast<int>(wparam); | 314 windows_key_code = native_key_code = static_cast<int>(wparam); |
| 314 | 315 |
| 315 switch (message) { | 316 switch (message) { |
| 316 case WM_SYSKEYDOWN: | 317 case WM_SYSKEYDOWN: |
| 317 system_key = true; | 318 system_key = true; |
| 318 case WM_KEYDOWN: | 319 case WM_KEYDOWN: |
| 319 type = KEY_DOWN; | 320 type = RAW_KEY_DOWN; |
| 320 break; | 321 break; |
| 321 case WM_SYSKEYUP: | 322 case WM_SYSKEYUP: |
| 322 system_key = true; | 323 system_key = true; |
| 323 case WM_KEYUP: | 324 case WM_KEYUP: |
| 324 type = KEY_UP; | 325 type = KEY_UP; |
| 325 break; | 326 break; |
| 326 case WM_IME_CHAR: | 327 case WM_IME_CHAR: |
| 327 type = CHAR; | 328 type = CHAR; |
| 328 break; | 329 break; |
| 329 case WM_SYSCHAR: | 330 case WM_SYSCHAR: |
| 330 system_key = true; | 331 system_key = true; |
| 331 type = CHAR; | 332 type = CHAR; |
| 332 case WM_CHAR: | 333 case WM_CHAR: |
| 333 type = CHAR; | 334 type = CHAR; |
| 334 break; | 335 break; |
| 335 default: | 336 default: |
| 336 NOTREACHED() << "unexpected native message: " << message; | 337 NOTREACHED() << "unexpected native message: " << message; |
| 337 } | 338 } |
| 338 | 339 |
| 340 memset(&text, 0, sizeof(text)); |
| 341 memset(&unmodified_text, 0, sizeof(unmodified_text)); |
| 342 memset(&key_identifier, 0, sizeof(key_identifier)); |
| 343 |
| 344 if (type == CHAR || type == RAW_KEY_DOWN) |
| 345 text[0] = windows_key_code; |
| 346 unmodified_text[0] = windows_key_code; |
| 347 if (type != CHAR) { |
| 348 std::string key_identifier_str = |
| 349 GetKeyIdentifierForWindowsKeyCode(windows_key_code); |
| 350 base::strlcpy(key_identifier, key_identifier_str.c_str(), |
| 351 kIdentifierLengthCap); |
| 352 } |
| 353 |
| 339 if (GetKeyState(VK_SHIFT) & 0x8000) | 354 if (GetKeyState(VK_SHIFT) & 0x8000) |
| 340 modifiers |= SHIFT_KEY; | 355 modifiers |= SHIFT_KEY; |
| 341 if (GetKeyState(VK_CONTROL) & 0x8000) | 356 if (GetKeyState(VK_CONTROL) & 0x8000) |
| 342 modifiers |= CTRL_KEY; | 357 modifiers |= CTRL_KEY; |
| 343 if (GetKeyState(VK_MENU) & 0x8000) | 358 if (GetKeyState(VK_MENU) & 0x8000) |
| 344 modifiers |= (ALT_KEY | META_KEY); | 359 modifiers |= (ALT_KEY | META_KEY); |
| 345 | 360 |
| 346 if (LOWORD(lparam) > 1) | 361 if (LOWORD(lparam) > 1) |
| 347 modifiers |= IS_AUTO_REPEAT; | 362 modifiers |= IS_AUTO_REPEAT; |
| 348 if (IsKeyPad(wparam, lparam)) | 363 if (IsKeyPad(wparam, lparam)) |
| 349 modifiers |= IS_KEYPAD; | 364 modifiers |= IS_KEYPAD; |
| 350 } | 365 } |
| 351 | 366 |
| OLD | NEW |