OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "ash/accelerators/accelerator_dispatcher.h" | 5 #include "ash/accelerators/accelerator_dispatcher.h" |
6 | 6 |
7 #include "ash/accelerators/accelerator_controller.h" | 7 #include "ash/accelerators/accelerator_controller.h" |
8 #include "ash/shell.h" | 8 #include "ash/shell.h" |
9 #include "ui/aura/event.h" | 9 #include "ui/aura/event.h" |
10 #include "ui/aura/root_window.h" | 10 #include "ui/aura/root_window.h" |
11 #include "ui/base/accelerators/accelerator.h" | 11 #include "ui/base/accelerators/accelerator.h" |
12 | 12 |
13 namespace ash { | 13 namespace ash { |
14 | 14 |
15 namespace { | 15 namespace { |
16 | 16 |
17 const int kModifierMask = (ui::EF_SHIFT_DOWN | | 17 const int kModifierMask = (ui::EF_SHIFT_DOWN | |
18 ui::EF_CONTROL_DOWN | | 18 ui::EF_CONTROL_DOWN | |
19 ui::EF_ALT_DOWN); | 19 ui::EF_ALT_DOWN); |
20 } // namespace | 20 } // namespace |
21 | 21 |
22 bool AcceleratorDispatcher::Dispatch(const MSG& msg) { | 22 bool AcceleratorDispatcher::Dispatch(const MSG& msg) { |
| 23 if (!associated_window_) |
| 24 return false; |
23 if (!associated_window_->CanReceiveEvents()) | 25 if (!associated_window_->CanReceiveEvents()) |
24 return aura::RootWindow::GetInstance()->GetDispatcher()->Dispatch(msg); | 26 return aura::RootWindow::GetInstance()->GetDispatcher()->Dispatch(msg); |
25 | 27 |
26 if(msg.message == WM_KEYDOWN || msg.message == WM_SYSKEYDOWN) { | 28 if(msg.message == WM_KEYDOWN || msg.message == WM_SYSKEYDOWN) { |
27 ash::AcceleratorController* accelerator_controller = | 29 ash::AcceleratorController* accelerator_controller = |
28 ash::Shell::GetInstance()->accelerator_controller(); | 30 ash::Shell::GetInstance()->accelerator_controller(); |
29 ui::Accelerator accelerator(ui::KeyboardCodeFromNative(msg), | 31 ui::Accelerator accelerator(ui::KeyboardCodeFromNative(msg), |
30 ui::EventFlagsFromNative(msg) & kModifierMask); | 32 ui::EventFlagsFromNative(msg) & kModifierMask); |
31 if (accelerator_controller && accelerator_controller->Process(accelerator)) | 33 if (accelerator_controller && accelerator_controller->Process(accelerator)) |
32 return true; | 34 return true; |
33 } | 35 } |
34 | 36 |
35 return nested_dispatcher_->Dispatch(msg); | 37 return nested_dispatcher_->Dispatch(msg); |
36 } | 38 } |
37 | 39 |
38 } // namespace ash | 40 } // namespace ash |
OLD | NEW |