Skip to content

Commit 6beef56

Browse files
committed
Fix #22 - causing crashes of configuration dialogs of other IMEs.
1 parent c44f070 commit 6beef56

File tree

2 files changed

+24
-19
lines changed

2 files changed

+24
-19
lines changed

Diff for: ImeModule.cpp

+23-18
Original file line numberDiff line numberDiff line change
@@ -176,20 +176,22 @@ HRESULT ImeModule::registerServer(wchar_t* name, const GUID& profileGuid, LANGID
176176
result = E_FAIL;
177177
}
178178

179-
// for Windows 8 store app support
180-
// TODO: according to a exhaustive Google search, I found that
181-
// TF_IPP_CAPS_IMMERSIVESUPPORT is required to make the IME work with Windows 8.
182-
// http://social.msdn.microsoft.com/Forums/windowsapps/en-US/4c422cf1-ceb4-413b-8a7c-6881946a4c63/how-to-set-a-flag-indicating-tsf-components-compatibility
183-
// Quote from the page: "To indicate that your IME is compatible with Windows Store apps, call RegisterCategory with GUID_TFCAT_TIPCAP_IMMERSIVESUPPORT."
184-
185-
// declare supporting immersive mode
186-
if(categoryMgr->RegisterCategory(textServiceClsid_, GUID_TFCAT_TIPCAP_IMMERSIVESUPPORT, textServiceClsid_) != S_OK) {
187-
result = E_FAIL;
188-
}
179+
if(isWindows8Above()) {
180+
// for Windows 8 store app support
181+
// TODO: according to a exhaustive Google search, I found that
182+
// TF_IPP_CAPS_IMMERSIVESUPPORT is required to make the IME work with Windows 8.
183+
// http://social.msdn.microsoft.com/Forums/windowsapps/en-US/4c422cf1-ceb4-413b-8a7c-6881946a4c63/how-to-set-a-flag-indicating-tsf-components-compatibility
184+
// Quote from the page: "To indicate that your IME is compatible with Windows Store apps, call RegisterCategory with GUID_TFCAT_TIPCAP_IMMERSIVESUPPORT."
185+
186+
// declare supporting immersive mode
187+
if(categoryMgr->RegisterCategory(textServiceClsid_, GUID_TFCAT_TIPCAP_IMMERSIVESUPPORT, textServiceClsid_) != S_OK) {
188+
result = E_FAIL;
189+
}
189190

190-
// declare compatibility with Windows 8 system tray
191-
if(categoryMgr->RegisterCategory(textServiceClsid_, GUID_TFCAT_TIPCAP_SYSTRAYSUPPORT, textServiceClsid_) != S_OK) {
192-
result = E_FAIL;
191+
// declare compatibility with Windows 8 system tray
192+
if(categoryMgr->RegisterCategory(textServiceClsid_, GUID_TFCAT_TIPCAP_SYSTRAYSUPPORT, textServiceClsid_) != S_OK) {
193+
result = E_FAIL;
194+
}
193195
}
194196

195197
categoryMgr->Release();
@@ -212,9 +214,11 @@ HRESULT ImeModule::unregisterServer(const GUID& profileGuid) {
212214
categoryMgr->UnregisterCategory(textServiceClsid_, GUID_TFCAT_TIP_KEYBOARD, textServiceClsid_);
213215
categoryMgr->UnregisterCategory(textServiceClsid_, GUID_TFCAT_DISPLAYATTRIBUTEPROVIDER, textServiceClsid_);
214216

215-
// Windows 8 support
216-
categoryMgr->UnregisterCategory(textServiceClsid_, GUID_TFCAT_TIPCAP_IMMERSIVESUPPORT, textServiceClsid_);
217-
categoryMgr->RegisterCategory(textServiceClsid_, GUID_TFCAT_TIPCAP_SYSTRAYSUPPORT, textServiceClsid_);
217+
if(isWindows8Above()) {
218+
// Windows 8 support
219+
categoryMgr->UnregisterCategory(textServiceClsid_, GUID_TFCAT_TIPCAP_IMMERSIVESUPPORT, textServiceClsid_);
220+
categoryMgr->RegisterCategory(textServiceClsid_, GUID_TFCAT_TIPCAP_SYSTRAYSUPPORT, textServiceClsid_);
221+
}
218222

219223
categoryMgr->Release();
220224
}
@@ -310,10 +314,11 @@ STDMETHODIMP ImeModule::CreateInstance(IUnknown *pUnkOuter, REFIID riid, void **
310314
textServices_.push_back(service);
311315
service->QueryInterface(riid, ppvObj);
312316
service->Release();
313-
return S_OK;
317+
if(*ppvObj)
318+
return S_OK;
314319
}
315320
}
316-
return S_FALSE;
321+
return E_NOINTERFACE;
317322
}
318323

319324
STDMETHODIMP ImeModule::LockServer(BOOL fLock) {

Diff for: TextService.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -557,7 +557,7 @@ STDMETHODIMP TextService::QueryInterface(REFIID riid, void **ppvObj) {
557557
if(IsEqualIID(riid, IID_IUnknown) || IsEqualIID(riid, IID_ITfTextInputProcessor))
558558
*ppvObj = (ITfTextInputProcessor*)this;
559559
else if(IsEqualIID(riid, IID_ITfFnConfigure ))
560-
*ppvObj = (ITfFnConfigure *)this;
560+
*ppvObj = (ITfFnConfigure *)this;
561561
//else if(IsEqualIID(riid, IID_ITfThreadMgrEventSink))
562562
// *ppvObj = (ITfThreadMgrEventSink*)this;
563563
else if(IsEqualIID(riid, IID_ITfTextEditSink))

0 commit comments

Comments
 (0)