[IMM32] Use Imm32IsImmMode and Imm32IsCiceroMode macros (#3971)

- Define Imm32IsImmMode, Imm32IsCiceroMode and Imm32Is16BitMode macros in "precomp.h".
- Improve Imm32InquireIme and Imm32CleanupContext functions.
- Add IME_SYSINFO_WINLOGON and IME_SYSINFO_WOW16 macros (from DDK) in psdk/imm.h.
- Modify CtfImeInquireExW and CtfImeSelectEx prototype.
CORE-11700
This commit is contained in:
Katayama Hirofumi MZ 2021-09-24 22:06:29 +09:00 committed by GitHub
parent e372f2b19b
commit ca3fa7197d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 50 additions and 67 deletions

View file

@ -46,23 +46,26 @@ BOOL APIENTRY Imm32InquireIme(PIMEDPI pImeDpi)
{
WCHAR szUIClass[64];
WNDCLASSW wcW;
DWORD dwSysInfoFlags = 0; // TODO: ???
DWORD dwSysInfoFlags = 0;
LPIMEINFO pImeInfo = &pImeDpi->ImeInfo;
// TODO: NtUserGetThreadState(16);
if (NtUserGetThreadState(16))
dwSysInfoFlags |= IME_SYSINFO_WINLOGON;
if (!IS_IME_HKL(pImeDpi->hKL))
if (IS_IME_HKL(pImeDpi->hKL))
{
if (g_psi && (g_psi->dwSRVIFlags & SRVINFO_CICERO_ENABLED) &&
pImeDpi->CtfImeInquireExW)
{
// TODO:
if (!pImeDpi->ImeInquire(pImeInfo, szUIClass, dwSysInfoFlags))
return FALSE;
}
}
if (!pImeDpi->ImeInquire(pImeInfo, szUIClass, dwSysInfoFlags))
else if (Imm32IsCiceroMode() && pImeDpi->CtfImeInquireExW)
{
if (!pImeDpi->CtfImeInquireExW(pImeInfo, szUIClass, dwSysInfoFlags, pImeDpi->hKL))
return FALSE;
}
else
{
return FALSE;
}
szUIClass[_countof(szUIClass) - 1] = 0;
@ -257,18 +260,10 @@ PIMEDPI APIENTRY Ime32LoadImeDpi(HKL hKL, BOOL bLock)
PIMEDPI APIENTRY ImmLockOrLoadImeDpi(HKL hKL)
{
PW32CLIENTINFO pInfo;
PIMEDPI pImeDpi;
if (!IS_IME_HKL(hKL))
{
if (!g_psi || !(g_psi->dwSRVIFlags & SRVINFO_CICERO_ENABLED))
return NULL;
pInfo = (PW32CLIENTINFO)(NtCurrentTeb()->Win32ClientInfo);
if ((pInfo->W32ClientInfo[0] & 2))
return NULL;
}
if (!IS_IME_HKL(hKL) && (!Imm32IsCiceroMode() || Imm32Is16BitMode()))
return NULL;
pImeDpi = ImmLockImeDpi(hKL);
if (pImeDpi == NULL)
@ -282,11 +277,9 @@ ImeDpi_Escape(PIMEDPI pImeDpi, HIMC hIMC, UINT uSubFunc, LPVOID lpData, HKL hKL)
if (IS_IME_HKL(hKL))
return pImeDpi->ImeEscape(hIMC, uSubFunc, lpData);
if (g_psi && (g_psi->dwSRVIFlags & SRVINFO_CICERO_ENABLED))
{
if (pImeDpi->CtfImeEscapeEx)
return pImeDpi->CtfImeEscapeEx(hIMC, uSubFunc, lpData, hKL);
}
if (Imm32IsCiceroMode() && pImeDpi->CtfImeEscapeEx)
return pImeDpi->CtfImeEscapeEx(hIMC, uSubFunc, lpData, hKL);
return 0;
}
@ -305,7 +298,7 @@ BOOL WINAPI ImmIsIME(HKL hKL)
*/
HWND WINAPI ImmGetDefaultIMEWnd(HWND hWnd)
{
if (!g_psi || !(g_psi->dwSRVIFlags & SRVINFO_IMM32))
if (!Imm32IsImmMode())
return NULL;
// FIXME: NtUserGetThreadState and enum ThreadStateRoutines are broken.
@ -367,7 +360,6 @@ ImmGetImeInfoEx(PIMEINFOEX pImeInfoEx, IMEINFOEXCLASS SearchType, PVOID pvSearch
{
BOOL bDisabled = FALSE;
HKL hKL;
PTEB pTeb;
switch (SearchType)
{
@ -390,10 +382,9 @@ ImmGetImeInfoEx(PIMEINFOEX pImeInfoEx, IMEINFOEXCLASS SearchType, PVOID pvSearch
if (!IS_IME_HKL(hKL))
{
if (g_psi && (g_psi->dwSRVIFlags & SRVINFO_CICERO_ENABLED))
if (Imm32IsCiceroMode())
{
pTeb = NtCurrentTeb();
if (((PW32CLIENTINFO)pTeb->Win32ClientInfo)->W32ClientInfo[0] & 2)
if (Imm32Is16BitMode())
return FALSE;
if (!bDisabled)
goto Quit;
@ -487,18 +478,10 @@ VOID WINAPI ImmUnlockImeDpi(PIMEDPI pImeDpi)
*/
BOOL WINAPI ImmLoadIME(HKL hKL)
{
PW32CLIENTINFO pInfo;
PIMEDPI pImeDpi;
if (!IS_IME_HKL(hKL))
{
if (!g_psi || !(g_psi->dwSRVIFlags & SRVINFO_CICERO_ENABLED))
return FALSE;
pInfo = (PW32CLIENTINFO)(NtCurrentTeb()->Win32ClientInfo);
if ((pInfo->W32ClientInfo[0] & 2))
return FALSE;
}
if (!IS_IME_HKL(hKL) && (!Imm32IsCiceroMode() || Imm32Is16BitMode()))
return FALSE;
pImeDpi = Imm32FindImeDpi(hKL);
if (pImeDpi == NULL)
@ -1319,20 +1302,14 @@ BOOL WINAPI ImmSetConversionStatus(HIMC hIMC, DWORD fdwConversion, DWORD fdwSent
HKL hKL;
LPINPUTCONTEXT pIC;
DWORD dwOldConversion, dwOldSentence;
BOOL fConversionChange = FALSE, fSentenceChange = FALSE;
BOOL fConversionChange = FALSE, fSentenceChange = FALSE, fUseCicero = FALSE;
HWND hWnd;
TRACE("(%p, 0x%lX, 0x%lX)\n", hIMC, fdwConversion, fdwSentence);
hKL = GetKeyboardLayout(0);
if (!IS_IME_HKL(hKL))
{
if (g_psi && (g_psi->dwSRVIFlags & SRVINFO_CICERO_ENABLED))
{
FIXME("Cicero\n");
return FALSE;
}
}
if (!IS_IME_HKL(hKL) && Imm32IsCiceroMode() && !Imm32Is16BitMode())
fUseCicero = TRUE;
if (Imm32IsCrossThreadAccess(hIMC))
return FALSE;
@ -1358,14 +1335,15 @@ BOOL WINAPI ImmSetConversionStatus(HIMC hIMC, DWORD fdwConversion, DWORD fdwSent
hWnd = pIC->hWnd;
ImmUnlockIMC(hIMC);
if (fConversionChange)
if (fConversionChange || fUseCicero)
{
Imm32NotifyAction(hIMC, hWnd, NI_CONTEXTUPDATED, dwOldConversion,
IMC_SETCONVERSIONMODE, IMN_SETCONVERSIONMODE, 0);
NtUserNotifyIMEStatus(hWnd, hIMC, fdwConversion);
if (fConversionChange)
NtUserNotifyIMEStatus(hWnd, hIMC, fdwConversion);
}
if (fSentenceChange)
if (fSentenceChange || fUseCicero)
{
Imm32NotifyAction(hIMC, hWnd, NI_CONTEXTUPDATED, dwOldSentence,
IMC_SETSENTENCEMODE, IMN_SETSENTENCEMODE, 0);

View file

@ -62,9 +62,7 @@ HKL WINAPI ImmLoadLayout(HKL hKL, PIMEINFOEX pImeInfoEx)
TRACE("(%p, %p)\n", hKL, pImeInfoEx);
if (IS_IME_HKL(hKL) ||
!g_psi || !(g_psi->dwSRVIFlags & SRVINFO_CICERO_ENABLED) ||
((PW32CLIENTINFO)NtCurrentTeb()->Win32ClientInfo)->W32ClientInfo[0] & 2)
if (IS_IME_HKL(hKL) || !Imm32IsCiceroMode() || Imm32Is16BitMode())
{
UnicodeString.Buffer = szLayout;
UnicodeString.MaximumLength = sizeof(szLayout);
@ -266,7 +264,7 @@ BOOL WINAPI ImmAssociateContextEx(HWND hWnd, HIMC hIMC, DWORD dwFlags)
TRACE("(%p, %p, 0x%lX)\n", hWnd, hIMC, dwFlags);
if (!g_psi || !(g_psi->dwSRVIFlags & SRVINFO_IMM32))
if (!Imm32IsImmMode())
return FALSE;
if (hIMC && !(dwFlags & IACE_DEFAULT) && Imm32IsCrossThreadAccess(hIMC))
@ -311,7 +309,7 @@ HIMC WINAPI ImmCreateContext(void)
TRACE("()\n");
if (g_psi == NULL || !(g_psi->dwSRVIFlags & SRVINFO_IMM32))
if (!Imm32IsImmMode())
return NULL;
pClientImc = Imm32HeapAlloc(HEAP_ZERO_MEMORY, sizeof(CLIENTIMC));
@ -350,7 +348,7 @@ BOOL APIENTRY Imm32CleanupContext(HIMC hIMC, HKL hKL, BOOL bKeep)
LPINPUTCONTEXT pIC;
PCLIENTIMC pClientImc;
if (g_psi == NULL || !(g_psi->dwSRVIFlags & SRVINFO_IMM32) || hIMC == NULL)
if (!Imm32IsImmMode() || hIMC == NULL)
return FALSE;
FIXME("We have do something to do here\n");
@ -385,9 +383,9 @@ BOOL APIENTRY Imm32CleanupContext(HIMC hIMC, HKL hKL, BOOL bKeep)
{
pImeDpi->ImeSelect(hIMC, FALSE);
}
else if (g_psi && (g_psi->dwSRVIFlags & SRVINFO_CICERO_ENABLED))
else if (Imm32IsCiceroMode() && pImeDpi->CtfImeSelectEx)
{
FIXME("We have do something to do here\n");
pImeDpi->CtfImeSelectEx(hIMC, FALSE, hKL);
}
ImmUnlockImeDpi(pImeDpi);
}
@ -422,7 +420,7 @@ BOOL WINAPI ImmDestroyContext(HIMC hIMC)
TRACE("(%p)\n", hIMC);
if (g_psi == NULL || !(g_psi->dwSRVIFlags & SRVINFO_IMM32))
if (!Imm32IsImmMode())
return FALSE;
if (Imm32IsCrossThreadAccess(hIMC))
@ -508,7 +506,7 @@ static HIMC APIENTRY Imm32GetContextEx(HWND hWnd, DWORD dwContextFlags)
PCLIENTIMC pClientImc;
PWND pWnd;
if (!g_psi || !(g_psi->dwSRVIFlags & SRVINFO_IMM32))
if (!Imm32IsImmMode())
return NULL;
if (!hWnd)
@ -843,7 +841,7 @@ HIMC WINAPI ImmGetContext(HWND hWnd)
*/
BOOL WINAPI CtfImmIsCiceroEnabled(VOID)
{
return (g_psi && (g_psi->dwSRVIFlags & SRVINFO_CICERO_ENABLED));
return Imm32IsCiceroMode();
}
/***********************************************************************
@ -1380,7 +1378,7 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpReserved)
break;
case DLL_THREAD_DETACH:
if (g_psi == NULL || !(g_psi->dwSRVIFlags & SRVINFO_IMM32))
if (!Imm32IsImmMode())
return TRUE;
pTeb = NtCurrentTeb();

View file

@ -93,7 +93,10 @@ static inline BOOL Imm32IsCrossProcessAccess(HWND hWnd)
(DWORD_PTR)NtCurrentTeb()->ClientId.UniqueProcess);
}
#define ImeDpi_IsUnicode(pImeDpi) ((pImeDpi)->ImeInfo.fdwProperty & IME_PROP_UNICODE)
#define ImeDpi_IsUnicode(pImeDpi) ((pImeDpi)->ImeInfo.fdwProperty & IME_PROP_UNICODE)
#define Imm32IsImmMode() (g_psi && (g_psi->dwSRVIFlags & SRVINFO_IMM32))
#define Imm32IsCiceroMode() (g_psi && (g_psi->dwSRVIFlags & SRVINFO_CICERO_ENABLED))
#define Imm32Is16BitMode() (GetWin32ClientInfo()->dwTIFlags & TIF_16BIT)
DWORD APIENTRY
CandidateListWideToAnsi(const CANDIDATELIST *pWideCL, LPCANDIDATELIST pAnsiCL, DWORD dwBufLen,

View file

@ -237,6 +237,10 @@ typedef struct tagCANDIDATEINFO {
#define NI_SETCANDIDATE_PAGESIZE 0x0017
#define NI_IMEMENUSELECTED 0x0018
/* dwSystemInfoFlags bits */
#define IME_SYSINFO_WINLOGON 0x0001
#define IME_SYSINFO_WOW16 0x0002
BOOL WINAPI ImmUnlockIMC(HIMC);
DWORD WINAPI ImmGetIMCLockCount(HIMC);
HIMCC WINAPI ImmCreateIMCC(DWORD);

View file

@ -15,8 +15,8 @@ DEFINE_IME_ENTRY(UINT, ImeToAsciiEx, (UINT uVirKey, UINT uScanCode, CONST LPBYTE
DEFINE_IME_ENTRY(BOOL, NotifyIME, (HIMC hIMC, DWORD dwAction, DWORD dwIndex, DWORD dwValue), FALSE)
DEFINE_IME_ENTRY(BOOL, ImeSetCompositionString, (HIMC hIMC, DWORD dwIndex, LPCVOID lpComp, DWORD dwCompLen, LPCVOID lpRead, DWORD dwReadLen), FALSE)
DEFINE_IME_ENTRY(DWORD, ImeGetImeMenuItems, (HIMC hIMC, DWORD dwFlags, DWORD dwType, LPIMEMENUITEMINFOW lpImeParentMenu, LPIMEMENUITEMINFOW lpImeMenu, DWORD dwSize), FALSE)
DEFINE_IME_ENTRY(DWORD, CtfImeInquireExW, (VOID /* FIXME: unknown */), TRUE)
DEFINE_IME_ENTRY(DWORD, CtfImeSelectEx, (VOID /* FIXME: unknown */), TRUE)
DEFINE_IME_ENTRY(BOOL, CtfImeInquireExW, (LPIMEINFO lpIMEInfo, LPVOID lpszWndClass, DWORD dwSystemInfoFlags, HKL hKL), TRUE)
DEFINE_IME_ENTRY(BOOL, CtfImeSelectEx, (HIMC hIMC, BOOL fSelect, HKL hKL), TRUE)
DEFINE_IME_ENTRY(LRESULT, CtfImeEscapeEx, (HIMC hIMC, UINT uSubFunc, LPVOID lpData, HKL hKL), TRUE)
DEFINE_IME_ENTRY(DWORD, CtfImeGetGuidAtom, (VOID /* FIXME: unknown */), TRUE)
DEFINE_IME_ENTRY(DWORD, CtfImeIsGuidMapEnable, (VOID /* FIXME: unknown */), TRUE)