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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « no previous file | 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/win/ime_input.h" 5 #include "ui/base/win/ime_input.h"
6 6
7 #include <atlbase.h>
8 #include <atlcom.h>
9 #include <msctf.h>
10
7 #include "base/basictypes.h" 11 #include "base/basictypes.h"
8 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
9 #include "base/string16.h" 13 #include "base/string16.h"
10 #include "base/string_util.h" 14 #include "base/string_util.h"
11 #include "base/utf_string_conversions.h" 15 #include "base/utf_string_conversions.h"
12 #include "third_party/skia/include/core/SkColor.h" 16 #include "third_party/skia/include/core/SkColor.h"
13 #include "ui/base/ime/composition_text.h" 17 #include "ui/base/ime/composition_text.h"
14 18
15 // "imm32.lib" is required by IMM32 APIs used in this file. 19 // "imm32.lib" is required by IMM32 APIs used in this file.
16 // NOTE(hbono): To comply with a comment from Darin, I have added 20 // NOTE(hbono): To comply with a comment from Darin, I have added
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 ImeInput::~ImeInput() { 127 ImeInput::~ImeInput() {
124 } 128 }
125 129
126 bool ImeInput::SetInputLanguage() { 130 bool ImeInput::SetInputLanguage() {
127 // Retrieve the current keyboard layout from Windows and determine whether 131 // Retrieve the current keyboard layout from Windows and determine whether
128 // or not the current input context has IMEs. 132 // or not the current input context has IMEs.
129 // Also save its input language for language-specific operations required 133 // Also save its input language for language-specific operations required
130 // while composing a text. 134 // while composing a text.
131 HKL keyboard_layout = ::GetKeyboardLayout(0); 135 HKL keyboard_layout = ::GetKeyboardLayout(0);
132 input_language_id_ = reinterpret_cast<LANGID>(keyboard_layout); 136 input_language_id_ = reinterpret_cast<LANGID>(keyboard_layout);
133 ime_status_ = (::ImmIsIME(keyboard_layout) == TRUE); 137
138 // Check TSF Input Processor first.
139 // If the active profile is TSF INPUTPROCESSOR, this is IME.
140 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.
141 TF_INPUTPROCESSORPROFILE prof;
142 if (SUCCEEDED(prof_mgr.CoCreateInstance(CLSID_TF_InputProcessorProfiles)) &&
143 SUCCEEDED(prof_mgr->GetActiveProfile(GUID_TFCAT_TIP_KEYBOARD, &prof)) &&
144 prof.hkl == NULL &&
145 prof.dwProfileType == TF_PROFILETYPE_INPUTPROCESSOR) {
146 ime_status_ = true;
147 } else {
148 // If the curent language is not using TSF, check IMM32 based IMEs.
149 // As ImmIsIME always returns non-0 value on Vista+, use ImmGetIMEFileName
150 // instead to check if this HKL has any associated IME file.
151 ime_status_ = (ImmGetIMEFileName(keyboard_layout, NULL, 0) != 0);
152 }
153
134 return ime_status_; 154 return ime_status_;
135 } 155 }
136 156
137 void ImeInput::CreateImeWindow(HWND window_handle) { 157 void ImeInput::CreateImeWindow(HWND window_handle) {
138 // When a user disables TSF (Text Service Framework) and CUAS (Cicero 158 // When a user disables TSF (Text Service Framework) and CUAS (Cicero
139 // Unaware Application Support), Chinese IMEs somehow ignore function calls 159 // Unaware Application Support), Chinese IMEs somehow ignore function calls
140 // to ::ImmSetCandidateWindow(), i.e. they do not move their candidate 160 // to ::ImmSetCandidateWindow(), i.e. they do not move their candidate
141 // window to the position given as its parameters, and use the position 161 // window to the position given as its parameters, and use the position
142 // of the current system caret instead, i.e. it uses ::GetCaretPos() to 162 // of the current system caret instead, i.e. it uses ::GetCaretPos() to
143 // retrieve the position of their IME candidate window. 163 // retrieve the position of their IME candidate window.
(...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after
559 keystate[VK_RCONTROL] = 0; 579 keystate[VK_RCONTROL] = 0;
560 keystate[VK_LCONTROL] = 0; 580 keystate[VK_LCONTROL] = 0;
561 for (int i = 0; i <= VK_PACKET; ++i) { 581 for (int i = 0; i <= VK_PACKET; ++i) {
562 if (keystate[i] & kKeyDownMask) 582 if (keystate[i] & kKeyDownMask)
563 return false; 583 return false;
564 } 584 }
565 return true; 585 return true;
566 } 586 }
567 587
568 } // namespace ui 588 } // namespace ui
OLDNEW
« 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