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