https://git.reactos.org/?p=reactos.git;a=commitdiff;h=fcc222c28a48e464a88cfd...
commit fcc222c28a48e464a88cfdd809f89d45c16af472 Author: Katayama Hirofumi MZ katayama.hirofumi.mz@gmail.com AuthorDate: Fri Dec 31 10:20:53 2021 +0900 Commit: GitHub noreply@github.com CommitDate: Fri Dec 31 10:20:53 2021 +0900
[NTUSER] Implement NtUserDisableThreadIme (#4216)
CORE-11700 --- win32ss/include/ntuser.h | 4 +-- win32ss/user/ntuser/ime.c | 69 ++++++++++++++++++++++++++++++++++++++++---- win32ss/user/ntuser/ntuser.h | 2 +- win32ss/user/ntuser/win32.h | 1 + 4 files changed, 68 insertions(+), 8 deletions(-)
diff --git a/win32ss/include/ntuser.h b/win32ss/include/ntuser.h index 339076b4984..9d936530827 100644 --- a/win32ss/include/ntuser.h +++ b/win32ss/include/ntuser.h @@ -2038,10 +2038,10 @@ NTAPI NtUserDestroyWindow( HWND Wnd);
-DWORD +BOOL NTAPI NtUserDisableThreadIme( - DWORD dwUnknown1); + DWORD dwThreadID);
LRESULT NTAPI diff --git a/win32ss/user/ntuser/ime.c b/win32ss/user/ntuser/ime.c index 12914ccb171..c172f28a70c 100644 --- a/win32ss/user/ntuser/ime.c +++ b/win32ss/user/ntuser/ime.c @@ -10,6 +10,7 @@ #include <win32k.h> DBG_DEFAULT_CHANNEL(UserMisc);
+#define INVALID_THREAD_ID ((ULONG)-1)
UINT FASTCALL IntImmProcessKey(PUSER_MESSAGE_QUEUE MessageQueue, PWND pWnd, UINT Msg, WPARAM wParam, LPARAM lParam) @@ -80,14 +81,72 @@ NtUserCheckImeHotKey( return 0; }
- -DWORD +BOOL APIENTRY NtUserDisableThreadIme( - DWORD dwUnknown1) + DWORD dwThreadID) { - STUB; - return 0; + PTHREADINFO pti, ptiCurrent; + PPROCESSINFO ppi; + BOOL ret = FALSE; + + UserEnterExclusive(); + + if (!IS_IMM_MODE()) + { + EngSetLastError(ERROR_CALL_NOT_IMPLEMENTED); + goto Quit; + } + + ptiCurrent = GetW32ThreadInfo(); + + if (dwThreadID == INVALID_THREAD_ID) + { + ppi = ptiCurrent->ppi; + ppi->W32PF_flags |= W32PF_DISABLEIME; + +Retry: + for (pti = ppi->ptiList; pti; pti = pti->ptiSibling) + { + pti->TIF_flags |= TIF_DISABLEIME; + + if (pti->spwndDefaultIme) + { + co_UserDestroyWindow(pti->spwndDefaultIme); + pti->spwndDefaultIme = NULL; + goto Retry; /* The contents of ppi->ptiList may be changed. */ + } + } + } + else + { + if (dwThreadID == 0) + { + pti = ptiCurrent; + } + else + { + pti = IntTID2PTI(UlongToHandle(dwThreadID)); + + /* The thread needs to reside in the current process. */ + if (!pti || pti->ppi != ptiCurrent->ppi) + goto Quit; + } + + pti->TIF_flags |= TIF_DISABLEIME; + + if (pti->spwndDefaultIme) + { + co_UserDestroyWindow(pti->spwndDefaultIme); + pti->spwndDefaultIme = NULL; + } + } + + ret = TRUE; + +Quit: + UserLeave(); + return ret; }
DWORD diff --git a/win32ss/user/ntuser/ntuser.h b/win32ss/user/ntuser/ntuser.h index d456564b159..29ee2fae600 100644 --- a/win32ss/user/ntuser/ntuser.h +++ b/win32ss/user/ntuser/ntuser.h @@ -4,7 +4,7 @@ #define RETURN(value) { _ret_ = value; goto _cleanup_; } #define CLEANUP /*unreachable*/ ASSERT(FALSE); _cleanup_ #define END_CLEANUP return _ret_; - +#define IS_IMM_MODE() (gpsi && (gpsi->dwSRVIFlags & SRVINFO_IMM32))
#define UserEnterCo UserEnterExclusive #define UserLeaveCo UserLeave diff --git a/win32ss/user/ntuser/win32.h b/win32ss/user/ntuser/win32.h index e7d3ac0e52a..585a7191589 100644 --- a/win32ss/user/ntuser/win32.h +++ b/win32ss/user/ntuser/win32.h @@ -25,6 +25,7 @@ #define W32PF_OLELOADED 0x00100000 #define W32PF_SCREENSAVER 0x00200000 #define W32PF_IDLESCREENSAVER 0x00400000 +#define W32PF_DISABLEIME 0x00800000 #define W32PF_ICONTITLEREGISTERED 0x10000000 #define W32PF_DPIAWARE 0x20000000 // ReactOS