Chromium Code Reviews| Index: ash/accelerators/accelerator_dispatcher_linux.cc |
| diff --git a/ash/accelerators/accelerator_dispatcher_linux.cc b/ash/accelerators/accelerator_dispatcher_linux.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..5675f38850c7afaaba4b22e968c5ac55df135341 |
| --- /dev/null |
| +++ b/ash/accelerators/accelerator_dispatcher_linux.cc |
| @@ -0,0 +1,48 @@ |
| +// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "ash/accelerators/accelerator_dispatcher.h" |
| + |
| +#include <X11/Xlib.h> |
| + |
| +// Xlib defines RootWindow |
| +#ifdef RootWindow |
| +#undef RootWindow |
| +#endif |
| + |
| +#include "ash/accelerators/accelerator_controller.h" |
| +#include "ash/shell.h" |
| +#include "base/message_loop.h" |
| +#include "base/message_pump_x.h" |
|
oshima
2012/01/31 20:42:00
are these two necessary?
|
| +#include "ui/aura/event.h" |
| +#include "ui/aura/root_window.h" |
| +#include "ui/base/accelerators/accelerator.h" |
| + |
| +namespace ash { |
| + |
| +namespace { |
| + |
| +const int kModifierMask = (ui::EF_SHIFT_DOWN | |
| + ui::EF_CONTROL_DOWN | |
| + ui::EF_ALT_DOWN); |
| +} // namespace |
| + |
| +base::MessagePumpDispatcher::DispatchStatus AcceleratorDispatcher::Dispatch( |
| + XEvent* xev) { |
| + ash::Shell* shell = ash::Shell::GetInstance(); |
| + if (shell->IsScreenLocked()) |
|
oshima
2012/01/31 20:42:00
one liner too. same for win.
pkotwicz
2012/02/01 19:11:31
I need to use shell later, so it makes sense to ke
|
| + return aura::RootWindow::GetInstance()->GetDispatcher()->Dispatch(xev); |
| + |
| + if (xev->type == KeyPress) { |
| + ash::AcceleratorController* accelerator_controller = |
| + shell->accelerator_controller(); |
| + ui::Accelerator accelerator(ui::KeyboardCodeFromNative(xev), |
| + ui::EventFlagsFromNative(xev) & kModifierMask); |
| + if (accelerator_controller && accelerator_controller->Process(accelerator)) |
| + return EVENT_PROCESSED; |
| + } |
| + return nested_dispatcher_->Dispatch(xev); |
| +} |
| + |
| +} // namespace ash |