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

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

Issue 2700933002: Updates the IME state when necessary when switching top-level windows. (Closed)
Patch Set: . Created 3 years, 10 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
« no previous file with comments | « ui/base/ime/input_method_win.h ('k') | no next file » | 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 <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 #include <cwctype> 9 #include <cwctype>
10 10
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 enabled_(false), 50 enabled_(false),
51 is_candidate_popup_open_(false), 51 is_candidate_popup_open_(false),
52 composing_window_handle_(NULL), 52 composing_window_handle_(NULL),
53 weak_ptr_factory_(this) { 53 weak_ptr_factory_(this) {
54 SetDelegate(delegate); 54 SetDelegate(delegate);
55 imm32_manager_.SetInputLanguage(); 55 imm32_manager_.SetInputLanguage();
56 } 56 }
57 57
58 InputMethodWin::~InputMethodWin() {} 58 InputMethodWin::~InputMethodWin() {}
59 59
60 void InputMethodWin::OnFocus() {
61 InputMethodBase::OnFocus();
62 RefreshInputLanguage();
63 }
64
60 bool InputMethodWin::OnUntranslatedIMEMessage( 65 bool InputMethodWin::OnUntranslatedIMEMessage(
61 const base::NativeEvent& event, 66 const base::NativeEvent& event,
62 InputMethod::NativeEventResult* result) { 67 InputMethod::NativeEventResult* result) {
63 LRESULT original_result = 0; 68 LRESULT original_result = 0;
64 BOOL handled = FALSE; 69 BOOL handled = FALSE;
65 70
66 switch (event.message) { 71 switch (event.message) {
67 case WM_IME_SETCONTEXT: 72 case WM_IME_SETCONTEXT:
68 original_result = OnImeSetContext( 73 original_result = OnImeSetContext(
69 event.hwnd, event.message, event.wParam, event.lParam, &handled); 74 event.hwnd, event.message, event.wParam, event.lParam, &handled);
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 } 273 }
269 274
270 void InputMethodWin::OnInputLocaleChanged() { 275 void InputMethodWin::OnInputLocaleChanged() {
271 // Note: OnInputLocaleChanged() is for capturing the input language which can 276 // Note: OnInputLocaleChanged() is for capturing the input language which can
272 // be used to determine the appropriate TextInputType for Omnibox. 277 // be used to determine the appropriate TextInputType for Omnibox.
273 // See crbug.com/344834. 278 // See crbug.com/344834.
274 // Currently OnInputLocaleChanged() on Windows relies on WM_INPUTLANGCHANGED, 279 // Currently OnInputLocaleChanged() on Windows relies on WM_INPUTLANGCHANGED,
275 // which is known to be incompatible with TSF. 280 // which is known to be incompatible with TSF.
276 // TODO(shuchen): Use ITfLanguageProfileNotifySink instead. 281 // TODO(shuchen): Use ITfLanguageProfileNotifySink instead.
277 OnInputMethodChanged(); 282 OnInputMethodChanged();
278 imm32_manager_.SetInputLanguage(); 283 RefreshInputLanguage();
279 UpdateIMEState();
280 } 284 }
281 285
282 bool InputMethodWin::IsInputLocaleCJK() const { 286 bool InputMethodWin::IsInputLocaleCJK() const {
283 return imm32_manager_.IsInputLanguageCJK(); 287 return imm32_manager_.IsInputLanguageCJK();
284 } 288 }
285 289
286 bool InputMethodWin::IsCandidatePopupOpen() const { 290 bool InputMethodWin::IsCandidatePopupOpen() const {
287 return is_candidate_popup_open_; 291 return is_candidate_popup_open_;
288 } 292 }
289 293
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after
649 const gfx::Rect rect = 653 const gfx::Rect rect =
650 display::win::ScreenWin::DIPToScreenRect(toplevel_window_handle_, 654 display::win::ScreenWin::DIPToScreenRect(toplevel_window_handle_,
651 dip_rect); 655 dip_rect);
652 656
653 char_positon->pt.x = rect.x(); 657 char_positon->pt.x = rect.x();
654 char_positon->pt.y = rect.y(); 658 char_positon->pt.y = rect.y();
655 char_positon->cLineHeight = rect.height(); 659 char_positon->cLineHeight = rect.height();
656 return 1; // returns non-zero value when succeeded. 660 return 1; // returns non-zero value when succeeded.
657 } 661 }
658 662
663 void InputMethodWin::RefreshInputLanguage() {
664 TextInputType type_original = GetTextInputType();
665 imm32_manager_.SetInputLanguage();
666 if (type_original != GetTextInputType()) {
667 // Only update the IME state when necessary.
668 // It's unnecessary to report IME state, when:
669 // 1) Switching betweeen 2 top-level windows, and the switched-away window
670 // receives OnInputLocaleChanged.
671 // 2) The text input type is not changed by |SetInputLanguage|.
672 // Please refer to crbug.com/679564.
673 UpdateIMEState();
674 }
675 }
676
659 bool InputMethodWin::IsWindowFocused(const TextInputClient* client) const { 677 bool InputMethodWin::IsWindowFocused(const TextInputClient* client) const {
660 if (!client) 678 if (!client)
661 return false; 679 return false;
662 // When Aura is enabled, |attached_window_handle| should always be a top-level 680 // When Aura is enabled, |attached_window_handle| should always be a top-level
663 // window. So we can safely assume that |attached_window_handle| is ready for 681 // window. So we can safely assume that |attached_window_handle| is ready for
664 // receiving keyboard input as long as it is an active window. This works well 682 // receiving keyboard input as long as it is an active window. This works well
665 // even when the |attached_window_handle| becomes active but has not received 683 // even when the |attached_window_handle| becomes active but has not received
666 // WM_FOCUS yet. 684 // WM_FOCUS yet.
667 return toplevel_window_handle_ && 685 return toplevel_window_handle_ &&
668 GetActiveWindow() == toplevel_window_handle_; 686 GetActiveWindow() == toplevel_window_handle_;
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
733 ui::IMEEngineHandlerInterface* engine = GetEngine(); 751 ui::IMEEngineHandlerInterface* engine = GetEngine();
734 if (engine) { 752 if (engine) {
735 if (old_text_input_type != ui::TEXT_INPUT_TYPE_NONE) 753 if (old_text_input_type != ui::TEXT_INPUT_TYPE_NONE)
736 engine->FocusOut(); 754 engine->FocusOut();
737 if (GetTextInputType() != ui::TEXT_INPUT_TYPE_NONE) 755 if (GetTextInputType() != ui::TEXT_INPUT_TYPE_NONE)
738 engine->FocusIn(context); 756 engine->FocusIn(context);
739 } 757 }
740 } 758 }
741 759
742 } // namespace ui 760 } // namespace ui
OLDNEW
« no previous file with comments | « ui/base/ime/input_method_win.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698