From 6468b72bb88843d39a831b6841bc1f02cf77dc98 Mon Sep 17 00:00:00 2001 From: "hbono@chromium.org" Date: Thu, 19 Mar 2009 12:06:14 +0000 Subject: A quick fix for Issue 2720. To investigate this issue, we noticed some IMEs got confused when we change the text in a rich-edit control and finish an ongoing IME composition while they are composing a text. To prevent this, we accept keywords when they are activated. Review URL: http://codereview.chromium.org/42275 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@12089 0039d316-1c4b-4281-b951-d872f2087c98 --- .../autocomplete/autocomplete_edit_view_win.cc | 22 ++++++++++++++++++++++ .../autocomplete/autocomplete_edit_view_win.h | 2 ++ 2 files changed, 24 insertions(+) (limited to 'chrome/browser/autocomplete') diff --git a/chrome/browser/autocomplete/autocomplete_edit_view_win.cc b/chrome/browser/autocomplete/autocomplete_edit_view_win.cc index 66db822..d8c88b0 100644 --- a/chrome/browser/autocomplete/autocomplete_edit_view_win.cc +++ b/chrome/browser/autocomplete/autocomplete_edit_view_win.cc @@ -1202,6 +1202,28 @@ LRESULT AutocompleteEditViewWin::OnImeComposition(UINT message, return result; } +LRESULT AutocompleteEditViewWin::OnImeNotify(UINT message, + WPARAM wparam, + LPARAM lparam) { + if (wparam == IMN_SETOPENSTATUS) { + // A user has activated (or deactivated) IMEs (but not started a + // composition). + // Some IMEs get confused when we accept keywords while they are composing + // text. To prevent this situation, we accept keywords when an IME is + // activated. + HIMC imm_context = ImmGetContext(m_hWnd); + if (imm_context) { + if (ImmGetOpenStatus(imm_context) && + model_->is_keyword_hint() && !model_->keyword().empty()) { + ScopedFreeze freeze(this, GetTextObjectModel()); + model_->AcceptKeyword(); + } + ImmReleaseContext(m_hWnd, imm_context); + } + } + return DefWindowProc(message, wparam, lparam); +} + void AutocompleteEditViewWin::OnKeyDown(TCHAR key, UINT repeat_count, UINT flags) { diff --git a/chrome/browser/autocomplete/autocomplete_edit_view_win.h b/chrome/browser/autocomplete/autocomplete_edit_view_win.h index b69005a..06bfbab 100644 --- a/chrome/browser/autocomplete/autocomplete_edit_view_win.h +++ b/chrome/browser/autocomplete/autocomplete_edit_view_win.h @@ -151,6 +151,7 @@ class AutocompleteEditViewWin MSG_WM_CUT(OnCut) MESSAGE_HANDLER_EX(WM_GETOBJECT, OnGetObject) MESSAGE_HANDLER_EX(WM_IME_COMPOSITION, OnImeComposition) + MESSAGE_HANDLER_EX(WM_IME_NOTIFY, OnImeNotify) MSG_WM_KEYDOWN(OnKeyDown) MSG_WM_KEYUP(OnKeyUp) MSG_WM_KILLFOCUS(OnKillFocus) @@ -230,6 +231,7 @@ class AutocompleteEditViewWin void OnCut(); LRESULT OnGetObject(UINT uMsg, WPARAM wparam, LPARAM lparam); LRESULT OnImeComposition(UINT message, WPARAM wparam, LPARAM lparam); + LRESULT OnImeNotify(UINT message, WPARAM wparam, LPARAM lparam); void OnKeyDown(TCHAR key, UINT repeat_count, UINT flags); void OnKeyUp(TCHAR key, UINT repeat_count, UINT flags); void OnKillFocus(HWND focus_wnd); -- cgit v1.1