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

Unified Diff: ui/base/ime/input_method_ibus_aura.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: rebase, review 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
Index: ui/base/ime/input_method_ibus_aura.cc
diff --git a/ui/base/ime/input_method_ibus_aura.cc b/ui/base/ime/input_method_ibus_aura.cc
new file mode 100644
index 0000000000000000000000000000000000000000..fbd3b244f051cee9fc5bb26a576a06dab2342750
--- /dev/null
+++ b/ui/base/ime/input_method_ibus_aura.cc
@@ -0,0 +1,58 @@
+// 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/base/ime/input_method_ibus_aura.h"
+
+#include "base/logging.h"
+#include "ui/aura/desktop.h"
+#include "ui/aura/event.h"
+#include "ui/base/ime/text_input_client.h"
+#include "ui/base/ime/input_method_delegate.h"
+
+namespace ui {
+
+InputMethodIBusAura::InputMethodIBusAura(
+ internal::InputMethodDelegate* delegate)
+ : InputMethodIBus(delegate),
+ active_window_(NULL) {
+}
+
+InputMethodIBusAura::~InputMethodIBusAura() {
+ aura::Desktop* desktop = aura::Desktop::GetInstance();
+ desktop->RemoveObserver(this);
+}
+
+void InputMethodIBusAura::Init() {
+ aura::Desktop* desktop = aura::Desktop::GetInstance();
+ aura::Window* active_window = desktop->active_window();
+ if (active_window)
+ OnActiveWindowChanged(active_window);
+ desktop->AddObserver(this);
+ InputMethodIBus::Init();
+}
+
+void InputMethodIBusAura::OnActiveWindowChanged(
+ aura::Window* new_active_window) {
+ active_window_ = new_active_window;
+ UpdateContextFocusState();
+ // We don't have to confirm/cancel a composition text here because the window
+ // which is losing focus will do that.
+}
+
+bool InputMethodIBusAura::IsWindowFocused(aura::Window* window) const {
+ if (!active_window_ || !window)
+ return false;
+
+ // Return true if |window| is in the |active_window_|'s tree.
+ aura::Window* current = window;
+ while (current) {
+ if (active_window_ == current)
+ return true;
+ current = current->parent();
+ }
+
+ return false;
+}
+
+} // namespace ui

Powered by Google App Engine
This is Rietveld 408576698