https://git.reactos.org/?p=reactos.git;a=commitdiff;h=4342b84c9a310006bf521…
commit 4342b84c9a310006bf521c74a4e65f6020083cbd
Author: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com>
AuthorDate: Thu Apr 7 22:55:33 2022 +0900
Commit: GitHub <noreply(a)github.com>
CommitDate: Thu Apr 7 22:55:33 2022 +0900
[IMM32] Add ctf.c for Cicero (#4430)
Preparing of Cicero (modern input method) support.
- Add ctf.c and add some CTF functions.
- Modify the IMM table.
- Modify imm32.spec.
- Rename: s/Imm32FreeImeStates/Imm32DestroyImeModeSaver/.
- Improve Imm32DestroyInputContext.
CORE-11700
---
dll/win32/imm32/CMakeLists.txt | 1 +
dll/win32/imm32/ctf.c | 90 ++++++++++++++++++++++++++++++++++
dll/win32/imm32/imm.c | 62 ++++++++++++-----------
dll/win32/imm32/imm32.spec | 8 +--
dll/win32/imm32/utils.c | 8 ---
sdk/include/reactos/imm32_undoc.h | 1 +
win32ss/user/user32/include/immtable.h | 2 +-
7 files changed, 131 insertions(+), 41 deletions(-)
diff --git a/dll/win32/imm32/CMakeLists.txt b/dll/win32/imm32/CMakeLists.txt
index 5e67f36f4f5..a0c518040aa 100644
--- a/dll/win32/imm32/CMakeLists.txt
+++ b/dll/win32/imm32/CMakeLists.txt
@@ -10,6 +10,7 @@ spec2def(imm32.dll imm32.spec ADD_IMPORTLIB)
list(APPEND SOURCE
candidate.c
compstr.c
+ ctf.c
guideline.c
ime.c
imm.c
diff --git a/dll/win32/imm32/ctf.c b/dll/win32/imm32/ctf.c
new file mode 100644
index 00000000000..e7f9cc77cad
--- /dev/null
+++ b/dll/win32/imm32/ctf.c
@@ -0,0 +1,90 @@
+/*
+ * PROJECT: ReactOS IMM32
+ * LICENSE: LGPL-2.1-or-later (
https://spdx.org/licenses/LGPL-2.1-or-later)
+ * PURPOSE: Implementing IMM32 Cicero (modern input method)
+ * COPYRIGHT: Copyright 2022 Katayama Hirofumi MZ
<katayama.hirofumi.mz(a)gmail.com>
+ */
+
+#include "precomp.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(imm);
+
+// Win: LoadCtfIme
+HMODULE APIENTRY Imm32LoadCtfIme(VOID)
+{
+ FIXME("()\n");
+ return NULL;
+}
+
+// Win: Internal_CtfImeDestroyInputContext
+HRESULT APIENTRY Imm32CtfImeDestroyInputContext(HIMC hIMC)
+{
+ if (!Imm32LoadCtfIme())
+ return E_FAIL;
+#if 1
+ FIXME("(%p)\n", hIMC);
+ return E_NOTIMPL;
+#else
+ return g_pfnCtfImeDestroyInputContext(hIMC);
+#endif
+}
+
+// Win: CtfImmTIMDestroyInputContext
+HRESULT APIENTRY CtfImmTIMDestroyInputContext(HIMC hIMC)
+{
+ if (!Imm32IsCiceroMode() || (GetWin32ClientInfo()->dwCompatFlags2 & 2))
+ return E_NOINTERFACE;
+
+ return Imm32CtfImeDestroyInputContext(hIMC);
+}
+
+/***********************************************************************
+ * CtfImmIsCiceroEnabled (IMM32.@)
+ */
+BOOL WINAPI CtfImmIsCiceroEnabled(VOID)
+{
+ return Imm32IsCiceroMode();
+}
+
+/***********************************************************************
+ * CtfImmIsTextFrameServiceDisabled(IMM32.@)
+ */
+BOOL WINAPI CtfImmIsTextFrameServiceDisabled(VOID)
+{
+ return !!(GetWin32ClientInfo()->CI_flags & CI_TFSDISABLED);
+}
+
+/***********************************************************************
+ * CtfImmTIMActivate(IMM32.@)
+ */
+HRESULT WINAPI CtfImmTIMActivate(HKL hKL)
+{
+ FIXME("(%p)\n", hKL);
+ return E_NOTIMPL;
+}
+
+/***********************************************************************
+ * CtfImmRestoreToolbarWnd(IMM32.@)
+ */
+VOID WINAPI CtfImmRestoreToolbarWnd(DWORD dwStatus)
+{
+ FIXME("(0x%lx)\n", dwStatus);
+}
+
+/***********************************************************************
+ * CtfImmHideToolbarWnd(IMM32.@)
+ */
+DWORD WINAPI CtfImmHideToolbarWnd(VOID)
+{
+ FIXME("()\n");
+ return 0;
+}
+
+/***********************************************************************
+ * CtfImmDispatchDefImeMessage(IMM32.@)
+ */
+LRESULT WINAPI CtfImmDispatchDefImeMessage(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM
lParam)
+{
+ FIXME("(%p, %u, %p, %p)\n", hWnd, uMsg, wParam, lParam);
+ return 0;
+}
diff --git a/dll/win32/imm32/imm.c b/dll/win32/imm32/imm.c
index e3a71f8ba8d..4b6b72433f3 100644
--- a/dll/win32/imm32/imm.c
+++ b/dll/win32/imm32/imm.c
@@ -611,23 +611,26 @@ HIMC WINAPI ImmCreateContext(void)
return hIMC;
}
-static VOID APIENTRY Imm32FreeImeStates(LPINPUTCONTEXTDX pIC)
+// Win: DestroyImeModeSaver
+static VOID APIENTRY Imm32DestroyImeModeSaver(LPINPUTCONTEXTDX pIC)
{
- PIME_STATE pState, pStateNext;
- PIME_SUBSTATE pSubState, pSubStateNext;
+ PIME_STATE pState, pNext;
+ PIME_SUBSTATE pSubState, pSubNext;
- pState = pIC->pState;
- pIC->pState = NULL;
- for (; pState; pState = pStateNext)
+ for (pState = pIC->pState; pState; pState = pNext)
{
- pStateNext = pState->pNext;
- for (pSubState = pState->pSubState; pSubState; pSubState = pSubStateNext)
+ pNext = pState->pNext;
+
+ for (pSubState = pState->pSubState; pSubState; pSubState = pSubNext)
{
- pSubStateNext = pSubState->pNext;
+ pSubNext = pSubState->pNext;
ImmLocalFree(pSubState);
}
+
ImmLocalFree(pState);
}
+
+ pIC->pState = NULL;
}
// Win: DestroyInputContext
@@ -638,7 +641,7 @@ BOOL APIENTRY Imm32DestroyInputContext(HIMC hIMC, HKL hKL, BOOL
bKeep)
PCLIENTIMC pClientImc;
PIMC pIMC;
- if (!IS_IMM_MODE() || hIMC == NULL)
+ if (!hIMC || !IS_IMM_MODE())
return FALSE;
pIMC = ValidateHandleNoErr(hIMC, TYPE_INPUTCONTEXT);
@@ -674,19 +677,30 @@ BOOL APIENTRY Imm32DestroyInputContext(HIMC hIMC, HKL hKL, BOOL
bKeep)
return FALSE;
}
- pImeDpi = ImmLockImeDpi(hKL);
- if (pImeDpi)
+ CtfImmTIMDestroyInputContext(hIMC);
+
+ if (pClientImc->hKL == hKL)
{
- pImeDpi->ImeSelect(hIMC, FALSE);
- ImmUnlockImeDpi(pImeDpi);
+ pImeDpi = ImmLockImeDpi(hKL);
+ if (pImeDpi)
+ {
+ if (IS_IME_HKL(hKL))
+ pImeDpi->ImeSelect(hIMC, FALSE);
+ else if (Imm32IsCiceroMode() && !Imm32Is16BitMode())
+ pImeDpi->CtfImeSelectEx(hIMC, FALSE, hKL);
+
+ ImmUnlockImeDpi(pImeDpi);
+ }
+
+ pClientImc->hKL = NULL;
}
- pIC->hPrivate = ImmDestroyIMCC(pIC->hPrivate);
- pIC->hMsgBuf = ImmDestroyIMCC(pIC->hMsgBuf);
- pIC->hGuideLine = ImmDestroyIMCC(pIC->hGuideLine);
- pIC->hCandInfo = ImmDestroyIMCC(pIC->hCandInfo);
- pIC->hCompStr = ImmDestroyIMCC(pIC->hCompStr);
- Imm32FreeImeStates(pIC);
+ ImmDestroyIMCC(pIC->hPrivate);
+ ImmDestroyIMCC(pIC->hMsgBuf);
+ ImmDestroyIMCC(pIC->hGuideLine);
+ ImmDestroyIMCC(pIC->hCandInfo);
+ ImmDestroyIMCC(pIC->hCompStr);
+ Imm32DestroyImeModeSaver(pIC);
ImmUnlockIMC(hIMC);
Quit:
@@ -1008,14 +1022,6 @@ HIMC WINAPI ImmGetContext(HWND hWnd)
return ImmGetSaveContext(hWnd, 2);
}
-/***********************************************************************
- * CtfImmIsCiceroEnabled (IMM32.@)
- */
-BOOL WINAPI CtfImmIsCiceroEnabled(VOID)
-{
- return Imm32IsCiceroMode();
-}
-
/***********************************************************************
* ImmLockIMC(IMM32.@)
*
diff --git a/dll/win32/imm32/imm32.spec b/dll/win32/imm32/imm32.spec
index eb1fa8046f1..07e85847740 100644
--- a/dll/win32/imm32/imm32.spec
+++ b/dll/win32/imm32/imm32.spec
@@ -1,9 +1,9 @@
@ stdcall CtfImmIsCiceroEnabled()
@ stdcall CtfImmIsTextFrameServiceDisabled()
-@ stdcall -stub CtfImmTIMActivate(ptr)
-@ stdcall -stub CtfImmRestoreToolbarWnd(long)
-@ stdcall -stub CtfImmHideToolbarWnd()
-@ stdcall -stub CtfImmDispatchDefImeMessage(ptr long ptr ptr)
+@ stdcall CtfImmTIMActivate(ptr)
+@ stdcall CtfImmRestoreToolbarWnd(long)
+@ stdcall CtfImmHideToolbarWnd()
+@ stdcall CtfImmDispatchDefImeMessage(ptr long ptr ptr)
@ stdcall ImmActivateLayout(ptr)
@ stdcall ImmAssociateContext(ptr ptr)
@ stdcall ImmAssociateContextEx(ptr ptr long)
diff --git a/dll/win32/imm32/utils.c b/dll/win32/imm32/utils.c
index e9aea522696..319a670ec69 100644
--- a/dll/win32/imm32/utils.c
+++ b/dll/win32/imm32/utils.c
@@ -941,14 +941,6 @@ Quit:
return ret;
}
-/***********************************************************************
- * CtfImmIsTextFrameServiceDisabled(IMM32.@)
- */
-BOOL WINAPI CtfImmIsTextFrameServiceDisabled(VOID)
-{
- return !!(GetWin32ClientInfo()->CI_flags & CI_TFSDISABLED);
-}
-
/***********************************************************************
* ImmCreateIMCC(IMM32.@)
*/
diff --git a/sdk/include/reactos/imm32_undoc.h b/sdk/include/reactos/imm32_undoc.h
index be00e353492..f90b684a877 100644
--- a/sdk/include/reactos/imm32_undoc.h
+++ b/sdk/include/reactos/imm32_undoc.h
@@ -18,6 +18,7 @@ PCLIENTIMC WINAPI ImmLockClientImc(HIMC hImc);
VOID WINAPI ImmUnlockClientImc(PCLIENTIMC pClientImc);
PIMEDPI WINAPI ImmLockImeDpi(HKL hKL);
VOID WINAPI ImmUnlockImeDpi(PIMEDPI pImeDpi);
+HRESULT APIENTRY CtfImmTIMDestroyInputContext(HIMC hIMC);
#ifdef __cplusplus
} // extern "C"
diff --git a/win32ss/user/user32/include/immtable.h
b/win32ss/user/user32/include/immtable.h
index 5672285ec4b..b9acde65ab7 100644
--- a/win32ss/user/user32/include/immtable.h
+++ b/win32ss/user/user32/include/immtable.h
@@ -52,7 +52,7 @@ DEFINE_IMM_ENTRY(BOOL, ImmSetCompositionStringA, (HIMC hIMC, DWORD
dwIndex, LPCV
DEFINE_IMM_ENTRY(BOOL, ImmSetCompositionStringW, (HIMC hIMC, DWORD dwIndex, LPCVOID
lpComp, DWORD dwCompLen, LPCVOID lpRead, DWORD dwReadLen), 0, NONVOID)
DEFINE_IMM_ENTRY(BOOL, ImmEnumInputContext, (DWORD dwThreadID, IMCENUMPROC lpfn, LPARAM
lParam), 0, NONVOID)
DEFINE_IMM_ENTRY(LRESULT, ImmSystemHandler, (HIMC hIMC, WPARAM wParam, LPARAM lParam), 0,
NONVOID)
-DEFINE_IMM_ENTRY(LRESULT, CtfImmTIMActivate, (HKL hKL), 0, NONVOID)
+DEFINE_IMM_ENTRY(HRESULT, CtfImmTIMActivate, (HKL hKL), 0, NONVOID)
DEFINE_IMM_ENTRY(VOID, CtfImmRestoreToolbarWnd, (DWORD dwStatus), 0, VOID)
DEFINE_IMM_ENTRY(DWORD, CtfImmHideToolbarWnd, (VOID), 0, NONVOID)
DEFINE_IMM_ENTRY(LRESULT, CtfImmDispatchDefImeMessage, (HWND hWnd, UINT uMsg, WPARAM
wParam, LPARAM lParam), 0, NONVOID)