Chromium Code Reviews| Index: ui/aura_shell/global_accelerator_filter.cc |
| diff --git a/ui/aura_shell/global_accelerator_filter.cc b/ui/aura_shell/global_accelerator_filter.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..94a047389207a2f9e9265f5aa2f8bb488df94b36 |
| --- /dev/null |
| +++ b/ui/aura_shell/global_accelerator_filter.cc |
| @@ -0,0 +1,61 @@ |
| +// Copyright (c) 2011 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 "ui/aura_shell/global_accelerator_filter.h" |
| + |
| +#include "ui/aura/desktop.h" |
| +#include "ui/aura/event.h" |
| +#include "ui/aura_shell/shell.h" |
| +#include "ui/base/accelerator_manager.h" |
| +#include "ui/base/models/accelerator.h" |
| + |
| +namespace { |
| +const int kModifierFlagMask = (ui::EF_SHIFT_DOWN | |
| + ui::EF_CONTROL_DOWN | |
| + ui::EF_ALT_DOWN); |
| +} |
|
tfarina
2011/11/15 15:46:23
nit: } // namespace
mazda
2011/11/15 16:16:29
Done.
|
| + |
| +namespace aura_shell { |
| +namespace internal { |
| + |
| +//////////////////////////////////////////////////////////////////////////////// |
| +// GlobalAcceleratorFilter, public: |
| + |
| +GlobalAcceleratorFilter::GlobalAcceleratorFilter() |
| + : EventFilter(aura::Desktop::GetInstance()) { |
| +} |
| + |
| +GlobalAcceleratorFilter::~GlobalAcceleratorFilter() { |
| +} |
| + |
| +//////////////////////////////////////////////////////////////////////////////// |
| +// GlobalAcceleratorFilter, EventFilter implementation: |
| + |
| +bool GlobalAcceleratorFilter::PreHandleKeyEvent(aura::Window* target, |
| + aura::KeyEvent* event) { |
| + if (event->type() == ui::ET_KEY_PRESSED && |
| + aura_shell::Shell::GetInstance()->accelerator_manager()->Process( |
|
tfarina
2011/11/15 15:46:23
can you omit aura_shell:: here, since it's already
mazda
2011/11/15 16:16:29
Done.
|
| + ui::Accelerator(event->key_code(), |
| + event->flags() & kModifierFlagMask))) { |
| + return true; |
| + } |
| + return false; |
| +} |
| + |
| +bool GlobalAcceleratorFilter::PreHandleMouseEvent(aura::Window* target, |
| + aura::MouseEvent* event) { |
| + return false; |
| +} |
| + |
| +ui::TouchStatus GlobalAcceleratorFilter::PreHandleTouchEvent( |
| + aura::Window* target, |
| + aura::TouchEvent* event) { |
| + return ui::TOUCH_STATUS_UNKNOWN; |
| +} |
| + |
| +//////////////////////////////////////////////////////////////////////////////// |
|
tfarina
2011/11/15 15:46:23
nit: Remove this?
mazda
2011/11/15 16:16:29
Done.
|
| +// GlobalAcceleratorFilter, private: |
| + |
| +} // namespace internal |
| +} // namespace aura_shell |