コミットメタ情報

リビジョンc18161bb3be1b163d5eebe9f6fa56c48fee1d5fa (tree)
日時2014-09-11 22:22:28
作者Kazuhiro Fujieda <fujieda@user...>
コミッターKazuhiro Fujieda

ログメッセージ

Add the only active TIP (IME on TSF) to the IME list

変更サマリ

差分

--- a/xkeymacs/AppList.cpp
+++ b/xkeymacs/AppList.cpp
@@ -128,5 +128,5 @@ void AppList::AddIMEInfo(CProperties& cProperties)
128128 {
129129 IMEList imeList;
130130 for (IMEListIterator p = imeList.begin(); p != imeList.end(); ++p)
131- cProperties.AddItem(p->szDescription, p->szFileName);
131+ cProperties.AddItem(p->description, p->filename);
132132 }
--- a/xkeymacs/imelist.cpp
+++ b/xkeymacs/imelist.cpp
@@ -30,8 +30,8 @@ void IMEList::GetIMM()
3030 GetKeyboardLayoutList(n, &hkls[0]);
3131 for (std::vector<HKL>::const_iterator p = hkls.begin(); p != hkls.end(); ++p) {
3232 IMEInfo info;
33- if (ImmGetDescription(*p, info.szDescription, WINDOW_TEXT_LENGTH) &&
34- ImmGetIMEFileName(*p, info.szFileName, MAX_PATH))
33+ if (ImmGetDescription(*p, info.description, WINDOW_TEXT_LENGTH) &&
34+ ImmGetIMEFileName(*p, info.filename, MAX_PATH))
3535 list.push_back(info);
3636 }
3737 }
@@ -39,47 +39,34 @@ void IMEList::GetIMM()
3939 void IMEList::GetTSF()
4040 {
4141 CoInitialize(NULL);
42- HRESULT hr;
43- ITfInputProcessorProfiles *pProfiles;
44- hr = CoCreateInstance(CLSID_TF_InputProcessorProfiles, NULL, CLSCTX_INPROC_SERVER, IID_ITfInputProcessorProfiles, reinterpret_cast<LPVOID*>(&pProfiles));
45- if (FAILED(hr)) {
42+ ITfInputProcessorProfiles *ipp;
43+ if (FAILED(CoCreateInstance(CLSID_TF_InputProcessorProfiles, NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&ipp)))) {
4644 CoUninitialize();
4745 return;
4846 }
49- const LANGID langid = GetUserDefaultLangID();
50- IEnumTfLanguageProfiles *pEnum;
51- hr = pProfiles->EnumLanguageProfiles(langid, &pEnum);
52- if (FAILED(hr))
47+ ITfInputProcessorProfileMgr *mgr;
48+ if (FAILED(ipp->QueryInterface(&mgr)))
5349 goto fail;
54- TF_LANGUAGEPROFILE prof;
55- ULONG fetch;
56- while (pEnum->Next(1, &prof, &fetch) == S_OK) {
57- if (!prof.fActive)
58- continue;
59- BSTR bstr;
60- hr = pProfiles->GetLanguageProfileDescription(prof.clsid, langid, prof.guidProfile, &bstr);
61- if (FAILED(hr))
62- continue;
63- IMEInfo info;
50+ TF_INPUTPROCESSORPROFILE prof;
51+ if (FAILED(mgr->GetActiveProfile(GUID_TFCAT_TIP_KEYBOARD, &prof))) {
52+ mgr->Release();
53+ goto fail;
54+ }
55+ mgr->Release();
56+ if (prof.dwProfileType != TF_PROFILETYPE_INPUTPROCESSOR) // current IME is not TIP
57+ goto fail;
58+ BSTR bstr;
59+ if (FAILED(ipp->GetLanguageProfileDescription(prof.clsid, prof.langid, prof.guidProfile, &bstr)))
60+ goto fail;
61+ IMEInfo info;
6462 #ifdef _MBCS
65- WideCharToMultiByte(CP_ACP, 0, bstr, -1, info.szDescription, MAX_PATH, NULL, NULL);
63+ WideCharToMultiByte(CP_ACP, 0, bstr, -1, info.description, WINDOW_TEXT_LENGTH, NULL, NULL);
6664 #else
67- wcscpy_s(info.szDescription, WINDOW_TEXT_LENGTH, bstr);
65+ wcscpy_s(info.description, WINDOW_TEXT_LENGTH, bstr);
6866 #endif
69- bool exist = false;
70- for (IMEListIterator p = list.begin(); p != list.end(); ++p)
71- if (!_tcscmp(info.szDescription, p->szDescription)) { // already get via IMM
72- exist = true;
73- break;
74- }
75- if (!exist) {
76- _tcscpy_s(info.szFileName, _T("IME"));
77- list.push_back(info);
78- break;
79- }
80- }
81- pEnum->Release();
67+ _tcscpy_s(info.filename, _T("IME"));
68+ list.push_back(info);
8269 fail:
83- pProfiles->Release();
70+ ipp->Release();
8471 CoUninitialize();
8572 }
--- a/xkeymacs/imelist.h
+++ b/xkeymacs/imelist.h
@@ -10,8 +10,8 @@
1010
1111 struct IMEInfo
1212 {
13- TCHAR szDescription[WINDOW_TEXT_LENGTH];
14- TCHAR szFileName[MAX_PATH];
13+ TCHAR description[WINDOW_TEXT_LENGTH];
14+ TCHAR filename[MAX_PATH];
1515 };
1616
1717 typedef std::list<IMEInfo>::const_iterator IMEListIterator;
旧リポジトリブラウザで表示