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