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

Side by Side Diff: ui/base/ime/input_method_win.cc

Issue 13235003: Support the Text services framework based IME for Chrome AURA on Windows. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: 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/base/ime/input_method_win.h ('k') | ui/base/ime/win/mock_tsf_bridge.h » ('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/base/ime/input_method_win.h" 5 #include "ui/base/ime/input_method_win.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/debug/stack_trace.h" 8 #include "base/debug/stack_trace.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/string_util.h" 10 #include "base/string_util.h"
11 #include "base/win/metro.h"
11 #include "ui/base/events/event.h" 12 #include "ui/base/events/event.h"
12 #include "ui/base/events/event_constants.h" 13 #include "ui/base/events/event_constants.h"
13 #include "ui/base/events/event_utils.h" 14 #include "ui/base/events/event_utils.h"
14 #include "ui/base/ime/composition_text.h" 15 #include "ui/base/ime/composition_text.h"
15 #include "ui/base/ime/input_method.h" 16 #include "ui/base/ime/input_method.h"
16 #include "ui/base/ime/text_input_client.h" 17 #include "ui/base/ime/text_input_client.h"
18 #include "ui/base/ime/win/tsf_bridge.h"
17 #include "ui/base/keycodes/keyboard_codes.h" 19 #include "ui/base/keycodes/keyboard_codes.h"
18 #include "ui/base/win/hwnd_util.h" 20 #include "ui/base/win/hwnd_util.h"
19 21
20 // Extra number of chars before and after selection (or composition) range which 22 // Extra number of chars before and after selection (or composition) range which
21 // is returned to IME for improving conversion accuracy. 23 // is returned to IME for improving conversion accuracy.
22 static const size_t kExtraNumberOfChars = 20; 24 static const size_t kExtraNumberOfChars = 20;
23 25
24 namespace ui { 26 namespace ui {
25 27
26 InputMethodWin::InputMethodWin(internal::InputMethodDelegate* delegate, 28 InputMethodWin::InputMethodWin(internal::InputMethodDelegate* delegate,
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 ui::GetModifiersFromKeyState()); 101 ui::GetModifiersFromKeyState());
100 return true; 102 return true;
101 } 103 }
102 } 104 }
103 return DispatchFabricatedKeyEventPostIME(event.type(), 105 return DispatchFabricatedKeyEventPostIME(event.type(),
104 event.key_code(), 106 event.key_code(),
105 event.flags()); 107 event.flags());
106 } 108 }
107 109
108 void InputMethodWin::OnTextInputTypeChanged(const TextInputClient* client) { 110 void InputMethodWin::OnTextInputTypeChanged(const TextInputClient* client) {
111 if (base::win::IsTSFAwareRequired()) {
112 UpdateIMEState();
113 ui::TSFBridge::GetInstance()->OnTextInputTypeChanged(
114 const_cast<TextInputClient*>(client));
115 return;
cpu_(ooo_6.6-7.5) 2013/04/11 19:54:12 this seems very important to do. If the full CL is
116 }
109 if (IsTextInputClientFocused(client)) { 117 if (IsTextInputClientFocused(client)) {
110 ime_input_.CancelIME(hwnd_); 118 ime_input_.CancelIME(hwnd_);
111 UpdateIMEState(); 119 UpdateIMEState();
112 } 120 }
113 InputMethodBase::OnTextInputTypeChanged(client); 121 InputMethodBase::OnTextInputTypeChanged(client);
114 } 122 }
115 123
116 void InputMethodWin::OnCaretBoundsChanged(const TextInputClient* client) { 124 void InputMethodWin::OnCaretBoundsChanged(const TextInputClient* client) {
117 if (!enabled_ || !IsTextInputClientFocused(client)) 125 if (!enabled_ || !IsTextInputClientFocused(client))
118 return; 126 return;
119
120 // The current text input type should not be NONE if |client| is focused. 127 // The current text input type should not be NONE if |client| is focused.
121 DCHECK(!IsTextInputTypeNone()); 128 DCHECK(!IsTextInputTypeNone());
122 gfx::Rect screen_bounds(GetTextInputClient()->GetCaretBounds()); 129 gfx::Rect screen_bounds(GetTextInputClient()->GetCaretBounds());
123 // TODO(ime): see comment in TextInputClient::GetCaretBounds(), this 130 // TODO(ime): see comment in TextInputClient::GetCaretBounds(), this
124 // conversion shouldn't be necessary. 131 // conversion shouldn't be necessary.
125 RECT r; 132 RECT r;
126 GetClientRect(hwnd_, &r); 133 GetClientRect(hwnd_, &r);
127 POINT window_point = { screen_bounds.x(), screen_bounds.y() }; 134 POINT window_point = { screen_bounds.x(), screen_bounds.y() };
128 ScreenToClient(hwnd_, &window_point); 135 ScreenToClient(hwnd_, &window_point);
129 ime_input_.UpdateCaretRect( 136 ime_input_.UpdateCaretRect(
(...skipping 12 matching lines...) Expand all
142 } 149 }
143 150
144 base::i18n::TextDirection InputMethodWin::GetInputTextDirection() { 151 base::i18n::TextDirection InputMethodWin::GetInputTextDirection() {
145 return direction_; 152 return direction_;
146 } 153 }
147 154
148 bool InputMethodWin::IsActive() { 155 bool InputMethodWin::IsActive() {
149 return active_; 156 return active_;
150 } 157 }
151 158
159 void InputMethodWin::SetFocusedTextInputClient(TextInputClient* client) {
160 if (base::win::IsTSFAwareRequired()) {
161 if (client) {
162 ui::TSFBridge::GetInstance()->SetFocusedClient(hwnd_, client);
163 } else {
164 ui::TSFBridge::GetInstance()->RemoveFocusedClient(
165 ui::TSFBridge::GetInstance()->GetFocusedTextInputClient());
166 return;
167 }
168 }
169 InputMethodBase::SetFocusedTextInputClient(client);
170 }
171
172 TextInputClient* InputMethodWin::GetTextInputClient() const {
173 if (base::win::IsTSFAwareRequired())
174 return ui::TSFBridge::GetInstance()->GetFocusedTextInputClient();
175 return InputMethodBase::GetTextInputClient();
176 }
177
152 LRESULT InputMethodWin::OnImeMessages(UINT message, 178 LRESULT InputMethodWin::OnImeMessages(UINT message,
153 WPARAM w_param, 179 WPARAM w_param,
154 LPARAM l_param, 180 LPARAM l_param,
155 BOOL* handled) { 181 BOOL* handled) {
182 // Don't do traditional IME in Text services mode.
183 if (base::win::IsTSFAwareRequired() &&
184 message != WM_CHAR &&
185 message != WM_SYSCHAR &&
186 message != WM_DEADCHAR &&
187 message != WM_SYSDEADCHAR &&
188 message != WM_IME_SETCONTEXT) {
189 return false;
190 }
156 LRESULT result = 0; 191 LRESULT result = 0;
157 switch (message) { 192 switch (message) {
158 case WM_IME_SETCONTEXT: 193 case WM_IME_SETCONTEXT:
159 result = OnImeSetContext(message, w_param, l_param, handled); 194 result = OnImeSetContext(message, w_param, l_param, handled);
160 break; 195 break;
161 case WM_IME_STARTCOMPOSITION: 196 case WM_IME_STARTCOMPOSITION:
162 result = OnImeStartComposition(message, w_param, l_param, handled); 197 result = OnImeStartComposition(message, w_param, l_param, handled);
163 break; 198 break;
164 case WM_IME_COMPOSITION: 199 case WM_IME_COMPOSITION:
165 result = OnImeComposition(message, w_param, l_param, handled); 200 result = OnImeComposition(message, w_param, l_param, handled);
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after
501 enabled_ = false; 536 enabled_ = false;
502 break; 537 break;
503 default: 538 default:
504 ime_input_.EnableIME(hwnd_); 539 ime_input_.EnableIME(hwnd_);
505 enabled_ = true; 540 enabled_ = true;
506 break; 541 break;
507 } 542 }
508 } 543 }
509 544
510 } // namespace ui 545 } // namespace ui
OLDNEW
« no previous file with comments | « ui/base/ime/input_method_win.h ('k') | ui/base/ime/win/mock_tsf_bridge.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698