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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "ui/base/ime/input_method_ibus_aura.h"
6
7 #include "base/logging.h"
8 #include "ui/aura/desktop.h"
9 #include "ui/aura/event.h"
10 #include "ui/base/ime/text_input_client.h"
11 #include "ui/base/ime/input_method_delegate.h"
12
13 namespace ui {
14
15 InputMethodIBusAura::InputMethodIBusAura(
16 internal::InputMethodDelegate* delegate)
17 : InputMethodIBus(delegate),
18 active_window_(NULL) {
19 }
20
21 InputMethodIBusAura::~InputMethodIBusAura() {
22 aura::Desktop* desktop = aura::Desktop::GetInstance();
23 desktop->RemoveObserver(this);
24 }
25
26 void InputMethodIBusAura::Init() {
27 aura::Desktop* desktop = aura::Desktop::GetInstance();
28 aura::Window* active_window = desktop->active_window();
29 if (active_window)
30 OnActiveWindowChanged(active_window);
31 desktop->AddObserver(this);
32 InputMethodIBus::Init();
33 }
34
35 void InputMethodIBusAura::OnActiveWindowChanged(
36 aura::Window* new_active_window) {
37 active_window_ = new_active_window;
38 UpdateContextFocusState();
39 // We don't have to confirm/cancel a composition text here because the window
40 // which is losing focus will do that.
41 }
42
43 bool InputMethodIBusAura::IsWindowFocused(aura::Window* window) const {
44 if (!active_window_ || !window)
45 return false;
46
47 // Return true if |window| is in the |active_window_|'s tree.
48 aura::Window* current = window;
49 while (current) {
50 if (active_window_ == current)
51 return true;
52 current = current->parent();
53 }
54
55 return false;
56 }
57
58 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698