| 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 = FocusManager::GetFocusManager(msg.hwnd); | 18 FocusManager* focus_manager = |
| 19 FocusManager::GetFocusManagerForNativeView(msg.hwnd); |
| 19 if (focus_manager) { | 20 if (focus_manager) { |
| 20 // FocusManager::OnKeyDown and OnKeyUp return false if this message has | 21 // FocusManager::OnKeyDown and OnKeyUp return false if this message has |
| 21 // been consumed and should not be propagated further. | 22 // been consumed and should not be propagated further. |
| 22 switch (msg.message) { | 23 switch (msg.message) { |
| 23 case WM_KEYDOWN: | 24 case WM_KEYDOWN: |
| 24 case WM_SYSKEYDOWN: | 25 case WM_SYSKEYDOWN: |
| 25 process_message = focus_manager->OnKeyDown(msg.hwnd, msg.message, | 26 process_message = focus_manager->OnKeyDown(msg.hwnd, msg.message, |
| 26 msg.wParam, msg.lParam); | 27 msg.wParam, msg.lParam); |
| 27 break; | 28 break; |
| 28 | 29 |
| 29 case WM_KEYUP: | 30 case WM_KEYUP: |
| 30 case WM_SYSKEYUP: | 31 case WM_SYSKEYUP: |
| 31 process_message = focus_manager->OnKeyUp(msg.hwnd, msg.message, | 32 process_message = focus_manager->OnKeyUp(msg.hwnd, msg.message, |
| 32 msg.wParam, msg.lParam); | 33 msg.wParam, msg.lParam); |
| 33 break; | 34 break; |
| 34 } | 35 } |
| 35 } | 36 } |
| 36 } | 37 } |
| 37 | 38 |
| 38 if (process_message) { | 39 if (process_message) { |
| 39 TranslateMessage(&msg); | 40 TranslateMessage(&msg); |
| 40 DispatchMessage(&msg); | 41 DispatchMessage(&msg); |
| 41 } | 42 } |
| 42 | 43 |
| 43 return true; | 44 return true; |
| 44 } | 45 } |
| 45 | 46 |
| 46 } // namespace views | 47 } // namespace views |
| OLD | NEW |