https://git.reactos.org/?p=reactos.git;a=commitdiff;h=8de743988708e7835d869…
commit 8de743988708e7835d869bb412e7332bf9467e6e
Author: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com>
AuthorDate: Fri Apr 8 22:23:30 2022 +0900
Commit: GitHub <noreply(a)github.com>
CommitDate: Fri Apr 8 22:23:30 2022 +0900
[IMM32] Fix & Rename: s/Imm32LockIMCEx/Imm32InternalLockIMC/ (#4436)
- Fix & Rename: s/Imm32InitContext/Imm32CreateInputContext/ (Win:
IMM32!CreateInputContext).
- Fix & Rename: s/Imm32LockIMCEx/Imm32InternalLockIMC/ (Win:
IMM32!InternalImmLockIMC).
- Add CtfImmTIMCreateInputContext stub.
CORE-11700
---
dll/win32/imm32/ctf.c | 7 +++
dll/win32/imm32/imm.c | 97 +++++++++++++++++----------------------
dll/win32/imm32/precomp.h | 2 +-
sdk/include/reactos/imm32_undoc.h | 2 +
4 files changed, 51 insertions(+), 57 deletions(-)
diff --git a/dll/win32/imm32/ctf.c b/dll/win32/imm32/ctf.c
index e7f9cc77cad..b894c4498e3 100644
--- a/dll/win32/imm32/ctf.c
+++ b/dll/win32/imm32/ctf.c
@@ -38,6 +38,13 @@ HRESULT APIENTRY CtfImmTIMDestroyInputContext(HIMC hIMC)
return Imm32CtfImeDestroyInputContext(hIMC);
}
+// Win: CtfImmTIMCreateInputContext
+HRESULT APIENTRY CtfImmTIMCreateInputContext(HIMC hIMC)
+{
+ FIXME("(%p)\n", hIMC);
+ return E_NOTIMPL;
+}
+
/***********************************************************************
* CtfImmIsCiceroEnabled (IMM32.@)
*/
diff --git a/dll/win32/imm32/imm.c b/dll/win32/imm32/imm.c
index 9eb0b0b54fd..2260a50e74e 100644
--- a/dll/win32/imm32/imm.c
+++ b/dll/win32/imm32/imm.c
@@ -242,7 +242,7 @@ VOID APIENTRY Imm32SelectLayout(HKL hNewKL, HKL hOldKL, HIMC hIMC)
}
}
- pIC = (LPINPUTCONTEXTDX)Imm32LockIMCEx(hIMC, FALSE);
+ pIC = (LPINPUTCONTEXTDX)Imm32InternalLockIMC(hIMC, FALSE);
if (!pIC)
{
if (pNewImeDpi)
@@ -713,15 +713,16 @@ Finish:
return NtUserDestroyInputContext(hIMC);
}
+// NOTE: Windows does recursive call ImmLockIMC here but we don't do so.
+// Win: BOOL CreateInputContext(HIMC hIMC, HKL hKL, BOOL fSelect)
BOOL APIENTRY
-Imm32InitContext(HIMC hIMC, LPINPUTCONTEXT pIC, PCLIENTIMC pClientImc, HKL hKL, BOOL
fSelect)
+Imm32CreateInputContext(HIMC hIMC, LPINPUTCONTEXT pIC, PCLIENTIMC pClientImc, HKL hKL,
BOOL fSelect)
{
DWORD dwIndex, cbPrivate;
PIMEDPI pImeDpi = NULL;
LPCOMPOSITIONSTRING pCS;
LPCANDIDATEINFO pCI;
LPGUIDELINE pGL;
- /* NOTE: Windows does recursive call ImmLockIMC here but we don't do so. */
/* Create IC components */
pIC->hCompStr = ImmCreateIMCC(sizeof(COMPOSITIONSTRING));
@@ -809,16 +810,15 @@ Fail:
}
// Win: InternalImmLockIMC
-LPINPUTCONTEXT APIENTRY Imm32LockIMCEx(HIMC hIMC, BOOL fSelect)
+LPINPUTCONTEXT APIENTRY Imm32InternalLockIMC(HIMC hIMC, BOOL fSelect)
{
HANDLE hIC;
LPINPUTCONTEXT pIC = NULL;
PCLIENTIMC pClientImc;
- WORD Word;
+ WORD LangID;
DWORD dwThreadId;
- HKL hKL, hNewKL;
+ HKL hOldKL, hNewKL;
PIMEDPI pImeDpi = NULL;
- BOOL bInited;
pClientImc = ImmLockClientImc(hIMC);
if (!pClientImc)
@@ -826,68 +826,53 @@ LPINPUTCONTEXT APIENTRY Imm32LockIMCEx(HIMC hIMC, BOOL fSelect)
RtlEnterCriticalSection(&pClientImc->cs);
- if (!pClientImc->hInputContext)
- {
- dwThreadId = (DWORD)NtUserQueryInputContext(hIMC, QIC_INPUTTHREADID);
-
- if (dwThreadId == GetCurrentThreadId() && Imm32IsCiceroMode() &&
!Imm32Is16BitMode())
- {
- hKL = GetKeyboardLayout(0);
- Word = LOWORD(hKL);
- hNewKL = (HKL)(DWORD_PTR)MAKELONG(Word, Word);
-
- pImeDpi = Imm32FindOrLoadImeDpi(hNewKL);
- if (pImeDpi)
- {
- FIXME("We have to do something here\n");
- }
- }
-
- if (!NtUserQueryInputContext(hIMC, QIC_DEFAULTWINDOWIME))
- {
- RtlLeaveCriticalSection(&pClientImc->cs);
- goto Quit;
- }
+ if (pClientImc->hInputContext)
+ goto Finish;
- hIC = LocalAlloc(LHND, sizeof(INPUTCONTEXTDX));
- if (!hIC)
- {
- RtlLeaveCriticalSection(&pClientImc->cs);
- goto Quit;
- }
- pClientImc->hInputContext = hIC;
+ dwThreadId = (DWORD)NtUserQueryInputContext(hIMC, QIC_INPUTTHREADID);
+ if (dwThreadId == GetCurrentThreadId() && Imm32IsCiceroMode() &&
!Imm32Is16BitMode())
+ {
+ hOldKL = GetKeyboardLayout(0);
+ LangID = LOWORD(hOldKL);
+ hNewKL = (HKL)(DWORD_PTR)MAKELONG(LangID, LangID);
- pIC = LocalLock(pClientImc->hInputContext);
- if (!pIC)
+ pImeDpi = Imm32FindOrLoadImeDpi(hNewKL);
+ if (pImeDpi)
{
- pClientImc->hInputContext = LocalFree(pClientImc->hInputContext);
- RtlLeaveCriticalSection(&pClientImc->cs);
- goto Quit;
+ CtfImmTIMActivate(hNewKL);
}
+ }
- hKL = GetKeyboardLayout(dwThreadId);
- // bInited = Imm32InitContext(hIMC, hKL, fSelect);
- bInited = Imm32InitContext(hIMC, pIC, pClientImc, hKL, fSelect);
- LocalUnlock(pClientImc->hInputContext);
+ if (!NtUserQueryInputContext(hIMC, QIC_DEFAULTWINDOWIME))
+ goto Quit;
- if (!bInited)
- {
- pIC = NULL;
- pClientImc->hInputContext = LocalFree(pClientImc->hInputContext);
- RtlLeaveCriticalSection(&pClientImc->cs);
- goto Quit;
- }
+ hIC = LocalAlloc(LHND, sizeof(INPUTCONTEXTDX));
+ pIC = LocalLock(hIC);
+ if (!pIC)
+ {
+ LocalFree(hIC);
+ goto Quit;
}
+ pClientImc->hInputContext = hIC;
- FIXME("We have to do something here\n");
+ hNewKL = GetKeyboardLayout(dwThreadId);
+ if (!Imm32CreateInputContext(hIMC, pIC, pClientImc, hNewKL, fSelect))
+ {
+ pClientImc->hInputContext = LocalFree(pClientImc->hInputContext);
+ goto Quit;
+ }
+Finish:
+ CtfImmTIMCreateInputContext(hIMC);
RtlLeaveCriticalSection(&pClientImc->cs);
- pIC = LocalLock(pClientImc->hInputContext);
InterlockedIncrement(&pClientImc->cLockObj);
+ ImmUnlockClientImc(pClientImc);
+ return pIC;
Quit:
+ RtlLeaveCriticalSection(&pClientImc->cs);
ImmUnlockClientImc(pClientImc);
- return pIC;
+ return NULL;
}
/***********************************************************************
@@ -1030,7 +1015,7 @@ HIMC WINAPI ImmGetContext(HWND hWnd)
LPINPUTCONTEXT WINAPI ImmLockIMC(HIMC hIMC)
{
TRACE("(%p)\n", hIMC);
- return Imm32LockIMCEx(hIMC, TRUE);
+ return Imm32InternalLockIMC(hIMC, TRUE);
}
/***********************************************************************
diff --git a/dll/win32/imm32/precomp.h b/dll/win32/imm32/precomp.h
index 9139c3d0ce1..d6310c7e536 100644
--- a/dll/win32/imm32/precomp.h
+++ b/dll/win32/imm32/precomp.h
@@ -92,7 +92,7 @@ LPSTR APIENTRY Imm32AnsiFromWide(LPCWSTR pszW);
LONG APIENTRY IchWideFromAnsi(LONG cchAnsi, LPCSTR pchAnsi, UINT uCodePage);
LONG APIENTRY IchAnsiFromWide(LONG cchWide, LPCWSTR pchWide, UINT uCodePage);
PIMEDPI APIENTRY Imm32FindOrLoadImeDpi(HKL hKL);
-LPINPUTCONTEXT APIENTRY Imm32LockIMCEx(HIMC hIMC, BOOL fSelect);
+LPINPUTCONTEXT APIENTRY Imm32InternalLockIMC(HIMC hIMC, BOOL fSelect);
BOOL APIENTRY Imm32ReleaseIME(HKL hKL);
BOOL APIENTRY Imm32IsSystemJapaneseOrKorean(VOID);
diff --git a/sdk/include/reactos/imm32_undoc.h b/sdk/include/reactos/imm32_undoc.h
index f90b684a877..dadff68b031 100644
--- a/sdk/include/reactos/imm32_undoc.h
+++ b/sdk/include/reactos/imm32_undoc.h
@@ -18,7 +18,9 @@ PCLIENTIMC WINAPI ImmLockClientImc(HIMC hImc);
VOID WINAPI ImmUnlockClientImc(PCLIENTIMC pClientImc);
PIMEDPI WINAPI ImmLockImeDpi(HKL hKL);
VOID WINAPI ImmUnlockImeDpi(PIMEDPI pImeDpi);
+HRESULT APIENTRY CtfImmTIMCreateInputContext(HIMC hIMC);
HRESULT APIENTRY CtfImmTIMDestroyInputContext(HIMC hIMC);
+HRESULT WINAPI CtfImmTIMActivate(HKL hKL);
#ifdef __cplusplus
} // extern "C"