| 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 "views/widget/accelerator_handler.h" | 5 #include "views/widget/accelerator_handler.h" |
| 6 | 6 |
| 7 #include "views/focus/focus_manager.h" | 7 #include "views/focus/focus_manager.h" |
| 8 | 8 |
| 9 namespace views { | 9 namespace views { |
| 10 | 10 |
| 11 AcceleratorHandler::AcceleratorHandler() { | 11 AcceleratorHandler::AcceleratorHandler() { |
| 12 } | 12 } |
| 13 | 13 |
| 14 bool AcceleratorHandler::Dispatch(const MSG& msg) { | 14 bool AcceleratorHandler::Dispatch(const MSG& msg) { |
| 15 bool process_message = true; | 15 bool process_message = true; |
| 16 | 16 |
| 17 if (msg.message >= WM_KEYFIRST && msg.message <= WM_KEYLAST) { | 17 if (msg.message >= WM_KEYFIRST && msg.message <= WM_KEYLAST) { |
| 18 FocusManager* focus_manager = | 18 FocusManager* focus_manager = FocusManager::GetFocusManager(msg.hwnd); |
| 19 FocusManager::GetFocusManagerForNativeView(msg.hwnd); | |
| 20 if (focus_manager) { | 19 if (focus_manager) { |
| 21 // FocusManager::OnKeyDown and OnKeyUp return false if this message has | 20 // FocusManager::OnKeyDown and OnKeyUp return false if this message has |
| 22 // been consumed and should not be propagated further. | 21 // been consumed and should not be propagated further. |
| 23 switch (msg.message) { | 22 switch (msg.message) { |
| 24 case WM_KEYDOWN: | 23 case WM_KEYDOWN: |
| 25 case WM_SYSKEYDOWN: | 24 case WM_SYSKEYDOWN: |
| 26 process_message = focus_manager->OnKeyDown(msg.hwnd, msg.message, | 25 process_message = focus_manager->OnKeyDown(msg.hwnd, msg.message, |
| 27 msg.wParam, msg.lParam); | 26 msg.wParam, msg.lParam); |
| 28 break; | 27 break; |
| 29 | 28 |
| 30 case WM_KEYUP: | 29 case WM_KEYUP: |
| 31 case WM_SYSKEYUP: | 30 case WM_SYSKEYUP: |
| 32 process_message = focus_manager->OnKeyUp(msg.hwnd, msg.message, | 31 process_message = focus_manager->OnKeyUp(msg.hwnd, msg.message, |
| 33 msg.wParam, msg.lParam); | 32 msg.wParam, msg.lParam); |
| 34 break; | 33 break; |
| 35 } | 34 } |
| 36 } | 35 } |
| 37 } | 36 } |
| 38 | 37 |
| 39 if (process_message) { | 38 if (process_message) { |
| 40 TranslateMessage(&msg); | 39 TranslateMessage(&msg); |
| 41 DispatchMessage(&msg); | 40 DispatchMessage(&msg); |
| 42 } | 41 } |
| 43 | 42 |
| 44 return true; | 43 return true; |
| 45 } | 44 } |
| 46 | 45 |
| 47 } // namespace views | 46 } // namespace views |
| OLD | NEW |