https://git.reactos.org/?p=reactos.git;a=commitdiff;h=c0c9b1445dc7d1eea7ab2…
commit c0c9b1445dc7d1eea7ab2f9f0b77ae38d3ff308f
Author: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com>
AuthorDate: Fri Aug 6 07:15:19 2021 +0900
Commit: GitHub <noreply(a)github.com>
CommitDate: Fri Aug 6 07:15:19 2021 +0900
[IMM32] Rewrite ImmSetConversionStatus (#3879)
CORE-11700
---
dll/win32/imm32/imm.c | 62 +++++++++++++++++++++++++++++++++++++--------------
1 file changed, 45 insertions(+), 17 deletions(-)
diff --git a/dll/win32/imm32/imm.c b/dll/win32/imm32/imm.c
index 84ab597c381..c1f5db8b1c1 100644
--- a/dll/win32/imm32/imm.c
+++ b/dll/win32/imm32/imm.c
@@ -3678,33 +3678,61 @@ BOOL WINAPI ImmSetCompositionWindow(
BOOL WINAPI ImmSetConversionStatus(
HIMC hIMC, DWORD fdwConversion, DWORD fdwSentence)
{
- DWORD oldConversion, oldSentence;
- InputContextData *data = get_imc_data(hIMC);
+ HKL hKL;
+ LPINPUTCONTEXT pIC;
+ DWORD dwImeThreadId, dwThreadId, dwOldConversion, dwOldSentence;
+ BOOL fConversionChange = FALSE, fSentenceChange = FALSE;
+ HWND hWnd;
- TRACE("%p %d %d\n", hIMC, fdwConversion, fdwSentence);
+ TRACE("(%p, 0x%lX, 0x%lX)\n", hIMC, fdwConversion, fdwSentence);
- if (!data)
+ hKL = GetKeyboardLayout(0);
+ if (!IS_IME_HKL(hKL))
{
- SetLastError(ERROR_INVALID_HANDLE);
- return FALSE;
+ if (g_psi && (g_psi->dwSRVIFlags & SRVINFO_CICERO_ENABLED))
+ {
+ FIXME("Cicero\n");
+ return FALSE;
+ }
}
- if (IMM_IsCrossThreadAccess(NULL, hIMC))
+ dwImeThreadId = Imm32QueryInputContext(hIMC, 1);
+ dwThreadId = GetCurrentThreadId();
+ if (dwImeThreadId != dwThreadId)
+ return FALSE;
+
+ pIC = ImmLockIMC(hIMC);
+ if (pIC == NULL)
return FALSE;
- if ( fdwConversion != data->IMC.fdwConversion )
+ if (pIC->fdwConversion != fdwConversion)
+ {
+ dwOldConversion = pIC->fdwConversion;
+ pIC->fdwConversion = fdwConversion;
+ fConversionChange = TRUE;
+ }
+
+ if (pIC->fdwSentence != fdwSentence)
{
- oldConversion = data->IMC.fdwConversion;
- data->IMC.fdwConversion = fdwConversion;
- ImmNotifyIME(hIMC, NI_CONTEXTUPDATED, oldConversion, IMC_SETCONVERSIONMODE);
- ImmInternalSendIMENotify(data, IMN_SETCONVERSIONMODE, 0);
+ dwOldSentence = pIC->fdwSentence;
+ pIC->fdwSentence = fdwSentence;
+ fSentenceChange = TRUE;
}
- if ( fdwSentence != data->IMC.fdwSentence )
+
+ hWnd = pIC->hWnd;
+ ImmUnlockIMC(hIMC);
+
+ if (fConversionChange)
+ {
+ Imm32NotifyAction(hIMC, hWnd, NI_CONTEXTUPDATED, dwOldConversion,
+ IMC_SETCONVERSIONMODE, IMN_SETCONVERSIONMODE, 0);
+ Imm32NotifyIMEStatus(hWnd, hIMC, fdwConversion);
+ }
+
+ if (fSentenceChange)
{
- oldSentence = data->IMC.fdwSentence;
- data->IMC.fdwSentence = fdwSentence;
- ImmNotifyIME(hIMC, NI_CONTEXTUPDATED, oldSentence, IMC_SETSENTENCEMODE);
- ImmInternalSendIMENotify(data, IMN_SETSENTENCEMODE, 0);
+ Imm32NotifyAction(hIMC, hWnd, NI_CONTEXTUPDATED, dwOldSentence,
+ IMC_SETSENTENCEMODE, IMN_SETSENTENCEMODE, 0);
}
return TRUE;