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 <X11/Xlib.h> |
| 8 |
| 9 // Xlib defines RootWindow |
| 10 #ifdef RootWindow |
| 11 #undef RootWindow |
| 12 #endif |
| 13 |
| 14 #include "ash/accelerators/accelerator_controller.h" |
| 15 #include "ash/shell.h" |
| 16 #include "ui/aura/event.h" |
| 17 #include "ui/aura/root_window.h" |
| 18 #include "ui/base/accelerators/accelerator.h" |
| 19 |
| 20 namespace ash { |
| 21 |
| 22 namespace { |
| 23 |
| 24 const int kModifierMask = (ui::EF_SHIFT_DOWN | |
| 25 ui::EF_CONTROL_DOWN | |
| 26 ui::EF_ALT_DOWN); |
| 27 } // namespace |
| 28 |
| 29 base::MessagePumpDispatcher::DispatchStatus AcceleratorDispatcher::Dispatch( |
| 30 XEvent* xev) { |
| 31 ash::Shell* shell = ash::Shell::GetInstance(); |
| 32 if (shell->IsScreenLocked()) |
| 33 return aura::RootWindow::GetInstance()->GetDispatcher()->Dispatch(xev); |
| 34 |
| 35 if (xev->type == KeyPress) { |
| 36 ash::AcceleratorController* accelerator_controller = |
| 37 shell->accelerator_controller(); |
| 38 ui::Accelerator accelerator(ui::KeyboardCodeFromNative(xev), |
| 39 ui::EventFlagsFromNative(xev) & kModifierMask); |
| 40 if (accelerator_controller && accelerator_controller->Process(accelerator)) |
| 41 return EVENT_PROCESSED; |
| 42 } |
| 43 return nested_dispatcher_->Dispatch(xev); |
| 44 } |
| 45 |
| 46 } // namespace ash |
OLD | NEW |