[IMM32] Move ImmFreeLayout from ime.c to imm.c

CORE-11700
This commit is contained in:
Katayama Hirofumi MZ 2021-10-01 03:10:26 +09:00
parent 33affbfecb
commit e6a51b54c4
3 changed files with 68 additions and 67 deletions

View file

@ -1677,70 +1677,3 @@ ImmGetImeMenuItemsW(HIMC hIMC, DWORD dwFlags, DWORD dwType,
return Imm32GetImeMenuItemsAW(hIMC, dwFlags, dwType, lpImeParentMenu, lpImeMenu, return Imm32GetImeMenuItemsAW(hIMC, dwFlags, dwType, lpImeParentMenu, lpImeMenu,
dwSize, FALSE); 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;
}

View file

@ -101,6 +101,73 @@ HKL WINAPI ImmLoadLayout(HKL hKL, PIMEINFOEX pImeInfoEx)
return hKL; 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 typedef struct _tagImmHkl
{ {
struct list entry; struct list entry;

View file

@ -81,6 +81,7 @@ LPVOID APIENTRY Imm32HeapAlloc(DWORD dwFlags, DWORD dwBytes);
LPWSTR APIENTRY Imm32WideFromAnsi(LPCSTR pszA); LPWSTR APIENTRY Imm32WideFromAnsi(LPCSTR pszA);
LPSTR APIENTRY Imm32AnsiFromWide(LPCWSTR pszW); LPSTR APIENTRY Imm32AnsiFromWide(LPCWSTR pszW);
PIMEDPI APIENTRY ImmLockOrLoadImeDpi(HKL hKL); PIMEDPI APIENTRY ImmLockOrLoadImeDpi(HKL hKL);
BOOL APIENTRY Imm32ReleaseIME(HKL hKL);
static inline BOOL Imm32IsCrossThreadAccess(HIMC hIMC) static inline BOOL Imm32IsCrossThreadAccess(HIMC hIMC)
{ {