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 |