mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 18:15:11 +00:00
[IMM32] Move ImmFreeLayout from ime.c to imm.c
CORE-11700
This commit is contained in:
parent
33affbfecb
commit
e6a51b54c4
3 changed files with 68 additions and 67 deletions
|
@ -1677,70 +1677,3 @@ ImmGetImeMenuItemsW(HIMC hIMC, DWORD dwFlags, DWORD dwType,
|
|||
return Imm32GetImeMenuItemsAW(hIMC, dwFlags, dwType, lpImeParentMenu, lpImeMenu,
|
||||
dwSize, FALSE);
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
* ImmFreeLayout (IMM32.@)
|
||||
*/
|
||||
BOOL WINAPI ImmFreeLayout(DWORD dwUnknown)
|
||||
{
|
||||
WCHAR szKBD[9];
|
||||
UINT iKL, cKLs;
|
||||
HKL hOldKL, hNewKL, *pList;
|
||||
PIMEDPI pImeDpi;
|
||||
LANGID LangID;
|
||||
|
||||
TRACE("(0x%lX)\n", dwUnknown);
|
||||
|
||||
hOldKL = GetKeyboardLayout(0);
|
||||
|
||||
if (dwUnknown == 1)
|
||||
{
|
||||
if (!IS_IME_HKL(hOldKL))
|
||||
return TRUE;
|
||||
|
||||
LangID = LANGIDFROMLCID(GetSystemDefaultLCID());
|
||||
|
||||
cKLs = GetKeyboardLayoutList(0, NULL);
|
||||
if (cKLs)
|
||||
{
|
||||
pList = Imm32HeapAlloc(0, cKLs * sizeof(HKL));
|
||||
if (pList == NULL)
|
||||
return FALSE;
|
||||
|
||||
cKLs = GetKeyboardLayoutList(cKLs, pList);
|
||||
for (iKL = 0; iKL < cKLs; ++iKL)
|
||||
{
|
||||
if (!IS_IME_HKL(pList[iKL]))
|
||||
{
|
||||
LangID = LOWORD(pList[iKL]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Imm32HeapFree(pList);
|
||||
}
|
||||
|
||||
StringCchPrintfW(szKBD, _countof(szKBD), L"%08X", LangID);
|
||||
if (!LoadKeyboardLayoutW(szKBD, KLF_ACTIVATE))
|
||||
LoadKeyboardLayoutW(L"00000409", KLF_ACTIVATE | 0x200);
|
||||
}
|
||||
else if (dwUnknown == 2)
|
||||
{
|
||||
RtlEnterCriticalSection(&g_csImeDpi);
|
||||
Retry:
|
||||
for (pImeDpi = g_pImeDpiList; pImeDpi; pImeDpi = pImeDpi->pNext)
|
||||
{
|
||||
if (Imm32ReleaseIME(pImeDpi->hKL))
|
||||
goto Retry;
|
||||
}
|
||||
RtlLeaveCriticalSection(&g_csImeDpi);
|
||||
}
|
||||
else
|
||||
{
|
||||
hNewKL = (HKL)(DWORD_PTR)dwUnknown;
|
||||
if (IS_IME_HKL(hNewKL) && hNewKL != hOldKL)
|
||||
Imm32ReleaseIME(hNewKL);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
@ -101,6 +101,73 @@ HKL WINAPI ImmLoadLayout(HKL hKL, PIMEINFOEX pImeInfoEx)
|
|||
return hKL;
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
* ImmFreeLayout (IMM32.@)
|
||||
*/
|
||||
BOOL WINAPI ImmFreeLayout(DWORD dwUnknown)
|
||||
{
|
||||
WCHAR szKBD[9];
|
||||
UINT iKL, cKLs;
|
||||
HKL hOldKL, hNewKL, *pList;
|
||||
PIMEDPI pImeDpi;
|
||||
LANGID LangID;
|
||||
|
||||
TRACE("(0x%lX)\n", dwUnknown);
|
||||
|
||||
hOldKL = GetKeyboardLayout(0);
|
||||
|
||||
if (dwUnknown == 1)
|
||||
{
|
||||
if (!IS_IME_HKL(hOldKL))
|
||||
return TRUE;
|
||||
|
||||
LangID = LANGIDFROMLCID(GetSystemDefaultLCID());
|
||||
|
||||
cKLs = GetKeyboardLayoutList(0, NULL);
|
||||
if (cKLs)
|
||||
{
|
||||
pList = Imm32HeapAlloc(0, cKLs * sizeof(HKL));
|
||||
if (pList == NULL)
|
||||
return FALSE;
|
||||
|
||||
cKLs = GetKeyboardLayoutList(cKLs, pList);
|
||||
for (iKL = 0; iKL < cKLs; ++iKL)
|
||||
{
|
||||
if (!IS_IME_HKL(pList[iKL]))
|
||||
{
|
||||
LangID = LOWORD(pList[iKL]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Imm32HeapFree(pList);
|
||||
}
|
||||
|
||||
StringCchPrintfW(szKBD, _countof(szKBD), L"%08X", LangID);
|
||||
if (!LoadKeyboardLayoutW(szKBD, KLF_ACTIVATE))
|
||||
LoadKeyboardLayoutW(L"00000409", KLF_ACTIVATE | 0x200);
|
||||
}
|
||||
else if (dwUnknown == 2)
|
||||
{
|
||||
RtlEnterCriticalSection(&g_csImeDpi);
|
||||
Retry:
|
||||
for (pImeDpi = g_pImeDpiList; pImeDpi; pImeDpi = pImeDpi->pNext)
|
||||
{
|
||||
if (Imm32ReleaseIME(pImeDpi->hKL))
|
||||
goto Retry;
|
||||
}
|
||||
RtlLeaveCriticalSection(&g_csImeDpi);
|
||||
}
|
||||
else
|
||||
{
|
||||
hNewKL = (HKL)(DWORD_PTR)dwUnknown;
|
||||
if (IS_IME_HKL(hNewKL) && hNewKL != hOldKL)
|
||||
Imm32ReleaseIME(hNewKL);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
typedef struct _tagImmHkl
|
||||
{
|
||||
struct list entry;
|
||||
|
|
|
@ -81,6 +81,7 @@ LPVOID APIENTRY Imm32HeapAlloc(DWORD dwFlags, DWORD dwBytes);
|
|||
LPWSTR APIENTRY Imm32WideFromAnsi(LPCSTR pszA);
|
||||
LPSTR APIENTRY Imm32AnsiFromWide(LPCWSTR pszW);
|
||||
PIMEDPI APIENTRY ImmLockOrLoadImeDpi(HKL hKL);
|
||||
BOOL APIENTRY Imm32ReleaseIME(HKL hKL);
|
||||
|
||||
static inline BOOL Imm32IsCrossThreadAccess(HIMC hIMC)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue