OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 "views/focus/accelerator_handler.h" | 5 #include "views/focus/accelerator_handler.h" |
6 | 6 |
7 #include "base/keyboard_codes.h" | 7 #include "app/keyboard_code_conversion_win.h" |
| 8 #include "app/keyboard_codes.h" |
8 #include "base/win_util.h" | 9 #include "base/win_util.h" |
9 #include "views/event.h" | 10 #include "views/event.h" |
10 #include "views/focus/focus_manager.h" | 11 #include "views/focus/focus_manager.h" |
11 | 12 |
12 namespace views { | 13 namespace views { |
13 | 14 |
14 AcceleratorHandler::AcceleratorHandler() { | 15 AcceleratorHandler::AcceleratorHandler() { |
15 } | 16 } |
16 | 17 |
17 bool AcceleratorHandler::Dispatch(const MSG& msg) { | 18 bool AcceleratorHandler::Dispatch(const MSG& msg) { |
18 bool process_message = true; | 19 bool process_message = true; |
19 | 20 |
20 if (msg.message >= WM_KEYFIRST && msg.message <= WM_KEYLAST) { | 21 if (msg.message >= WM_KEYFIRST && msg.message <= WM_KEYLAST) { |
21 FocusManager* focus_manager = | 22 FocusManager* focus_manager = |
22 FocusManager::GetFocusManagerForNativeView(msg.hwnd); | 23 FocusManager::GetFocusManagerForNativeView(msg.hwnd); |
23 if (focus_manager) { | 24 if (focus_manager) { |
24 switch (msg.message) { | 25 switch (msg.message) { |
25 case WM_KEYDOWN: | 26 case WM_KEYDOWN: |
26 case WM_SYSKEYDOWN: { | 27 case WM_SYSKEYDOWN: { |
27 KeyEvent event(Event::ET_KEY_PRESSED, | 28 KeyEvent event(Event::ET_KEY_PRESSED, |
28 win_util::WinToKeyboardCode(msg.wParam), | 29 app::KeyboardCodeForWindowsKeyCode(msg.wParam), |
29 KeyEvent::GetKeyStateFlags(), | 30 KeyEvent::GetKeyStateFlags(), |
30 msg.lParam & 0xFFFF, | 31 msg.lParam & 0xFFFF, |
31 (msg.lParam & 0xFFFF0000) >> 16); | 32 (msg.lParam & 0xFFFF0000) >> 16); |
32 process_message = focus_manager->OnKeyEvent(event); | 33 process_message = focus_manager->OnKeyEvent(event); |
33 if (!process_message) { | 34 if (!process_message) { |
34 // Record that this key is pressed so we can remember not to | 35 // Record that this key is pressed so we can remember not to |
35 // translate and dispatch the associated WM_KEYUP. | 36 // translate and dispatch the associated WM_KEYUP. |
36 pressed_keys_.insert(msg.wParam); | 37 pressed_keys_.insert(msg.wParam); |
37 } | 38 } |
38 break; | 39 break; |
(...skipping 15 matching lines...) Expand all Loading... |
54 | 55 |
55 if (process_message) { | 56 if (process_message) { |
56 TranslateMessage(&msg); | 57 TranslateMessage(&msg); |
57 DispatchMessage(&msg); | 58 DispatchMessage(&msg); |
58 } | 59 } |
59 | 60 |
60 return true; | 61 return true; |
61 } | 62 } |
62 | 63 |
63 } // namespace views | 64 } // namespace views |
OLD | NEW |