https://git.reactos.org/?p=reactos.git;a=commitdiff;h=470aa2761033294f8f432…
commit 470aa2761033294f8f43261ee98324be705f607c
Author:     Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com>
AuthorDate: Wed Feb 2 11:56:40 2022 +0900
Commit:     GitHub <noreply(a)github.com>
CommitDate: Wed Feb 2 11:56:40 2022 +0900
    [NTUSER] Move IMM-related code to ime.c (#4322)
    Move the IMM-related code from ntstubs.c into ime.c.
    CORE-11700
---
 win32ss/user/ntuser/ime.c     | 203 +++++++++++++++++++++++++++++++++++++++++
 win32ss/user/ntuser/ntstubs.c | 206 ------------------------------------------
 2 files changed, 203 insertions(+), 206 deletions(-)
diff --git a/win32ss/user/ntuser/ime.c b/win32ss/user/ntuser/ime.c
index 18806d68a8d..c492f07507d 100644
--- a/win32ss/user/ntuser/ime.c
+++ b/win32ss/user/ntuser/ime.c
@@ -12,6 +12,34 @@ DBG_DEFAULT_CHANNEL(UserMisc);
 #define INVALID_THREAD_ID  ((ULONG)-1)
+DWORD
+APIENTRY
+NtUserSetThreadLayoutHandles(HKL hNewKL, HKL hOldKL)
+{
+    PTHREADINFO pti;
+    PKL pOldKL, pNewKL;
+
+    UserEnterExclusive();
+
+    pti = GetW32ThreadInfo();
+    pOldKL = pti->KeyboardLayout;
+    if (pOldKL && pOldKL->hkl != hOldKL)
+        goto Quit;
+
+    pNewKL = UserHklToKbl(hNewKL);
+    if (!pNewKL)
+        goto Quit;
+
+    if (IS_IME_HKL(hNewKL) != IS_IME_HKL(hOldKL))
+        pti->hklPrev = hOldKL;
+
+    pti->KeyboardLayout = pNewKL;
+
+Quit:
+    UserLeave();
+    return 0;
+}
+
 DWORD FASTCALL UserBuildHimcList(PTHREADINFO pti, DWORD dwCount, HIMC *phList)
 {
     PIMC pIMC;
@@ -534,4 +562,179 @@ BOOL APIENTRY NtUserDestroyInputContext(HIMC hIMC)
     return ret;
 }
+PIMC FASTCALL UserCreateInputContext(ULONG_PTR dwClientImcData)
+{
+    PIMC pIMC;
+    PTHREADINFO pti = PsGetCurrentThreadWin32Thread();
+    PDESKTOP pdesk = pti->rpdesk;
+
+    if (!IS_IMM_MODE() || (pti->TIF_flags & TIF_DISABLEIME)) // Disabled?
+        return NULL;
+
+    if (!pdesk) // No desktop?
+        return NULL;
+
+    // pti->spDefaultImc should be already set if non-first time.
+    if (dwClientImcData && !pti->spDefaultImc)
+        return NULL;
+
+    // Create an input context user object.
+    pIMC = UserCreateObject(gHandleTable, pdesk, pti, NULL, TYPE_INPUTCONTEXT,
sizeof(IMC));
+    if (!pIMC)
+        return NULL;
+
+    // Release the extra reference (UserCreateObject added 2 references).
+    UserDereferenceObject(pIMC);
+
+    if (dwClientImcData) // Non-first time.
+    {
+        // Insert pIMC to the second position (non-default) of the list.
+        pIMC->pImcNext = pti->spDefaultImc->pImcNext;
+        pti->spDefaultImc->pImcNext = pIMC;
+    }
+    else // First time. It's the default IMC.
+    {
+        // Add the first one (default) to the list.
+        pti->spDefaultImc = pIMC;
+        pIMC->pImcNext = NULL;
+    }
+
+    pIMC->dwClientImcData = dwClientImcData; // Set it.
+    return pIMC;
+}
+
+HIMC
+APIENTRY
+NtUserCreateInputContext(ULONG_PTR dwClientImcData)
+{
+    PIMC pIMC;
+    HIMC ret = NULL;
+
+    if (!dwClientImcData)
+        return NULL;
+
+    UserEnterExclusive();
+
+    if (!IS_IMM_MODE())
+        goto Quit;
+
+    pIMC = UserCreateInputContext(dwClientImcData);
+    if (pIMC)
+        ret = UserHMGetHandle(pIMC);
+
+Quit:
+    UserLeave();
+    return ret;
+}
+
+DWORD
+APIENTRY
+NtUserAssociateInputContext(HWND hWnd, HIMC hIMC, DWORD dwFlags)
+{
+    STUB
+    return 0;
+}
+
+BOOL FASTCALL UserUpdateInputContext(PIMC pIMC, DWORD dwType, DWORD_PTR dwValue)
+{
+    PTHREADINFO pti = GetW32ThreadInfo();
+    PTHREADINFO ptiIMC = pIMC->head.pti;
+
+    if (pti->ppi != ptiIMC->ppi) // Different process?
+        return FALSE;
+
+    switch (dwType)
+    {
+        case UIC_CLIENTIMCDATA:
+            if (pIMC->dwClientImcData)
+                return FALSE; // Already set
+
+            pIMC->dwClientImcData = dwValue;
+            break;
+
+        case UIC_IMEWINDOW:
+            if (!ValidateHwndNoErr((HWND)dwValue))
+                return FALSE; // Invalid HWND
+
+            pIMC->hImeWnd = (HWND)dwValue;
+            break;
+
+        default:
+            return FALSE;
+    }
+
+    return TRUE;
+}
+
+BOOL
+APIENTRY
+NtUserUpdateInputContext(
+    HIMC hIMC,
+    DWORD dwType,
+    DWORD_PTR dwValue)
+{
+    PIMC pIMC;
+    BOOL ret = FALSE;
+
+    UserEnterExclusive();
+
+    if (!IS_IMM_MODE())
+        goto Quit;
+
+    pIMC = UserGetObject(gHandleTable, hIMC, TYPE_INPUTCONTEXT);
+    if (!pIMC)
+        goto Quit;
+
+    ret = UserUpdateInputContext(pIMC, dwType, dwValue);
+
+Quit:
+    UserLeave();
+    return ret;
+}
+
+DWORD_PTR
+APIENTRY
+NtUserQueryInputContext(HIMC hIMC, DWORD dwType)
+{
+    PIMC pIMC;
+    PTHREADINFO ptiIMC;
+    DWORD_PTR ret = 0;
+
+    UserEnterExclusive();
+
+    if (!IS_IMM_MODE())
+        goto Quit;
+
+    pIMC = UserGetObject(gHandleTable, hIMC, TYPE_INPUTCONTEXT);
+    if (!pIMC)
+        goto Quit;
+
+    ptiIMC = pIMC->head.pti;
+
+    switch (dwType)
+    {
+        case QIC_INPUTPROCESSID:
+            ret = (DWORD_PTR)PsGetThreadProcessId(ptiIMC->pEThread);
+            break;
+
+        case QIC_INPUTTHREADID:
+            ret = (DWORD_PTR)PsGetThreadId(ptiIMC->pEThread);
+            break;
+
+        case QIC_DEFAULTWINDOWIME:
+            if (ptiIMC->spwndDefaultIme)
+                ret = (DWORD_PTR)UserHMGetHandle(ptiIMC->spwndDefaultIme);
+            break;
+
+        case QIC_DEFAULTIMC:
+            if (ptiIMC->spDefaultImc)
+                ret = (DWORD_PTR)UserHMGetHandle(ptiIMC->spDefaultImc);
+            break;
+    }
+
+Quit:
+    UserLeave();
+    return ret;
+}
+
 /* EOF */
diff --git a/win32ss/user/ntuser/ntstubs.c b/win32ss/user/ntuser/ntstubs.c
index cdb801dc765..8f1a678be8d 100644
--- a/win32ss/user/ntuser/ntstubs.c
+++ b/win32ss/user/ntuser/ntstubs.c
@@ -9,14 +9,6 @@
 #include <win32k.h>
 DBG_DEFAULT_CHANNEL(UserMisc);
-DWORD
-APIENTRY
-NtUserAssociateInputContext(HWND hWnd, HIMC hIMC, DWORD dwFlags)
-{
-    STUB
-    return 0;
-}
-
 //
 // Works like BitBlt, 
http://msdn.microsoft.com/en-us/library/ms532278(VS.85).aspx
 //
@@ -338,63 +330,6 @@ NtUserSetSysColors(
    return Ret;
 }
-BOOL FASTCALL UserUpdateInputContext(PIMC pIMC, DWORD dwType, DWORD_PTR dwValue)
-{
-    PTHREADINFO pti = GetW32ThreadInfo();
-    PTHREADINFO ptiIMC = pIMC->head.pti;
-
-    if (pti->ppi != ptiIMC->ppi) // Different process?
-        return FALSE;
-
-    switch (dwType)
-    {
-        case UIC_CLIENTIMCDATA:
-            if (pIMC->dwClientImcData)
-                return FALSE; // Already set
-
-            pIMC->dwClientImcData = dwValue;
-            break;
-
-        case UIC_IMEWINDOW:
-            if (!ValidateHwndNoErr((HWND)dwValue))
-                return FALSE; // Invalid HWND
-
-            pIMC->hImeWnd = (HWND)dwValue;
-            break;
-
-        default:
-            return FALSE;
-    }
-
-    return TRUE;
-}
-
-BOOL
-APIENTRY
-NtUserUpdateInputContext(
-    HIMC hIMC,
-    DWORD dwType,
-    DWORD_PTR dwValue)
-{
-    PIMC pIMC;
-    BOOL ret = FALSE;
-
-    UserEnterExclusive();
-
-    if (!IS_IMM_MODE())
-        goto Quit;
-
-    pIMC = UserGetObject(gHandleTable, hIMC, TYPE_INPUTCONTEXT);
-    if (!pIMC)
-        goto Quit;
-
-    ret = UserUpdateInputContext(pIMC, dwType, dwValue);
-
-Quit:
-    UserLeave();
-    return ret;
-}
-
 DWORD
 APIENTRY
 NtUserUpdateInstance(
@@ -453,71 +388,6 @@ NtUserYieldTask(VOID)
    return 0;
 }
-PIMC FASTCALL UserCreateInputContext(ULONG_PTR dwClientImcData)
-{
-    PIMC pIMC;
-    PTHREADINFO pti = PsGetCurrentThreadWin32Thread();
-    PDESKTOP pdesk = pti->rpdesk;
-
-    if (!IS_IMM_MODE() || (pti->TIF_flags & TIF_DISABLEIME)) // Disabled?
-        return NULL;
-
-    if (!pdesk) // No desktop?
-        return NULL;
-
-    // pti->spDefaultImc should be already set if non-first time.
-    if (dwClientImcData && !pti->spDefaultImc)
-        return NULL;
-
-    // Create an input context user object.
-    pIMC = UserCreateObject(gHandleTable, pdesk, pti, NULL, TYPE_INPUTCONTEXT,
sizeof(IMC));
-    if (!pIMC)
-        return NULL;
-
-    // Release the extra reference (UserCreateObject added 2 references).
-    UserDereferenceObject(pIMC);
-
-    if (dwClientImcData) // Non-first time.
-    {
-        // Insert pIMC to the second position (non-default) of the list.
-        pIMC->pImcNext = pti->spDefaultImc->pImcNext;
-        pti->spDefaultImc->pImcNext = pIMC;
-    }
-    else // First time. It's the default IMC.
-    {
-        // Add the first one (default) to the list.
-        pti->spDefaultImc = pIMC;
-        pIMC->pImcNext = NULL;
-    }
-
-    pIMC->dwClientImcData = dwClientImcData; // Set it.
-    return pIMC;
-}
-
-HIMC
-APIENTRY
-NtUserCreateInputContext(ULONG_PTR dwClientImcData)
-{
-    PIMC pIMC;
-    HIMC ret = NULL;
-
-    if (!dwClientImcData)
-        return NULL;
-
-    UserEnterExclusive();
-
-    if (!IS_IMM_MODE())
-        goto Quit;
-
-    pIMC = UserCreateInputContext(dwClientImcData);
-    if (pIMC)
-        ret = UserHMGetHandle(pIMC);
-
-Quit:
-    UserLeave();
-    return ret;
-}
-
 DWORD
 APIENTRY
 NtUserGetRawInputBuffer(
@@ -741,53 +611,6 @@ Quit:
     return Status;
 }
-DWORD_PTR
-APIENTRY
-NtUserQueryInputContext(
-    HIMC hIMC,
-    DWORD dwType)
-{
-    PIMC pIMC;
-    PTHREADINFO ptiIMC;
-    DWORD_PTR ret = 0;
-
-    UserEnterExclusive();
-
-    if (!IS_IMM_MODE())
-        goto Quit;
-
-    pIMC = UserGetObject(gHandleTable, hIMC, TYPE_INPUTCONTEXT);
-    if (!pIMC)
-        goto Quit;
-
-    ptiIMC = pIMC->head.pti;
-
-    switch (dwType)
-    {
-        case QIC_INPUTPROCESSID:
-            ret = (DWORD_PTR)PsGetThreadProcessId(ptiIMC->pEThread);
-            break;
-
-        case QIC_INPUTTHREADID:
-            ret = (DWORD_PTR)PsGetThreadId(ptiIMC->pEThread);
-            break;
-
-        case QIC_DEFAULTWINDOWIME:
-            if (ptiIMC->spwndDefaultIme)
-                ret = (DWORD_PTR)UserHMGetHandle(ptiIMC->spwndDefaultIme);
-            break;
-
-        case QIC_DEFAULTIMC:
-            if (ptiIMC->spDefaultImc)
-                ret = (DWORD_PTR)UserHMGetHandle(ptiIMC->spDefaultImc);
-            break;
-    }
-
-Quit:
-    UserLeave();
-    return ret;
-}
-
 BOOL
 APIENTRY
 NtUserRealInternalGetMessage(
@@ -1015,34 +838,6 @@ Quit:
     return Status;
 }
-DWORD
-APIENTRY
-NtUserSetThreadLayoutHandles(HKL hNewKL, HKL hOldKL)
-{
-    PTHREADINFO pti;
-    PKL pOldKL, pNewKL;
-
-    UserEnterExclusive();
-
-    pti = GetW32ThreadInfo();
-    pOldKL = pti->KeyboardLayout;
-    if (pOldKL && pOldKL->hkl != hOldKL)
-        goto Quit;
-
-    pNewKL = UserHklToKbl(hNewKL);
-    if (!pNewKL)
-        goto Quit;
-
-    if (IS_IME_HKL(hNewKL) != IS_IME_HKL(hOldKL))
-        pti->hklPrev = hOldKL;
-
-    pti->KeyboardLayout = pNewKL;
-
-Quit:
-    UserLeave();
-    return 0;
-}
-
 BOOL
 APIENTRY
 NtUserSoundSentry(VOID)
@@ -1174,5 +969,4 @@ NtDxEngGetRedirectionBitmap(
     return 0;
 }
-
 /* EOF */