https://git.reactos.org/?p=reactos.git;a=commitdiff;h=1bc9dda5e6ab80524aa00…
commit 1bc9dda5e6ab80524aa0012bd7a75d162325a232
Author: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com>
AuthorDate: Mon Feb 7 10:45:02 2022 +0900
Commit: GitHub <noreply(a)github.com>
CommitDate: Mon Feb 7 10:45:02 2022 +0900
[NTUSER] Rewrite NtUserDestroyInputContext (#4342)
CORE-11700
---
win32ss/user/ntuser/ime.c | 55 ++++++++++++++++++++++++++++++++++++-----------
1 file changed, 42 insertions(+), 13 deletions(-)
diff --git a/win32ss/user/ntuser/ime.c b/win32ss/user/ntuser/ime.c
index 06b7eabe5fe..98007549568 100644
--- a/win32ss/user/ntuser/ime.c
+++ b/win32ss/user/ntuser/ime.c
@@ -27,6 +27,13 @@ PWND FASTCALL IntGetTopLevelWindow(PWND pwnd)
return pwnd;
}
+HIMC FASTCALL IntAssociateInputContext(PWND pWnd, PIMC pImc)
+{
+ HIMC hOldImc = pWnd->hImc;
+ pWnd->hImc = (pImc ? UserHMGetHandle(pImc) : NULL);
+ return hOldImc;
+}
+
DWORD
APIENTRY
NtUserSetThreadLayoutHandles(HKL hNewKL, HKL hOldKL)
@@ -612,20 +619,49 @@ BOOL APIENTRY NtUserDestroyInputContext(HIMC hIMC)
{
PIMC pIMC;
BOOL ret = FALSE;
+ HWND *phwnd;
+ PWND pWnd;
+ PWINDOWLIST pwl;
+ PTHREADINFO pti;
UserEnterExclusive();
- if (!(gpsi->dwSRVIFlags & SRVINFO_IMM32))
+ if (!IS_IMM_MODE())
{
EngSetLastError(ERROR_CALL_NOT_IMPLEMENTED);
- UserLeave();
- return FALSE;
+ goto Quit;
}
- pIMC = UserGetObject(gHandleTable, hIMC, TYPE_INPUTCONTEXT);
- if (pIMC)
- ret = UserDereferenceObject(pIMC);
+ pIMC = UserGetObjectNoErr(gHandleTable, hIMC, TYPE_INPUTCONTEXT);
+ if (!pIMC)
+ goto Quit;
+
+ pti = pIMC->head.pti;
+ if (pti != GetW32ThreadInfo() || pIMC == pti->spDefaultImc)
+ goto Quit;
+
+ UserMarkObjectDestroy(pIMC);
+
+ pwl = IntBuildHwndList(pti->rpdesk->pDeskInfo->spwnd->spwndChild,
+ IACE_CHILDREN | IACE_LIST, pti);
+ if (pwl)
+ {
+ for (phwnd = pwl->ahwnd; *phwnd != HWND_TERMINATOR; ++phwnd)
+ {
+ pWnd = ValidateHwndNoErr(*phwnd);
+ if (!pWnd)
+ continue;
+
+ if (pWnd->hImc == hIMC)
+ IntAssociateInputContext(pWnd, pti->spDefaultImc);
+ }
+
+ IntFreeHwndList(pwl);
+ }
+ ret = UserDeleteObject(hIMC, TYPE_INPUTCONTEXT);
+
+Quit:
UserLeave();
return ret;
}
@@ -695,13 +731,6 @@ Quit:
return ret;
}
-HIMC FASTCALL IntAssociateInputContext(PWND pWnd, PIMC pImc)
-{
- HIMC hOldImc = pWnd->hImc;
- pWnd->hImc = (pImc ? UserHMGetHandle(pImc) : NULL);
- return hOldImc;
-}
-
DWORD FASTCALL IntAssociateInputContextEx(PWND pWnd, PIMC pIMC, DWORD dwFlags)
{
DWORD ret = 0;