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

Unified Diff: ui/base/win/ime_input.cc

Issue 14988010: Performance fix for Vista+ where non-IME input is reported as IME (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@imeapi
Patch Set: improve comments. Created 7 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/base/win/ime_input.cc
diff --git a/ui/base/win/ime_input.cc b/ui/base/win/ime_input.cc
index 3bad0acbf3b2c3c1220d0149fc86367fd21ed5a1..f3b1a0a8aa6a49b694466a49c6c9ea0956f89546 100644
--- a/ui/base/win/ime_input.cc
+++ b/ui/base/win/ime_input.cc
@@ -4,6 +4,10 @@
#include "ui/base/win/ime_input.h"
+#include <atlbase.h>
+#include <atlcom.h>
+#include <msctf.h>
+
#include "base/basictypes.h"
#include "base/memory/scoped_ptr.h"
#include "base/string16.h"
@@ -130,7 +134,23 @@ bool ImeInput::SetInputLanguage() {
// while composing a text.
HKL keyboard_layout = ::GetKeyboardLayout(0);
input_language_id_ = reinterpret_cast<LANGID>(keyboard_layout);
- ime_status_ = (::ImmIsIME(keyboard_layout) == TRUE);
+
+ // Check TSF Input Processor first.
+ // If the active profile is TSF INPUTPROCESSOR, this is IME.
+ CComPtr<ITfInputProcessorProfileMgr> prof_mgr;
Yohei Yukawa 2013/05/16 08:55:02 We prefer to use our own scoped pointer to maingai
kochi 2013/05/16 10:29:31 Done.
+ TF_INPUTPROCESSORPROFILE prof;
+ if (SUCCEEDED(prof_mgr.CoCreateInstance(CLSID_TF_InputProcessorProfiles)) &&
+ SUCCEEDED(prof_mgr->GetActiveProfile(GUID_TFCAT_TIP_KEYBOARD, &prof)) &&
+ prof.hkl == NULL &&
+ prof.dwProfileType == TF_PROFILETYPE_INPUTPROCESSOR) {
+ ime_status_ = true;
+ } else {
+ // If the curent language is not using TSF, check IMM32 based IMEs.
+ // As ImmIsIME always returns non-0 value on Vista+, use ImmGetIMEFileName
+ // instead to check if this HKL has any associated IME file.
+ ime_status_ = (ImmGetIMEFileName(keyboard_layout, NULL, 0) != 0);
+ }
+
return ime_status_;
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698