OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/remote_input_method_win.h" | 5 #include "ui/base/ime/remote_input_method_win.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/observer_list.h" | 8 #include "base/observer_list.h" |
9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
10 #include "base/win/metro.h" | 10 #include "base/win/metro.h" |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
176 } | 176 } |
177 | 177 |
178 TextInputClient* GetTextInputClient() const override { | 178 TextInputClient* GetTextInputClient() const override { |
179 return text_input_client_; | 179 return text_input_client_; |
180 } | 180 } |
181 | 181 |
182 void DispatchKeyEvent(ui::KeyEvent* event) override { | 182 void DispatchKeyEvent(ui::KeyEvent* event) override { |
183 if (event->HasNativeEvent()) { | 183 if (event->HasNativeEvent()) { |
184 const base::NativeEvent& native_key_event = event->native_event(); | 184 const base::NativeEvent& native_key_event = event->native_event(); |
185 if (native_key_event.message == WM_CHAR && text_input_client_) { | 185 if (native_key_event.message == WM_CHAR && text_input_client_) { |
186 text_input_client_->InsertChar( | 186 pending_char_events_.push_back(native_key_event); |
187 static_cast<base::char16>(native_key_event.wParam), | |
188 ui::GetModifiersFromKeyState()); | |
189 event->StopPropagation(); | 187 event->StopPropagation(); |
190 } | 188 } |
191 return; | 189 return; |
192 } | 190 } |
193 | 191 |
194 if (event->is_char()) { | 192 if (event->is_char()) { |
195 if (text_input_client_) { | 193 if (text_input_client_) { |
196 text_input_client_->InsertChar( | 194 text_input_client_->InsertChar( |
197 event->GetCharacter(), | 195 event->GetCharacter(), |
198 ui::GetModifiersFromKeyState()); | 196 ui::GetModifiersFromKeyState()); |
199 } | 197 } |
200 event->StopPropagation(); | 198 event->StopPropagation(); |
201 return; | 199 return; |
202 } | 200 } |
203 if (delegate_) | 201 if (delegate_) { |
204 ignore_result(delegate_->DispatchKeyEventPostIME(event)); | 202 ignore_result(delegate_->DispatchKeyEventPostIME(event)); |
203 if (text_input_client_ && pending_char_events_.size()) { | |
204 for (size_t i = 0; i < pending_char_events_.size(); ++i) { | |
205 const base::NativeEvent& native_key_event = pending_char_events_[i]; | |
206 text_input_client_->InsertChar( | |
207 static_cast<base::char16>(pending_char_events_[i].wParam), | |
208 event->flags()); | |
209 } | |
210 pending_char_events_.clear(); | |
James Su
2015/08/04 17:06:44
this cache should always be cleared for WM_KEYDOWN
Shu Chen
2015/08/05 01:36:45
Done.
| |
211 event->StopPropagation(); | |
212 } | |
213 } | |
205 } | 214 } |
206 | 215 |
207 void OnTextInputTypeChanged(const TextInputClient* client) override { | 216 void OnTextInputTypeChanged(const TextInputClient* client) override { |
208 if (!text_input_client_ || text_input_client_ != client) | 217 if (!text_input_client_ || text_input_client_ != client) |
209 return; | 218 return; |
210 std::vector<int32> prev_input_scopes; | 219 std::vector<int32> prev_input_scopes; |
211 std::swap(input_scopes_, prev_input_scopes); | 220 std::swap(input_scopes_, prev_input_scopes); |
212 input_scopes_ = GetInputScopesAsInt(client->GetTextInputType(), | 221 input_scopes_ = GetInputScopesAsInt(client->GetTextInputType(), |
213 client->GetTextInputMode()); | 222 client->GetTextInputMode()); |
214 if (input_scopes_ != prev_input_scopes && remote_delegate_) { | 223 if (input_scopes_ != prev_input_scopes && remote_delegate_) { |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
337 | 346 |
338 internal::InputMethodDelegate* delegate_; | 347 internal::InputMethodDelegate* delegate_; |
339 internal::RemoteInputMethodDelegateWin* remote_delegate_; | 348 internal::RemoteInputMethodDelegateWin* remote_delegate_; |
340 | 349 |
341 TextInputClient* text_input_client_; | 350 TextInputClient* text_input_client_; |
342 std::vector<int32> input_scopes_; | 351 std::vector<int32> input_scopes_; |
343 std::vector<gfx::Rect> composition_character_bounds_; | 352 std::vector<gfx::Rect> composition_character_bounds_; |
344 bool is_candidate_popup_open_; | 353 bool is_candidate_popup_open_; |
345 bool is_ime_; | 354 bool is_ime_; |
346 LANGID langid_; | 355 LANGID langid_; |
356 std::vector<base::NativeEvent> pending_char_events_; | |
347 | 357 |
348 DISALLOW_COPY_AND_ASSIGN(RemoteInputMethodWin); | 358 DISALLOW_COPY_AND_ASSIGN(RemoteInputMethodWin); |
349 }; | 359 }; |
350 | 360 |
351 } // namespace | 361 } // namespace |
352 | 362 |
353 bool IsRemoteInputMethodWinRequired(gfx::AcceleratedWidget widget) { | 363 bool IsRemoteInputMethodWinRequired(gfx::AcceleratedWidget widget) { |
354 // If the remote input method is already registered then don't do it again. | 364 // If the remote input method is already registered then don't do it again. |
355 if (ui::g_public_interface_ && ui::g_private_interface_) | 365 if (ui::g_public_interface_ && ui::g_private_interface_) |
356 return false; | 366 return false; |
(...skipping 17 matching lines...) Expand all Loading... | |
374 return make_scoped_ptr(new RemoteInputMethodWin(delegate)); | 384 return make_scoped_ptr(new RemoteInputMethodWin(delegate)); |
375 } | 385 } |
376 | 386 |
377 // static | 387 // static |
378 RemoteInputMethodPrivateWin* RemoteInputMethodPrivateWin::Get( | 388 RemoteInputMethodPrivateWin* RemoteInputMethodPrivateWin::Get( |
379 InputMethod* input_method) { | 389 InputMethod* input_method) { |
380 return GetPrivate(input_method); | 390 return GetPrivate(input_method); |
381 } | 391 } |
382 | 392 |
383 } // namespace ui | 393 } // namespace ui |
OLD | NEW |