mirror of
https://github.com/reactos/reactos.git
synced 2024-12-29 02:25:17 +00:00
[IMM32] Refactor and simplify code (#3900)
- Add Imm32WideFromAnsi, Imm32AnsiFromWide and Imm32IsCrossThreadAccess helper functions. - Simplify the IMM32 code by using the helper functions. CORE-11700
This commit is contained in:
parent
719823179d
commit
1da5d7a305
1 changed files with 82 additions and 129 deletions
|
@ -96,6 +96,29 @@ LPVOID APIENTRY Imm32HeapAlloc(DWORD dwFlags, DWORD dwBytes)
|
||||||
return HeapAlloc(g_hImm32Heap, dwFlags, dwBytes);
|
return HeapAlloc(g_hImm32Heap, dwFlags, dwBytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static LPWSTR APIENTRY Imm32WideFromAnsi(LPCSTR pszA)
|
||||||
|
{
|
||||||
|
INT cch = lstrlenA(pszA);
|
||||||
|
LPWSTR pszW = Imm32HeapAlloc(0, (cch + 1) * sizeof(WCHAR));
|
||||||
|
if (pszW == NULL)
|
||||||
|
return NULL;
|
||||||
|
cch = MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, pszA, cch, pszW, cch + 1);
|
||||||
|
pszW[cch] = 0;
|
||||||
|
return pszW;
|
||||||
|
}
|
||||||
|
|
||||||
|
static LPSTR APIENTRY Imm32AnsiFromWide(LPCWSTR pszW)
|
||||||
|
{
|
||||||
|
INT cchW = lstrlenW(pszW);
|
||||||
|
INT cchA = (cchW + 1) * sizeof(WCHAR);
|
||||||
|
LPSTR pszA = Imm32HeapAlloc(0, cchA);
|
||||||
|
if (!pszA)
|
||||||
|
return NULL;
|
||||||
|
cchA = WideCharToMultiByte(CP_ACP, 0, pszW, cchW, pszA, cchA, NULL, NULL);
|
||||||
|
pszA[cchA] = 0;
|
||||||
|
return pszA;
|
||||||
|
}
|
||||||
|
|
||||||
static DWORD_PTR APIENTRY Imm32QueryWindow(HWND hWnd, DWORD Index)
|
static DWORD_PTR APIENTRY Imm32QueryWindow(HWND hWnd, DWORD Index)
|
||||||
{
|
{
|
||||||
return NtUserQueryWindow(hWnd, Index);
|
return NtUserQueryWindow(hWnd, Index);
|
||||||
|
@ -112,6 +135,13 @@ static DWORD APIENTRY Imm32QueryInputContext(HIMC hIMC, DWORD dwUnknown2)
|
||||||
return NtUserQueryInputContext(hIMC, dwUnknown2);
|
return NtUserQueryInputContext(hIMC, dwUnknown2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline BOOL Imm32IsCrossThreadAccess(HIMC hIMC)
|
||||||
|
{
|
||||||
|
DWORD dwImeThreadId = Imm32QueryInputContext(hIMC, 1);
|
||||||
|
DWORD dwThreadId = GetCurrentThreadId();
|
||||||
|
return (dwImeThreadId != dwThreadId);
|
||||||
|
}
|
||||||
|
|
||||||
static DWORD APIENTRY Imm32NotifyIMEStatus(HWND hwnd, HIMC hIMC, DWORD dwConversion)
|
static DWORD APIENTRY Imm32NotifyIMEStatus(HWND hwnd, HIMC hIMC, DWORD dwConversion)
|
||||||
{
|
{
|
||||||
return NtUserNotifyIMEStatus(hwnd, hIMC, dwConversion);
|
return NtUserNotifyIMEStatus(hwnd, hIMC, dwConversion);
|
||||||
|
@ -416,6 +446,9 @@ static PIMEDPI APIENTRY Ime32LoadImeDpi(HKL hKL, BOOL bLock)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
* ImmLoadIME (IMM32.@)
|
||||||
|
*/
|
||||||
BOOL WINAPI ImmLoadIME(HKL hKL)
|
BOOL WINAPI ImmLoadIME(HKL hKL)
|
||||||
{
|
{
|
||||||
PW32CLIENTINFO pInfo;
|
PW32CLIENTINFO pInfo;
|
||||||
|
@ -458,6 +491,9 @@ PIMEDPI APIENTRY ImmLockOrLoadImeDpi(HKL hKL)
|
||||||
return pImeDpi;
|
return pImeDpi;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
* ImmLoadLayout (IMM32.@)
|
||||||
|
*/
|
||||||
HKL WINAPI ImmLoadLayout(HKL hKL, PIMEINFOEX pImeInfoEx)
|
HKL WINAPI ImmLoadLayout(HKL hKL, PIMEINFOEX pImeInfoEx)
|
||||||
{
|
{
|
||||||
DWORD cbData;
|
DWORD cbData;
|
||||||
|
@ -1113,7 +1149,6 @@ BOOL APIENTRY Imm32CleanupContext(HIMC hIMC, HKL hKL, BOOL bKeep)
|
||||||
*/
|
*/
|
||||||
BOOL WINAPI ImmDestroyContext(HIMC hIMC)
|
BOOL WINAPI ImmDestroyContext(HIMC hIMC)
|
||||||
{
|
{
|
||||||
DWORD dwImeThreadId, dwThreadId;
|
|
||||||
HKL hKL;
|
HKL hKL;
|
||||||
|
|
||||||
TRACE("(%p)\n", hIMC);
|
TRACE("(%p)\n", hIMC);
|
||||||
|
@ -1121,9 +1156,7 @@ BOOL WINAPI ImmDestroyContext(HIMC hIMC)
|
||||||
if (g_psi == NULL || !(g_psi->dwSRVIFlags & SRVINFO_IMM32))
|
if (g_psi == NULL || !(g_psi->dwSRVIFlags & SRVINFO_IMM32))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
dwImeThreadId = Imm32QueryInputContext(hIMC, 1);
|
if (Imm32IsCrossThreadAccess(hIMC))
|
||||||
dwThreadId = GetCurrentThreadId();
|
|
||||||
if (dwImeThreadId != dwThreadId)
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
hKL = GetKeyboardLayout(0);
|
hKL = GetKeyboardLayout(0);
|
||||||
|
@ -1505,17 +1538,11 @@ static BOOL APIENTRY Imm32KEnglish(HIMC hIMC)
|
||||||
|
|
||||||
static BOOL APIENTRY Imm32ProcessHotKey(HWND hWnd, HIMC hIMC, HKL hKL, DWORD dwHotKeyID)
|
static BOOL APIENTRY Imm32ProcessHotKey(HWND hWnd, HIMC hIMC, HKL hKL, DWORD dwHotKeyID)
|
||||||
{
|
{
|
||||||
DWORD dwImeThreadId, dwThreadId;
|
|
||||||
PIMEDPI pImeDpi;
|
PIMEDPI pImeDpi;
|
||||||
BOOL ret;
|
BOOL ret;
|
||||||
|
|
||||||
if (hIMC)
|
if (hIMC && Imm32IsCrossThreadAccess(hIMC))
|
||||||
{
|
|
||||||
dwImeThreadId = Imm32QueryInputContext(hIMC, 1);
|
|
||||||
dwThreadId = GetCurrentThreadId();
|
|
||||||
if (dwImeThreadId != dwThreadId)
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
|
||||||
|
|
||||||
switch (dwHotKeyID)
|
switch (dwHotKeyID)
|
||||||
{
|
{
|
||||||
|
@ -1565,6 +1592,9 @@ static BOOL APIENTRY Imm32ProcessHotKey(HWND hWnd, HIMC hIMC, HKL hKL, DWORD dwH
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
* ImmLockClientImc (IMM32.@)
|
||||||
|
*/
|
||||||
PCLIENTIMC WINAPI ImmLockClientImc(HIMC hImc)
|
PCLIENTIMC WINAPI ImmLockClientImc(HIMC hImc)
|
||||||
{
|
{
|
||||||
PCLIENTIMC pClientImc;
|
PCLIENTIMC pClientImc;
|
||||||
|
@ -1602,6 +1632,9 @@ PCLIENTIMC WINAPI ImmLockClientImc(HIMC hImc)
|
||||||
return pClientImc;
|
return pClientImc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
* ImmUnlockClientImc (IMM32.@)
|
||||||
|
*/
|
||||||
VOID WINAPI ImmUnlockClientImc(PCLIENTIMC pClientImc)
|
VOID WINAPI ImmUnlockClientImc(PCLIENTIMC pClientImc)
|
||||||
{
|
{
|
||||||
LONG cLocks;
|
LONG cLocks;
|
||||||
|
@ -2403,7 +2436,6 @@ BOOL WINAPI ImmGetCompositionWindow(HIMC hIMC, LPCOMPOSITIONFORM lpCompForm)
|
||||||
|
|
||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
* ImmGetContext (IMM32.@)
|
* ImmGetContext (IMM32.@)
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
HIMC WINAPI ImmGetContext(HWND hWnd)
|
HIMC WINAPI ImmGetContext(HWND hWnd)
|
||||||
{
|
{
|
||||||
|
@ -2443,7 +2475,6 @@ DWORD WINAPI ImmGetConversionListA(
|
||||||
DWORD dwBufLen, UINT uFlag)
|
DWORD dwBufLen, UINT uFlag)
|
||||||
{
|
{
|
||||||
DWORD ret = 0;
|
DWORD ret = 0;
|
||||||
INT cchA, cchW;
|
|
||||||
UINT cb;
|
UINT cb;
|
||||||
LPWSTR pszSrcW = NULL;
|
LPWSTR pszSrcW = NULL;
|
||||||
LPCANDIDATELIST pCL = NULL;
|
LPCANDIDATELIST pCL = NULL;
|
||||||
|
@ -2465,13 +2496,9 @@ DWORD WINAPI ImmGetConversionListA(
|
||||||
|
|
||||||
if (pSrc)
|
if (pSrc)
|
||||||
{
|
{
|
||||||
cchA = lstrlenA(pSrc);
|
pszSrcW = Imm32WideFromAnsi(pSrc);
|
||||||
cchW = cchA + 1;
|
|
||||||
pszSrcW = Imm32HeapAlloc(0, cchW * sizeof(WCHAR));
|
|
||||||
if (pszSrcW == NULL)
|
if (pszSrcW == NULL)
|
||||||
goto Quit;
|
goto Quit;
|
||||||
cchW = MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, pSrc, cchA, pszSrcW, cchW);
|
|
||||||
pszSrcW[cchW] = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
cb = pImeDpi->ImeConversionList(hIMC, pszSrcW, NULL, 0, uFlag);
|
cb = pImeDpi->ImeConversionList(hIMC, pszSrcW, NULL, 0, uFlag);
|
||||||
|
@ -2506,8 +2533,7 @@ DWORD WINAPI ImmGetConversionListW(
|
||||||
DWORD dwBufLen, UINT uFlag)
|
DWORD dwBufLen, UINT uFlag)
|
||||||
{
|
{
|
||||||
DWORD ret = 0;
|
DWORD ret = 0;
|
||||||
INT cb, cchW;
|
INT cb;
|
||||||
BOOL bUsedDefault;
|
|
||||||
PIMEDPI pImeDpi;
|
PIMEDPI pImeDpi;
|
||||||
LPCANDIDATELIST pCL = NULL;
|
LPCANDIDATELIST pCL = NULL;
|
||||||
LPSTR pszSrcA = NULL;
|
LPSTR pszSrcA = NULL;
|
||||||
|
@ -2528,13 +2554,9 @@ DWORD WINAPI ImmGetConversionListW(
|
||||||
|
|
||||||
if (pSrc)
|
if (pSrc)
|
||||||
{
|
{
|
||||||
cchW = lstrlenW(pSrc);
|
pszSrcA = Imm32AnsiFromWide(pSrc);
|
||||||
cb = (cchW + 1) * 2;
|
|
||||||
pszSrcA = Imm32HeapAlloc(0, cb);
|
|
||||||
if (pszSrcA == NULL)
|
if (pszSrcA == NULL)
|
||||||
goto Quit;
|
goto Quit;
|
||||||
cb = WideCharToMultiByte(CP_ACP, 0, pSrc, cchW, pszSrcA, cb, NULL, &bUsedDefault);
|
|
||||||
pszSrcA[cb] = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
cb = pImeDpi->ImeConversionList(hIMC, pszSrcA, NULL, 0, uFlag);
|
cb = pImeDpi->ImeConversionList(hIMC, pszSrcA, NULL, 0, uFlag);
|
||||||
|
@ -3166,31 +3188,25 @@ UINT WINAPI ImmGetVirtualKey(HWND hWnd)
|
||||||
HKL WINAPI ImmInstallIMEA(
|
HKL WINAPI ImmInstallIMEA(
|
||||||
LPCSTR lpszIMEFileName, LPCSTR lpszLayoutText)
|
LPCSTR lpszIMEFileName, LPCSTR lpszLayoutText)
|
||||||
{
|
{
|
||||||
INT cchFileName, cchLayoutText;
|
HKL hKL = NULL;
|
||||||
LPWSTR pszFileNameW, pszLayoutTextW;
|
LPWSTR pszFileNameW = NULL, pszLayoutTextW = NULL;
|
||||||
HKL hKL;
|
|
||||||
|
|
||||||
TRACE("(%s, %s)\n", debugstr_a(lpszIMEFileName), debugstr_a(lpszLayoutText));
|
TRACE("(%s, %s)\n", debugstr_a(lpszIMEFileName), debugstr_a(lpszLayoutText));
|
||||||
|
|
||||||
cchFileName = lstrlenA(lpszIMEFileName) + 1;
|
pszFileNameW = Imm32WideFromAnsi(lpszIMEFileName);
|
||||||
cchLayoutText = lstrlenA(lpszLayoutText) + 1;
|
|
||||||
|
|
||||||
pszFileNameW = Imm32HeapAlloc(0, cchFileName * sizeof(WCHAR));
|
|
||||||
if (pszFileNameW == NULL)
|
if (pszFileNameW == NULL)
|
||||||
return NULL;
|
goto Quit;
|
||||||
|
|
||||||
pszLayoutTextW = Imm32HeapAlloc(0, cchLayoutText * sizeof(WCHAR));
|
pszLayoutTextW = Imm32WideFromAnsi(lpszLayoutText);
|
||||||
if (pszLayoutTextW == NULL)
|
if (pszLayoutTextW == NULL)
|
||||||
{
|
goto Quit;
|
||||||
HeapFree(g_hImm32Heap, 0, pszFileNameW);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, lpszIMEFileName, -1, pszFileNameW, cchFileName);
|
|
||||||
MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, lpszLayoutText, -1, pszLayoutTextW, cchLayoutText);
|
|
||||||
|
|
||||||
hKL = ImmInstallIMEW(pszFileNameW, pszLayoutTextW);
|
hKL = ImmInstallIMEW(pszFileNameW, pszLayoutTextW);
|
||||||
|
|
||||||
|
Quit:
|
||||||
|
if (pszFileNameW)
|
||||||
HeapFree(g_hImm32Heap, 0, pszFileNameW);
|
HeapFree(g_hImm32Heap, 0, pszFileNameW);
|
||||||
|
if (pszLayoutTextW)
|
||||||
HeapFree(g_hImm32Heap, 0, pszLayoutTextW);
|
HeapFree(g_hImm32Heap, 0, pszLayoutTextW);
|
||||||
return hKL;
|
return hKL;
|
||||||
}
|
}
|
||||||
|
@ -3313,20 +3329,14 @@ BOOL WINAPI ImmIsUIMessageW(
|
||||||
BOOL WINAPI ImmNotifyIME(
|
BOOL WINAPI ImmNotifyIME(
|
||||||
HIMC hIMC, DWORD dwAction, DWORD dwIndex, DWORD dwValue)
|
HIMC hIMC, DWORD dwAction, DWORD dwIndex, DWORD dwValue)
|
||||||
{
|
{
|
||||||
DWORD dwImeThreadId, dwThreadId;
|
|
||||||
HKL hKL;
|
HKL hKL;
|
||||||
PIMEDPI pImeDpi;
|
PIMEDPI pImeDpi;
|
||||||
BOOL ret;
|
BOOL ret;
|
||||||
|
|
||||||
TRACE("(%p, %lu, %lu, %lu)\n", hIMC, dwAction, dwIndex, dwValue);
|
TRACE("(%p, %lu, %lu, %lu)\n", hIMC, dwAction, dwIndex, dwValue);
|
||||||
|
|
||||||
if (hIMC)
|
if (hIMC && Imm32IsCrossThreadAccess(hIMC))
|
||||||
{
|
|
||||||
dwImeThreadId = Imm32QueryWindow(hIMC, QUERY_WINDOW_UNIQUE_THREAD_ID);
|
|
||||||
dwThreadId = GetCurrentThreadId();
|
|
||||||
if (dwImeThreadId != dwThreadId)
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
|
||||||
|
|
||||||
hKL = GetKeyboardLayout(0);
|
hKL = GetKeyboardLayout(0);
|
||||||
pImeDpi = ImmLockImeDpi(hKL);
|
pImeDpi = ImmLockImeDpi(hKL);
|
||||||
|
@ -3347,7 +3357,6 @@ BOOL WINAPI ImmRegisterWordA(
|
||||||
BOOL ret = FALSE;
|
BOOL ret = FALSE;
|
||||||
PIMEDPI pImeDpi;
|
PIMEDPI pImeDpi;
|
||||||
LPWSTR pszReadingW = NULL, pszRegisterW = NULL;
|
LPWSTR pszReadingW = NULL, pszRegisterW = NULL;
|
||||||
INT cch;
|
|
||||||
|
|
||||||
TRACE("(%p, %s, 0x%lX, %s)\n", hKL, debugstr_a(lpszReading), dwStyle,
|
TRACE("(%p, %s, 0x%lX, %s)\n", hKL, debugstr_a(lpszReading), dwStyle,
|
||||||
debugstr_a(lpszRegister));
|
debugstr_a(lpszRegister));
|
||||||
|
@ -3365,24 +3374,16 @@ BOOL WINAPI ImmRegisterWordA(
|
||||||
|
|
||||||
if (lpszReading)
|
if (lpszReading)
|
||||||
{
|
{
|
||||||
cch = lstrlenA(lpszReading);
|
pszReadingW = Imm32WideFromAnsi(lpszReading);
|
||||||
pszReadingW = Imm32HeapAlloc(0, (cch + 1) * sizeof(WCHAR));
|
|
||||||
if (pszReadingW == NULL)
|
if (pszReadingW == NULL)
|
||||||
goto Quit;
|
goto Quit;
|
||||||
cch = MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, lpszReading, cch,
|
|
||||||
pszReadingW, cch + 1);
|
|
||||||
pszReadingW[cch] = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lpszRegister)
|
if (lpszRegister)
|
||||||
{
|
{
|
||||||
cch = lstrlenA(lpszRegister);
|
pszRegisterW = Imm32WideFromAnsi(lpszRegister);
|
||||||
pszRegisterW = Imm32HeapAlloc(0, (cch + 1) * sizeof(WCHAR));
|
|
||||||
if (pszRegisterW == NULL)
|
if (pszRegisterW == NULL)
|
||||||
goto Quit;
|
goto Quit;
|
||||||
cch = MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, lpszRegister, cch,
|
|
||||||
pszRegisterW, cch + 1);
|
|
||||||
pszRegisterW[cch] = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = pImeDpi->ImeRegisterWord(pszReadingW, dwStyle, pszRegisterW);
|
ret = pImeDpi->ImeRegisterWord(pszReadingW, dwStyle, pszRegisterW);
|
||||||
|
@ -3405,7 +3406,6 @@ BOOL WINAPI ImmRegisterWordW(
|
||||||
BOOL ret = FALSE;
|
BOOL ret = FALSE;
|
||||||
PIMEDPI pImeDpi;
|
PIMEDPI pImeDpi;
|
||||||
LPSTR pszReadingA = NULL, pszRegisterA = NULL;
|
LPSTR pszReadingA = NULL, pszRegisterA = NULL;
|
||||||
INT cchW, cchA;
|
|
||||||
|
|
||||||
TRACE("(%p, %s, 0x%lX, %s)\n", hKL, debugstr_w(lpszReading), dwStyle,
|
TRACE("(%p, %s, 0x%lX, %s)\n", hKL, debugstr_w(lpszReading), dwStyle,
|
||||||
debugstr_w(lpszRegister));
|
debugstr_w(lpszRegister));
|
||||||
|
@ -3423,24 +3423,16 @@ BOOL WINAPI ImmRegisterWordW(
|
||||||
|
|
||||||
if (lpszReading)
|
if (lpszReading)
|
||||||
{
|
{
|
||||||
cchW = lstrlenW(lpszReading);
|
pszReadingA = Imm32AnsiFromWide(lpszReading);
|
||||||
cchA = (cchW + 1) * sizeof(WCHAR);
|
|
||||||
pszReadingA = Imm32HeapAlloc(0, cchA);
|
|
||||||
if (!pszReadingA)
|
if (!pszReadingA)
|
||||||
goto Quit;
|
goto Quit;
|
||||||
cchA = WideCharToMultiByte(CP_ACP, 0, lpszReading, cchW, pszReadingA, cchA, NULL, NULL);
|
|
||||||
pszReadingA[cchA] = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lpszRegister)
|
if (lpszRegister)
|
||||||
{
|
{
|
||||||
cchW = lstrlenW(lpszRegister);
|
pszRegisterA = Imm32AnsiFromWide(lpszRegister);
|
||||||
cchA = (cchW + 1) * sizeof(WCHAR);
|
|
||||||
pszRegisterA = Imm32HeapAlloc(0, cchA);
|
|
||||||
if (!pszRegisterA)
|
if (!pszRegisterA)
|
||||||
goto Quit;
|
goto Quit;
|
||||||
cchA = WideCharToMultiByte(CP_ACP, 0, lpszRegister, cchW, pszRegisterA, cchA, NULL, NULL);
|
|
||||||
pszRegisterA[cchA] = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = pImeDpi->ImeRegisterWord(pszReadingA, dwStyle, pszRegisterA);
|
ret = pImeDpi->ImeRegisterWord(pszReadingA, dwStyle, pszRegisterA);
|
||||||
|
@ -3505,7 +3497,6 @@ BOOL WINAPI ImmSetCandidateWindow(
|
||||||
HIMC hIMC, LPCANDIDATEFORM lpCandidate)
|
HIMC hIMC, LPCANDIDATEFORM lpCandidate)
|
||||||
{
|
{
|
||||||
#define MAX_CANDIDATEFORM 4
|
#define MAX_CANDIDATEFORM 4
|
||||||
DWORD dwImeThreadId, dwThreadId;
|
|
||||||
HWND hWnd;
|
HWND hWnd;
|
||||||
LPINPUTCONTEXT pIC;
|
LPINPUTCONTEXT pIC;
|
||||||
|
|
||||||
|
@ -3514,9 +3505,7 @@ BOOL WINAPI ImmSetCandidateWindow(
|
||||||
if (lpCandidate->dwIndex >= MAX_CANDIDATEFORM)
|
if (lpCandidate->dwIndex >= MAX_CANDIDATEFORM)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
dwImeThreadId = Imm32QueryInputContext(hIMC, 1);
|
if (Imm32IsCrossThreadAccess(hIMC))
|
||||||
dwThreadId = GetCurrentThreadId();
|
|
||||||
if (dwImeThreadId != dwThreadId)
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
pIC = ImmLockIMC(hIMC);
|
pIC = ImmLockIMC(hIMC);
|
||||||
|
@ -3565,7 +3554,6 @@ static VOID APIENTRY AnsiToWideLogFont(const LOGFONTA *plfA, LPLOGFONTW plfW)
|
||||||
BOOL WINAPI ImmSetCompositionFontA(HIMC hIMC, LPLOGFONTA lplf)
|
BOOL WINAPI ImmSetCompositionFontA(HIMC hIMC, LPLOGFONTA lplf)
|
||||||
{
|
{
|
||||||
LOGFONTW lfW;
|
LOGFONTW lfW;
|
||||||
DWORD dwImeThreadId, dwThreadId;
|
|
||||||
PCLIENTIMC pClientImc;
|
PCLIENTIMC pClientImc;
|
||||||
BOOL bWide;
|
BOOL bWide;
|
||||||
LPINPUTCONTEXTDX pIC;
|
LPINPUTCONTEXTDX pIC;
|
||||||
|
@ -3575,9 +3563,7 @@ BOOL WINAPI ImmSetCompositionFontA(HIMC hIMC, LPLOGFONTA lplf)
|
||||||
|
|
||||||
TRACE("(%p, %p)\n", hIMC, lplf);
|
TRACE("(%p, %p)\n", hIMC, lplf);
|
||||||
|
|
||||||
dwImeThreadId = Imm32QueryInputContext(hIMC, 1);
|
if (Imm32IsCrossThreadAccess(hIMC))
|
||||||
dwThreadId = GetCurrentThreadId();
|
|
||||||
if (dwImeThreadId != dwThreadId)
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
pClientImc = ImmLockClientImc(hIMC);
|
pClientImc = ImmLockClientImc(hIMC);
|
||||||
|
@ -3625,7 +3611,6 @@ BOOL WINAPI ImmSetCompositionFontA(HIMC hIMC, LPLOGFONTA lplf)
|
||||||
BOOL WINAPI ImmSetCompositionFontW(HIMC hIMC, LPLOGFONTW lplf)
|
BOOL WINAPI ImmSetCompositionFontW(HIMC hIMC, LPLOGFONTW lplf)
|
||||||
{
|
{
|
||||||
LOGFONTA lfA;
|
LOGFONTA lfA;
|
||||||
DWORD dwImeThreadId, dwThreadId;
|
|
||||||
PCLIENTIMC pClientImc;
|
PCLIENTIMC pClientImc;
|
||||||
BOOL bWide;
|
BOOL bWide;
|
||||||
HWND hWnd;
|
HWND hWnd;
|
||||||
|
@ -3635,9 +3620,7 @@ BOOL WINAPI ImmSetCompositionFontW(HIMC hIMC, LPLOGFONTW lplf)
|
||||||
|
|
||||||
TRACE("(%p, %p)\n", hIMC, lplf);
|
TRACE("(%p, %p)\n", hIMC, lplf);
|
||||||
|
|
||||||
dwImeThreadId = Imm32QueryInputContext(hIMC, 1);
|
if (Imm32IsCrossThreadAccess(hIMC))
|
||||||
dwThreadId = GetCurrentThreadId();
|
|
||||||
if (dwImeThreadId != dwThreadId)
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
pClientImc = ImmLockClientImc(hIMC);
|
pClientImc = ImmLockClientImc(hIMC);
|
||||||
|
@ -3800,13 +3783,10 @@ BOOL WINAPI ImmSetCompositionStringW(
|
||||||
BOOL WINAPI ImmSetCompositionWindow(
|
BOOL WINAPI ImmSetCompositionWindow(
|
||||||
HIMC hIMC, LPCOMPOSITIONFORM lpCompForm)
|
HIMC hIMC, LPCOMPOSITIONFORM lpCompForm)
|
||||||
{
|
{
|
||||||
DWORD dwImeThreadId, dwThreadId;
|
|
||||||
LPINPUTCONTEXT pIC;
|
LPINPUTCONTEXT pIC;
|
||||||
HWND hWnd;
|
HWND hWnd;
|
||||||
|
|
||||||
dwImeThreadId = NtUserQueryInputContext(hIMC, 1);
|
if (Imm32IsCrossThreadAccess(hIMC))
|
||||||
dwThreadId = GetCurrentThreadId();
|
|
||||||
if (dwImeThreadId != dwThreadId)
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
pIC = ImmLockIMC(hIMC);
|
pIC = ImmLockIMC(hIMC);
|
||||||
|
@ -3833,7 +3813,7 @@ BOOL WINAPI ImmSetConversionStatus(
|
||||||
{
|
{
|
||||||
HKL hKL;
|
HKL hKL;
|
||||||
LPINPUTCONTEXT pIC;
|
LPINPUTCONTEXT pIC;
|
||||||
DWORD dwImeThreadId, dwThreadId, dwOldConversion, dwOldSentence;
|
DWORD dwOldConversion, dwOldSentence;
|
||||||
BOOL fConversionChange = FALSE, fSentenceChange = FALSE;
|
BOOL fConversionChange = FALSE, fSentenceChange = FALSE;
|
||||||
HWND hWnd;
|
HWND hWnd;
|
||||||
|
|
||||||
|
@ -3849,9 +3829,7 @@ BOOL WINAPI ImmSetConversionStatus(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dwImeThreadId = Imm32QueryInputContext(hIMC, 1);
|
if (Imm32IsCrossThreadAccess(hIMC))
|
||||||
dwThreadId = GetCurrentThreadId();
|
|
||||||
if (dwImeThreadId != dwThreadId)
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
pIC = ImmLockIMC(hIMC);
|
pIC = ImmLockIMC(hIMC);
|
||||||
|
@ -3973,16 +3951,14 @@ VOID WINAPI ImmUnlockImeDpi(PIMEDPI pImeDpi)
|
||||||
*/
|
*/
|
||||||
BOOL WINAPI ImmSetOpenStatus(HIMC hIMC, BOOL fOpen)
|
BOOL WINAPI ImmSetOpenStatus(HIMC hIMC, BOOL fOpen)
|
||||||
{
|
{
|
||||||
DWORD dwImeThreadId, dwThreadId, dwConversion;
|
DWORD dwConversion;
|
||||||
LPINPUTCONTEXT pIC;
|
LPINPUTCONTEXT pIC;
|
||||||
HWND hWnd;
|
HWND hWnd;
|
||||||
BOOL bHasChange = FALSE;
|
BOOL bHasChange = FALSE;
|
||||||
|
|
||||||
TRACE("(%p, %d)\n", hIMC, fOpen);
|
TRACE("(%p, %d)\n", hIMC, fOpen);
|
||||||
|
|
||||||
dwImeThreadId = Imm32QueryInputContext(hIMC, 1);
|
if (Imm32IsCrossThreadAccess(hIMC))
|
||||||
dwThreadId = GetCurrentThreadId();
|
|
||||||
if (dwImeThreadId != dwThreadId)
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
pIC = ImmLockIMC(hIMC);
|
pIC = ImmLockIMC(hIMC);
|
||||||
|
@ -4016,13 +3992,10 @@ BOOL WINAPI ImmSetStatusWindowPos(HIMC hIMC, LPPOINT lpptPos)
|
||||||
{
|
{
|
||||||
LPINPUTCONTEXT pIC;
|
LPINPUTCONTEXT pIC;
|
||||||
HWND hWnd;
|
HWND hWnd;
|
||||||
DWORD dwImeThreadId, dwThreadId;
|
|
||||||
|
|
||||||
TRACE("(%p, {%ld, %ld})\n", hIMC, lpptPos->x, lpptPos->y);
|
TRACE("(%p, {%ld, %ld})\n", hIMC, lpptPos->x, lpptPos->y);
|
||||||
|
|
||||||
dwImeThreadId = Imm32QueryInputContext(hIMC, 1);
|
if (Imm32IsCrossThreadAccess(hIMC))
|
||||||
dwThreadId = GetCurrentThreadId();
|
|
||||||
if (dwImeThreadId != dwThreadId)
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
pIC = ImmLockIMC(hIMC);
|
pIC = ImmLockIMC(hIMC);
|
||||||
|
@ -4099,7 +4072,6 @@ BOOL WINAPI ImmUnregisterWordA(
|
||||||
BOOL ret = FALSE;
|
BOOL ret = FALSE;
|
||||||
PIMEDPI pImeDpi;
|
PIMEDPI pImeDpi;
|
||||||
LPWSTR pszReadingW = NULL, pszUnregisterW = NULL;
|
LPWSTR pszReadingW = NULL, pszUnregisterW = NULL;
|
||||||
INT cch;
|
|
||||||
|
|
||||||
TRACE("(%p, %s, 0x%lX, %s)\n", hKL, debugstr_a(lpszReading), dwStyle,
|
TRACE("(%p, %s, 0x%lX, %s)\n", hKL, debugstr_a(lpszReading), dwStyle,
|
||||||
debugstr_a(lpszUnregister));
|
debugstr_a(lpszUnregister));
|
||||||
|
@ -4117,24 +4089,16 @@ BOOL WINAPI ImmUnregisterWordA(
|
||||||
|
|
||||||
if (lpszReading)
|
if (lpszReading)
|
||||||
{
|
{
|
||||||
cch = lstrlenA(lpszReading);
|
pszReadingW = Imm32WideFromAnsi(lpszReading);
|
||||||
pszReadingW = Imm32HeapAlloc(0, (cch + 1) * sizeof(WCHAR));
|
|
||||||
if (pszReadingW == NULL)
|
if (pszReadingW == NULL)
|
||||||
goto Quit;
|
goto Quit;
|
||||||
cch = MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, lpszReading, cch,
|
|
||||||
pszReadingW, cch + 1);
|
|
||||||
pszReadingW[cch] = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lpszUnregister)
|
if (lpszUnregister)
|
||||||
{
|
{
|
||||||
cch = lstrlenA(lpszUnregister);
|
pszUnregisterW = Imm32WideFromAnsi(lpszUnregister);
|
||||||
pszUnregisterW = Imm32HeapAlloc(0, (cch + 1) * sizeof(WCHAR));
|
|
||||||
if (pszUnregisterW == NULL)
|
if (pszUnregisterW == NULL)
|
||||||
goto Quit;
|
goto Quit;
|
||||||
cch = MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, lpszUnregister, cch,
|
|
||||||
pszUnregisterW, cch + 1);
|
|
||||||
pszUnregisterW[cch] = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = pImeDpi->ImeUnregisterWord(pszReadingW, dwStyle, pszUnregisterW);
|
ret = pImeDpi->ImeUnregisterWord(pszReadingW, dwStyle, pszUnregisterW);
|
||||||
|
@ -4157,7 +4121,6 @@ BOOL WINAPI ImmUnregisterWordW(
|
||||||
BOOL ret = FALSE;
|
BOOL ret = FALSE;
|
||||||
PIMEDPI pImeDpi;
|
PIMEDPI pImeDpi;
|
||||||
LPSTR pszReadingA = NULL, pszUnregisterA = NULL;
|
LPSTR pszReadingA = NULL, pszUnregisterA = NULL;
|
||||||
INT cchW, cchA;
|
|
||||||
|
|
||||||
TRACE("(%p, %s, 0x%lX, %s)\n", hKL, debugstr_w(lpszReading), dwStyle,
|
TRACE("(%p, %s, 0x%lX, %s)\n", hKL, debugstr_w(lpszReading), dwStyle,
|
||||||
debugstr_w(lpszUnregister));
|
debugstr_w(lpszUnregister));
|
||||||
|
@ -4175,24 +4138,16 @@ BOOL WINAPI ImmUnregisterWordW(
|
||||||
|
|
||||||
if (lpszReading)
|
if (lpszReading)
|
||||||
{
|
{
|
||||||
cchW = lstrlenW(lpszReading);
|
pszReadingA = Imm32AnsiFromWide(lpszReading);
|
||||||
cchA = (cchW + 1) * sizeof(WCHAR);
|
|
||||||
pszReadingA = Imm32HeapAlloc(0, cchA);
|
|
||||||
if (!pszReadingA)
|
if (!pszReadingA)
|
||||||
goto Quit;
|
goto Quit;
|
||||||
cchA = WideCharToMultiByte(CP_ACP, 0, lpszReading, cchW, pszReadingA, cchA, NULL, NULL);
|
|
||||||
pszReadingA[cchA] = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lpszUnregister)
|
if (lpszUnregister)
|
||||||
{
|
{
|
||||||
cchW = lstrlenW(lpszUnregister);
|
pszUnregisterA = Imm32AnsiFromWide(lpszUnregister);
|
||||||
cchA = (cchW + 1) * sizeof(WCHAR);
|
|
||||||
pszUnregisterA = Imm32HeapAlloc(0, cchA);
|
|
||||||
if (!pszUnregisterA)
|
if (!pszUnregisterA)
|
||||||
goto Quit;
|
goto Quit;
|
||||||
cchA = WideCharToMultiByte(CP_ACP, 0, lpszUnregister, cchW, pszUnregisterA, cchA, NULL, NULL);
|
|
||||||
pszUnregisterA[cchA] = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = pImeDpi->ImeUnregisterWord(pszReadingA, dwStyle, pszUnregisterA);
|
ret = pImeDpi->ImeUnregisterWord(pszReadingA, dwStyle, pszUnregisterA);
|
||||||
|
@ -4660,7 +4615,6 @@ BOOL WINAPI ImmEnumInputContext(DWORD dwThreadId, IMCENUMPROC lpfn, LPARAM lPara
|
||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
* ImmGetHotKey(IMM32.@)
|
* ImmGetHotKey(IMM32.@)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
BOOL WINAPI
|
BOOL WINAPI
|
||||||
ImmGetHotKey(IN DWORD dwHotKey,
|
ImmGetHotKey(IN DWORD dwHotKey,
|
||||||
OUT LPUINT lpuModifiers,
|
OUT LPUINT lpuModifiers,
|
||||||
|
@ -4727,15 +4681,14 @@ BOOL WINAPI CtfImmIsTextFrameServiceDisabled(VOID)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/***********************************************************************
|
|
||||||
* ImmGetImeInfoEx (IMM32.@)
|
|
||||||
*/
|
|
||||||
|
|
||||||
static BOOL APIENTRY Imm32GetImeInfoEx(PIMEINFOEX pImeInfoEx, IMEINFOEXCLASS SearchType)
|
static BOOL APIENTRY Imm32GetImeInfoEx(PIMEINFOEX pImeInfoEx, IMEINFOEXCLASS SearchType)
|
||||||
{
|
{
|
||||||
return NtUserGetImeInfoEx(pImeInfoEx, SearchType);
|
return NtUserGetImeInfoEx(pImeInfoEx, SearchType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
* ImmGetImeInfoEx (IMM32.@)
|
||||||
|
*/
|
||||||
BOOL WINAPI
|
BOOL WINAPI
|
||||||
ImmGetImeInfoEx(PIMEINFOEX pImeInfoEx,
|
ImmGetImeInfoEx(PIMEINFOEX pImeInfoEx,
|
||||||
IMEINFOEXCLASS SearchType,
|
IMEINFOEXCLASS SearchType,
|
||||||
|
|
Loading…
Reference in a new issue