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

Unified Diff: ash/wm/key_rewriter_event_filter.cc

Issue 9838010: Automatically remap Command key on an Apple keyboard to Control [part 1 of 2 - Ash part] (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: review fix Created 8 years, 9 months 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 | « ash/wm/key_rewriter_event_filter.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/wm/key_rewriter_event_filter.cc
diff --git a/ash/wm/key_rewriter_event_filter.cc b/ash/wm/key_rewriter_event_filter.cc
new file mode 100644
index 0000000000000000000000000000000000000000..30ba84da34db0b3bda5e4d74da55a37547909a5d
--- /dev/null
+++ b/ash/wm/key_rewriter_event_filter.cc
@@ -0,0 +1,61 @@
+// 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/wm/key_rewriter_event_filter.h"
+
+#include "base/logging.h"
+#include "ash/key_rewriter_delegate.h"
+#include "ui/aura/event.h"
+
+namespace ash {
+namespace internal {
+
+KeyRewriterEventFilter::KeyRewriterEventFilter() {}
+
+KeyRewriterEventFilter::~KeyRewriterEventFilter() {}
+
+void KeyRewriterEventFilter::SetKeyRewriterDelegate(
+ scoped_ptr<KeyRewriterDelegate> delegate) {
+ delegate_.swap(delegate);
+}
+
+bool KeyRewriterEventFilter::PreHandleKeyEvent(
+ aura::Window* target, aura::KeyEvent* event) {
+ if (!delegate_.get())
+ return false;
+
+ // Do not consume a translated key event which is generated by an IME.
+ if (event->type() == ui::ET_TRANSLATED_KEY_PRESS ||
+ event->type() == ui::ET_TRANSLATED_KEY_RELEASE) {
+ return false;
+ }
+
+ switch (delegate_->RewriteOrFilterKeyEvent(event)) {
+ case KeyRewriterDelegate::ACTION_REWRITE_EVENT:
+ return false;
+ case KeyRewriterDelegate::ACTION_DROP_EVENT:
+ return true;
+ }
+
+ NOTREACHED();
+ return false;
+}
+
+bool KeyRewriterEventFilter::PreHandleMouseEvent(
+ aura::Window* target, aura::MouseEvent* event) {
+ return false; // Not handled.
+}
+
+ui::TouchStatus KeyRewriterEventFilter::PreHandleTouchEvent(
+ aura::Window* target, aura::TouchEvent* event) {
+ return ui::TOUCH_STATUS_UNKNOWN; // Not handled.
+}
+
+ui::GestureStatus KeyRewriterEventFilter::PreHandleGestureEvent(
+ aura::Window* target, aura::GestureEvent* event) {
+ return ui::GESTURE_STATUS_UNKNOWN; // Not handled.
+}
+
+} // namespace internal
+} // namespace ash
« no previous file with comments | « ash/wm/key_rewriter_event_filter.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698