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

Side by Side Diff: ui/views/ime/input_method_bridge.cc

Issue 12902029: Fix InputMethod Widget activation checks; cleanup, etc. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments. Created 7 years, 8 months 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
« no previous file with comments | « ui/views/ime/input_method_base.cc ('k') | ui/views/ime/input_method_win.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/views/ime/input_method_bridge.h" 5 #include "ui/views/ime/input_method_bridge.h"
6 6
7 #include "ui/base/events/event.h" 7 #include "ui/base/events/event.h"
8 #include "ui/base/ime/input_method.h" 8 #include "ui/base/ime/input_method.h"
9 #include "ui/gfx/rect.h" 9 #include "ui/gfx/rect.h"
10 #include "ui/views/view.h" 10 #include "ui/views/view.h"
11 #include "ui/views/widget/widget.h" 11 #include "ui/views/widget/widget.h"
12 12
13 namespace views { 13 namespace views {
14 14
15 InputMethodBridge::InputMethodBridge(internal::InputMethodDelegate* delegate, 15 InputMethodBridge::InputMethodBridge(internal::InputMethodDelegate* delegate,
16 ui::InputMethod* host, 16 ui::InputMethod* host,
17 bool shared_input_method) 17 bool shared_input_method)
18 : host_(host), 18 : host_(host),
19 shared_input_method_(shared_input_method), 19 shared_input_method_(shared_input_method),
20 context_focused_(false) { 20 context_focused_(false) {
21 DCHECK(host_); 21 DCHECK(host_);
22 set_delegate(delegate); 22 SetDelegate(delegate);
23 } 23 }
24 24
25 InputMethodBridge::~InputMethodBridge() { 25 InputMethodBridge::~InputMethodBridge() {
26 if (host_->GetTextInputClient() == this) 26 if (host_->GetTextInputClient() == this)
27 host_->SetFocusedTextInputClient(NULL); 27 host_->SetFocusedTextInputClient(NULL);
28 } 28 }
29 29
30 void InputMethodBridge::Init(Widget* widget) { 30 void InputMethodBridge::Init(Widget* widget) {
31 InputMethodBase::Init(widget); 31 InputMethodBase::Init(widget);
32 } 32 }
33 33
34 void InputMethodBridge::OnFocus() { 34 void InputMethodBridge::OnFocus() {
35 InputMethodBase::OnFocus(); 35 // Direct the shared IME to send TextInputClient messages to |this| object.
36
37 // Ask the system-wide IME to send all TextInputClient messages to |this|
38 // object.
39 if (shared_input_method_ || !host_->GetTextInputClient()) 36 if (shared_input_method_ || !host_->GetTextInputClient())
40 host_->SetFocusedTextInputClient(this); 37 host_->SetFocusedTextInputClient(this);
41 38
42 // TODO(yusukes): We don't need to call OnTextInputTypeChanged() once we move 39 // TODO(yusukes): We don't need to call OnTextInputTypeChanged() once we move
43 // text input type tracker code to ui::InputMethodBase. 40 // text input type tracker code to ui::InputMethodBase.
44 if (GetFocusedView()) 41 if (GetFocusedView())
45 OnTextInputTypeChanged(GetFocusedView()); 42 OnTextInputTypeChanged(GetFocusedView());
46 } 43 }
47 44
48 void InputMethodBridge::OnBlur() { 45 void InputMethodBridge::OnBlur() {
49 // win32 sends multiple focus lost events, ignore all but the first.
50 if (widget_focused())
51 return;
52
53 ConfirmCompositionText(); 46 ConfirmCompositionText();
54 InputMethodBase::OnBlur();
55 if (host_->GetTextInputClient() == this) 47 if (host_->GetTextInputClient() == this)
56 host_->SetFocusedTextInputClient(NULL); 48 host_->SetFocusedTextInputClient(NULL);
57 } 49 }
58 50
59 void InputMethodBridge::DispatchKeyEvent(const ui::KeyEvent& key) { 51 void InputMethodBridge::DispatchKeyEvent(const ui::KeyEvent& key) {
60 DCHECK(key.type() == ui::ET_KEY_PRESSED || key.type() == ui::ET_KEY_RELEASED); 52 DCHECK(key.type() == ui::ET_KEY_PRESSED || key.type() == ui::ET_KEY_RELEASED);
61 53
62 // We can just dispatch the event here since the |key| is already processed by 54 // We can just dispatch the event here since the |key| is already processed by
63 // the system-wide IME. 55 // the system-wide IME.
64 DispatchKeyEventPostIME(key); 56 DispatchKeyEventPostIME(key);
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 void InputMethodBridge::OnWillChangeFocus(View* focused_before, View* focused) { 220 void InputMethodBridge::OnWillChangeFocus(View* focused_before, View* focused) {
229 ConfirmCompositionText(); 221 ConfirmCompositionText();
230 } 222 }
231 223
232 void InputMethodBridge::OnDidChangeFocus(View* focused_before, View* focused) { 224 void InputMethodBridge::OnDidChangeFocus(View* focused_before, View* focused) {
233 OnTextInputTypeChanged(GetFocusedView()); 225 OnTextInputTypeChanged(GetFocusedView());
234 OnCaretBoundsChanged(GetFocusedView()); 226 OnCaretBoundsChanged(GetFocusedView());
235 } 227 }
236 228
237 } // namespace views 229 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/ime/input_method_base.cc ('k') | ui/views/ime/input_method_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698