| Index: views/focus/accelerator_handler_win.cc
|
| ===================================================================
|
| --- views/focus/accelerator_handler_win.cc (revision 74437)
|
| +++ views/focus/accelerator_handler_win.cc (working copy)
|
| @@ -11,10 +11,41 @@
|
|
|
| namespace views {
|
|
|
| +namespace {
|
| +
|
| +// Since AcceleratorHandler's Dispatch method is called regardless of the level
|
| +// of MessageLoop nesting, we maintain a stack of MSGs so that code run from
|
| +// each loop gets the correct MSG. This scoping class handles pushing and
|
| +// popping before and after calls to DispatchMessage().
|
| +class ScopedCurrentMessage {
|
| + public:
|
| + ScopedCurrentMessage(const MSG& msg, std::vector<MSG>* msg_stack)
|
| + : msg_stack_(msg_stack) {
|
| + msg_stack_->push_back(msg);
|
| + }
|
| + ~ScopedCurrentMessage() {
|
| + msg_stack_->pop_back();
|
| + }
|
| +
|
| + private:
|
| + std::vector<MSG>* msg_stack_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(ScopedCurrentMessage);
|
| +};
|
| +
|
| +} // namespace
|
| +
|
| +// static
|
| +std::vector<MSG>* AcceleratorHandler::current_messages_ = NULL;
|
| +
|
| AcceleratorHandler::AcceleratorHandler() {
|
| }
|
|
|
| bool AcceleratorHandler::Dispatch(const MSG& msg) {
|
| + if (!current_messages_)
|
| + current_messages_ = new std::vector<MSG>;
|
| + ScopedCurrentMessage current_message(msg, current_messages_);
|
| +
|
| bool process_message = true;
|
|
|
| if (msg.message >= WM_KEYFIRST && msg.message <= WM_KEYLAST) {
|
| @@ -24,11 +55,7 @@
|
| switch (msg.message) {
|
| case WM_KEYDOWN:
|
| case WM_SYSKEYDOWN: {
|
| - KeyEvent event(ui::ET_KEY_PRESSED,
|
| - ui::KeyboardCodeForWindowsKeyCode(msg.wParam),
|
| - KeyEvent::GetKeyStateFlags(),
|
| - msg.lParam & 0xFFFF,
|
| - (msg.lParam & 0xFFFF0000) >> 16);
|
| + KeyEvent event(msg);
|
| process_message = focus_manager->OnKeyEvent(event);
|
| if (!process_message) {
|
| // Record that this key is pressed so we can remember not to
|
|
|