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

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: moved IME code to aura_shell, not ready for review though 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
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..cb2a24bf3bfe1868bf9f955002dc190a1ecb518e
--- /dev/null
+++ b/ui/aura_shell/input_method_event_filter.cc
@@ -0,0 +1,76 @@
+// 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()) {
+ ui::InputMethod* input_method;
+#if defined(HAVE_IBUS)
+ input_method = new ui::InputMethodIBus(this);
Ben Goodger (Google) 2011/12/12 16:51:03 I've seen this pattern (and the associated include
Yusuke Sato 2011/12/14 13:42:04 Done.
+#else
+ 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);
+ // Pass ownership.
+ aura::RootWindow::GetInstance()->SetInputMethod(input_method);
+}
+
+InputMethodEventFilter::~InputMethodEventFilter() {
+}
+
+////////////////////////////////////////////////////////////////////////////////
+// InputMethodEventFilter, EventFilter implementation:
+
+bool InputMethodEventFilter::PreHandleKeyEvent(aura::Window* target,
+ aura::KeyEvent* event) {
+ if (event->skip_ime())
+ return false;
+
+ ui::InputMethod* input_method =
+ aura::RootWindow::GetInstance()->GetInputMethod();
+ DCHECK(input_method);
+ 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

Powered by Google App Engine
This is Rietveld 408576698