https://git.reactos.org/?p=reactos.git;a=commitdiff;h=0966e3214637d5d37be3bf1078229dfc9022e702

commit 0966e3214637d5d37be3bf1078229dfc9022e702
Author:     Katayama Hirofumi MZ <[email protected]>
AuthorDate: Fri Jul 16 03:04:00 2021 +0900
Commit:     GitHub <[email protected]>
CommitDate: Fri Jul 16 03:04:00 2021 +0900

    [IMM32] Rewrite ImmGetCandidateWindow (#3823)
    
    Rewrite ImmGetCandidateWindow function. CORE-11700
---
 dll/win32/imm32/imm.c | 27 ++++++++++++++++-----------
 1 file changed, 16 insertions(+), 11 deletions(-)

diff --git a/dll/win32/imm32/imm.c b/dll/win32/imm32/imm.c
index 8c40da91928..e93c522d2d9 100644
--- a/dll/win32/imm32/imm.c
+++ b/dll/win32/imm32/imm.c
@@ -45,6 +45,8 @@
 WINE_DEFAULT_DEBUG_CHANNEL(imm);
 
 #define IMM_INIT_MAGIC 0x19650412
+#define IMM_INVALID_CANDFORM ULONG_MAX
+
 BOOL WINAPI User32InitializeImmEntryTable(DWORD);
 
 typedef struct _tagImmHkl{
@@ -1449,22 +1451,25 @@ DWORD WINAPI ImmGetCandidateListW(
 BOOL WINAPI ImmGetCandidateWindow(
   HIMC hIMC, DWORD dwIndex, LPCANDIDATEFORM lpCandidate)
 {
-    InputContextData *data = get_imc_data(hIMC);
-
-    TRACE("%p, %d, %p\n", hIMC, dwIndex, lpCandidate);
-
-    if (!data || !lpCandidate)
-        return FALSE;
+    BOOL ret = FALSE;
+    LPINPUTCONTEXT pIC;
+    LPCANDIDATEFORM pCF;
 
-    if (dwIndex >= ARRAY_SIZE(data->IMC.cfCandForm))
-        return FALSE;
+    TRACE("ImmGetCandidateWindow(%p, %lu, %p)\n", hIMC, dwIndex, lpCandidate);
 
-    if (data->IMC.cfCandForm[dwIndex].dwIndex != dwIndex)
+    pIC = ImmLockIMC(hIMC);
+    if (pIC  == NULL)
         return FALSE;
 
-    *lpCandidate = data->IMC.cfCandForm[dwIndex];
+    pCF = &pIC->cfCandForm[dwIndex];
+    if (pCF->dwIndex != IMM_INVALID_CANDFORM)
+    {
+        *lpCandidate = *pCF;
+        ret = TRUE;
+    }
 
-    return TRUE;
+    ImmUnlockIMC(hIMC);
+    return ret;
 }
 
 static VOID APIENTRY LogFontAnsiToWide(const LOGFONTA *plfA, LPLOGFONTW plfW)

Reply via email to