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