[MSCTFIME] Implement ImeConfigure (#6197)

Add code to CicInputContext and CicBridge classes.
Implement ImeConfigure function by using them.
CORE-19360
This commit is contained in:
Katayama Hirofumi MZ 2023-12-19 19:23:52 +09:00 committed by GitHub
parent dfd6d7f32a
commit 6c438e4530
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 166 additions and 2 deletions

View file

@ -83,7 +83,7 @@ IsInteractiveUserLogon(VOID)
} }
/* FIXME */ /* FIXME */
class CicInputContext : public IUnknown class CicInputContext : public ITfContextOwnerCompositionSink
{ {
LONG m_cRefs; LONG m_cRefs;
public: public:
@ -95,10 +95,16 @@ public:
{ {
} }
// IUnknown interface
STDMETHODIMP QueryInterface(REFIID riid, LPVOID* ppvObj) override; STDMETHODIMP QueryInterface(REFIID riid, LPVOID* ppvObj) override;
STDMETHODIMP_(ULONG) AddRef() override; STDMETHODIMP_(ULONG) AddRef() override;
STDMETHODIMP_(ULONG) Release() override; STDMETHODIMP_(ULONG) Release() override;
// ITfContextOwnerCompositionSink interface
STDMETHODIMP OnStartComposition(ITfCompositionView *pComposition, BOOL *pfOk) override;
STDMETHODIMP OnUpdateComposition(ITfCompositionView *pComposition, ITfRange *pRangeNew) override;
STDMETHODIMP OnEndComposition(ITfCompositionView *pComposition) override;
HRESULT HRESULT
GetGuidAtom( GetGuidAtom(
_Inout_ IMCLock& imcLock, _Inout_ IMCLock& imcLock,
@ -152,6 +158,38 @@ STDMETHODIMP_(ULONG) CicInputContext::Release()
return m_cRefs; return m_cRefs;
} }
/**
* @unimplemented
*/
STDMETHODIMP
CicInputContext::OnStartComposition(
ITfCompositionView *pComposition,
BOOL *pfOk)
{
return E_NOTIMPL;
}
/**
* @unimplemented
*/
STDMETHODIMP
CicInputContext::OnUpdateComposition(
ITfCompositionView *pComposition,
ITfRange *pRangeNew)
{
return E_NOTIMPL;
}
/**
* @unimplemented
*/
STDMETHODIMP
CicInputContext::OnEndComposition(
ITfCompositionView *pComposition)
{
return E_NOTIMPL;
}
/** /**
* @unimplemented * @unimplemented
*/ */
@ -291,11 +329,15 @@ public:
HRESULT ActivateIMMX(TLS *pTLS, ITfThreadMgr *pThreadMgr); HRESULT ActivateIMMX(TLS *pTLS, ITfThreadMgr *pThreadMgr);
HRESULT DeactivateIMMX(TLS *pTLS, ITfThreadMgr *pThreadMgr); HRESULT DeactivateIMMX(TLS *pTLS, ITfThreadMgr *pThreadMgr);
HRESULT DestroyInputContext(TLS *pTLS, HIMC hIMC); HRESULT DestroyInputContext(TLS *pTLS, HIMC hIMC);
HRESULT ConfigureGeneral(TLS* pTLS, ITfThreadMgr *pThreadMgr, HKL hKL, HWND hWnd);
HRESULT ConfigureRegisterWord(TLS* pTLS, ITfThreadMgr *pThreadMgr, HKL hKL, HWND hWnd, LPVOID lpData);
}; };
/* FIXME */ /* FIXME */
struct CicProfile : IUnknown struct CicProfile : IUnknown
{ {
HRESULT GetActiveLanguageProfile(HKL hKL, REFGUID rguid, TF_LANGUAGEPROFILE *pProfile);
}; };
class TLS class TLS
@ -589,6 +631,112 @@ STDMETHODIMP CicBridge::OnSysShellProc(INT, UINT, LONG)
return S_OK; return S_OK;
} }
HRESULT
CicBridge::ConfigureGeneral(
TLS* pTLS,
ITfThreadMgr *pThreadMgr,
HKL hKL,
HWND hWnd)
{
CicProfile *pProfile = pTLS->m_pProfile;
if (!pProfile)
return E_OUTOFMEMORY;
TF_LANGUAGEPROFILE profile;
HRESULT hr = pProfile->GetActiveLanguageProfile(hKL, GUID_TFCAT_TIP_KEYBOARD, &profile);
if (FAILED(hr))
return hr;
ITfFunctionProvider *pProvider = NULL;
hr = pThreadMgr->GetFunctionProvider(profile.clsid, &pProvider);
if (FAILED(hr))
return hr;
ITfFnConfigure *pFnConfigure = NULL;
hr = pProvider->GetFunction(GUID_NULL, IID_ITfFnConfigure, (IUnknown**)&pFnConfigure);
if (FAILED(hr))
{
pProvider->Release();
return hr;
}
hr = pFnConfigure->Show(hWnd, profile.langid, profile.guidProfile);
pFnConfigure->Release();
pProvider->Release();
return hr;
}
HRESULT
CicBridge::ConfigureRegisterWord(
TLS* pTLS,
ITfThreadMgr *pThreadMgr,
HKL hKL,
HWND hWnd,
LPVOID lpData)
{
CicProfile *pProfile = pTLS->m_pProfile;
if (!pProfile)
return E_OUTOFMEMORY;
TF_LANGUAGEPROFILE profile;
HRESULT hr = pProfile->GetActiveLanguageProfile(hKL, GUID_TFCAT_TIP_KEYBOARD, &profile);
if (FAILED(hr))
return hr;
ITfFunctionProvider *pProvider;
hr = pThreadMgr->GetFunctionProvider(profile.clsid, &pProvider);
if (FAILED(hr))
return hr;
ITfFnConfigureRegisterWord *pFunction;
hr = pProvider->GetFunction(GUID_NULL, IID_ITfFnConfigureRegisterWord, (IUnknown**)pFunction);
if (FAILED(hr))
{
pProvider->Release();
return hr;
}
REGISTERWORDW* pRegWord = (REGISTERWORDW*)lpData;
if (pRegWord)
{
if (pRegWord->lpWord)
{
hr = E_OUTOFMEMORY;
BSTR bstrWord = SysAllocString(pRegWord->lpWord);
if (bstrWord)
{
hr = pFunction->Show(hWnd, profile.langid, profile.guidProfile, bstrWord);
SysFreeString(bstrWord);
}
}
else
{
hr = pFunction->Show(hWnd, profile.langid, profile.guidProfile, NULL);
}
}
pProvider->Release();
pFunction->Release();
return hr;
}
/***********************************************************************
* CicProfile
*/
/**
* @unimplemented
*/
HRESULT
CicProfile::GetActiveLanguageProfile(
HKL hKL,
REFGUID rguid,
TF_LANGUAGEPROFILE *pProfile)
{
return E_NOTIMPL;
}
/*********************************************************************** /***********************************************************************
* ImeInquire (MSCTFIME.@) * ImeInquire (MSCTFIME.@)
* *
@ -709,7 +857,21 @@ ImeConfigure(
_In_ DWORD dwMode, _In_ DWORD dwMode,
_Inout_opt_ LPVOID lpData) _Inout_opt_ LPVOID lpData)
{ {
FIXME("stub:(%p, %p, %lu, %p)\n", hKL, hWnd, dwMode, lpData); TRACE("(%p, %p, %lu, %p)\n", hKL, hWnd, dwMode, lpData);
TLS *pTLS = TLS::GetTLS();
if (!pTLS || !pTLS->m_pBridge || !pTLS->m_pThreadMgr)
return FALSE;
CicBridge *pBridge = pTLS->m_pBridge;
ITfThreadMgr *pThreadMgr = pTLS->m_pThreadMgr;
if (dwMode & 1)
return (pBridge->ConfigureGeneral(pTLS, pThreadMgr, hKL, hWnd) == S_OK);
if (dwMode & 2)
return (pBridge->ConfigureRegisterWord(pTLS, pThreadMgr, hKL, hWnd, lpData) == S_OK);
return FALSE; return FALSE;
} }

View file

@ -16,7 +16,9 @@
#include <windows.h> #include <windows.h>
#include <imm.h> #include <imm.h>
#include <ddk/immdev.h> #include <ddk/immdev.h>
#include <cguid.h>
#include <msctf.h> #include <msctf.h>
#include <ctffunc.h>
#include <shlwapi.h> #include <shlwapi.h>
#include <strsafe.h> #include <strsafe.h>