OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "ui/views/focus/accelerator_handler.h" | 5 #include "ui/views/focus/accelerator_handler.h" |
6 | 6 |
7 #include "ui/base/keycodes/keyboard_code_conversion_win.h" | 7 #include "ui/base/keycodes/keyboard_code_conversion_win.h" |
8 #include "ui/base/keycodes/keyboard_codes.h" | 8 #include "ui/base/keycodes/keyboard_codes.h" |
9 #include "ui/views/events/event.h" | 9 #include "ui/views/events/event.h" |
10 #include "ui/views/focus/focus_manager.h" | 10 #include "ui/views/focus/focus_manager.h" |
11 #include "ui/views/widget/widget.h" | 11 #include "ui/views/widget/widget.h" |
12 | 12 |
13 namespace views { | 13 namespace views { |
14 | 14 |
15 AcceleratorHandler::AcceleratorHandler() { | 15 AcceleratorHandler::AcceleratorHandler() { |
16 } | 16 } |
17 | 17 |
18 bool AcceleratorHandler::Dispatch(const MSG& msg) { | 18 base::DispatchStatus AcceleratorHandler::Dispatch( |
| 19 const base::NativeEvent& msg) { |
19 bool process_message = true; | 20 bool process_message = true; |
20 | 21 |
21 if (msg.message >= WM_KEYFIRST && msg.message <= WM_KEYLAST) { | 22 if (msg.message >= WM_KEYFIRST && msg.message <= WM_KEYLAST) { |
22 Widget* widget = Widget::GetTopLevelWidgetForNativeView(msg.hwnd); | 23 Widget* widget = Widget::GetTopLevelWidgetForNativeView(msg.hwnd); |
23 FocusManager* focus_manager = widget ? widget->GetFocusManager() : NULL; | 24 FocusManager* focus_manager = widget ? widget->GetFocusManager() : NULL; |
24 if (focus_manager) { | 25 if (focus_manager) { |
25 switch (msg.message) { | 26 switch (msg.message) { |
26 case WM_KEYDOWN: | 27 case WM_KEYDOWN: |
27 case WM_SYSKEYDOWN: { | 28 case WM_SYSKEYDOWN: { |
28 KeyEvent event(msg); | 29 KeyEvent event(msg); |
29 process_message = focus_manager->OnKeyEvent(event); | 30 process_message = focus_manager->OnKeyEvent(event); |
30 if (!process_message) { | 31 if (!process_message) { |
31 // Record that this key is pressed so we can remember not to | 32 // Record that this key is pressed so we can remember not to |
32 // translate and dispatch the associated WM_KEYUP. | 33 // translate and dispatch the associated WM_KEYUP. |
33 pressed_keys_.insert(msg.wParam); | 34 pressed_keys_.insert(msg.wParam); |
34 } | 35 } |
35 break; | 36 break; |
36 } | 37 } |
37 case WM_KEYUP: | 38 case WM_KEYUP: |
38 case WM_SYSKEYUP: { | 39 case WM_SYSKEYUP: { |
39 std::set<WPARAM>::iterator iter = pressed_keys_.find(msg.wParam); | 40 std::set<WPARAM>::iterator iter = pressed_keys_.find(msg.wParam); |
40 if (iter != pressed_keys_.end()) { | 41 if (iter != pressed_keys_.end()) { |
41 // Don't translate/dispatch the KEYUP since we have eaten the | 42 // Don't translate/dispatch the KEYUP since we have eaten the |
42 // associated KEYDOWN. | 43 // associated KEYDOWN. |
43 pressed_keys_.erase(iter); | 44 pressed_keys_.erase(iter); |
44 return true; | 45 return base::EVENT_PROCESSED; |
45 } | 46 } |
46 break; | 47 break; |
47 } | 48 } |
48 } | 49 } |
49 } | 50 } |
50 } | 51 } |
51 | 52 |
52 if (process_message) { | 53 if (process_message) { |
53 TranslateMessage(&msg); | 54 TranslateMessage(&msg); |
54 DispatchMessage(&msg); | 55 DispatchMessage(&msg); |
55 } | 56 } |
56 | 57 |
57 return true; | 58 return base::EVENT_PROCESSED; |
58 } | 59 } |
59 | 60 |
60 } // namespace views | 61 } // namespace views |
OLD | NEW |