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

Unified Diff: ui/aura_shell/input_method_event_filter.cc

Issue 8576005: IME (input method editor) support for Aura, part 3 of 3: Use ui::InputMethod in ash. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: moving IME code to aura_shell. not ready for review Created 9 years 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/input_method_event_filter.h ('k') | ui/aura_shell/shell.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/aura_shell/input_method_event_filter.cc
diff --git a/ui/aura_shell/input_method_event_filter.cc b/ui/aura_shell/input_method_event_filter.cc
new file mode 100644
index 0000000000000000000000000000000000000000..1e1e0873064e385a69d5cc3c052982610bf306d0
--- /dev/null
+++ b/ui/aura_shell/input_method_event_filter.cc
@@ -0,0 +1,74 @@
+// 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/input_method_event_filter.h"
+
+#include "ui/aura/event.h"
+#include "ui/aura/root_window.h"
+#include "ui/aura_shell/shell.h"
+
+#if defined(HAVE_IBUS)
+#include "ui/base/ime/input_method_ibus.h"
+#else
+#include "ui/base/ime/mock_input_method.h"
+#endif
+
+namespace aura_shell {
+namespace internal {
+
+////////////////////////////////////////////////////////////////////////////////
+// InputMethodEventFilter, public:
+
+InputMethodEventFilter::InputMethodEventFilter()
+ : EventFilter(aura::RootWindow::GetInstance()),
+#if defined(HAVE_IBUS)
+ ALLOW_THIS_IN_INITIALIZER_LIST(
+ input_method_(new ui::InputMethodIBus(this)))
+#else
+ ALLOW_THIS_IN_INITIALIZER_LIST(
+ input_method_(new ui::MockInputMethod(this)))
+#endif
+{
+ // TODO(yusukes): Check if the root window is currently focused and pass the
+ // result to Init().
+ input_method_->Init(true);
+ aura::RootWindow::GetInstance()->set_input_method(input_method_.get());
+}
+
+InputMethodEventFilter::~InputMethodEventFilter() {
+ aura::RootWindow::GetInstance()->set_input_method(NULL);
+}
+
+////////////////////////////////////////////////////////////////////////////////
+// InputMethodEventFilter, EventFilter implementation:
+
+bool InputMethodEventFilter::PreHandleKeyEvent(aura::Window* target,
+ aura::KeyEvent* event) {
+ if (event->skip_ime())
+ return false;
+ input_method_->DispatchKeyEvent(event->native_event());
+ return true;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+// InputMethodEventFilter, ui::InputMethodDelegate implementation:
+
+void InputMethodEventFilter::DispatchKeyEventPostIME(
+ const base::NativeEvent& event) {
+ aura::KeyEvent aura_event(event, false /* is_char */);
+ aura_event.set_skip_ime(true);
+ aura::RootWindow::GetInstance()->DispatchKeyEvent(&aura_event);
+}
+
+void InputMethodEventFilter::DispatchFabricatedKeyEventPostIME(
+ ui::EventType type,
+ ui::KeyboardCode key_code,
+ int flags) {
+ aura::KeyEvent aura_event(type, key_code, flags);
+ aura_event.set_skip_ime(true);
+ aura::RootWindow::GetInstance()->DispatchKeyEvent(&aura_event);
+}
+
+} // namespace internal
+} // namespace aura_shell
« no previous file with comments | « ui/aura_shell/input_method_event_filter.h ('k') | ui/aura_shell/shell.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698