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