Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(263)

Unified Diff: ui/aura_shell/shell_accelerator_filter.cc

Issue 8561012: Add ShellAcceleratorController that manages global keyboard accelerators (2nd try). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/aura_shell/shell_accelerator_filter.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/aura_shell/shell_accelerator_filter.cc
diff --git a/ui/aura_shell/shell_accelerator_filter.cc b/ui/aura_shell/shell_accelerator_filter.cc
new file mode 100644
index 0000000000000000000000000000000000000000..3a9cde5b38778792bb9f08a911e5a4fc1eb6309b
--- /dev/null
+++ b/ui/aura_shell/shell_accelerator_filter.cc
@@ -0,0 +1,59 @@
+// 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/shell_accelerator_filter.h"
+
+#include "ui/aura/desktop.h"
+#include "ui/aura/event.h"
+#include "ui/aura_shell/shell.h"
+#include "ui/aura_shell/shell_accelerator_controller.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);
+} // namespace
+
+namespace aura_shell {
+namespace internal {
+
+////////////////////////////////////////////////////////////////////////////////
+// ShellAcceleratorFilter, public:
+
+ShellAcceleratorFilter::ShellAcceleratorFilter()
+ : EventFilter(aura::Desktop::GetInstance()) {
+}
+
+ShellAcceleratorFilter::~ShellAcceleratorFilter() {
+}
+
+////////////////////////////////////////////////////////////////////////////////
+// ShellAcceleratorFilter, EventFilter implementation:
+
+bool ShellAcceleratorFilter::PreHandleKeyEvent(aura::Window* target,
+ aura::KeyEvent* event) {
+ if (event->type() == ui::ET_KEY_PRESSED &&
+ Shell::GetInstance()->accelerator_controller()->Process(
+ ui::Accelerator(event->key_code(),
+ event->flags() & kModifierFlagMask))) {
+ return true;
+ }
+ return false;
+}
+
+bool ShellAcceleratorFilter::PreHandleMouseEvent(aura::Window* target,
+ aura::MouseEvent* event) {
+ return false;
+}
+
+ui::TouchStatus ShellAcceleratorFilter::PreHandleTouchEvent(
+ aura::Window* target,
+ aura::TouchEvent* event) {
+ return ui::TOUCH_STATUS_UNKNOWN;
+}
+
+} // namespace internal
+} // namespace aura_shell
« no previous file with comments | « ui/aura_shell/shell_accelerator_filter.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698