Commit d980c084 authored by dewyatt's avatar dewyatt

Updated to fit SDL style a little more.

parent aa7b525b
...@@ -320,18 +320,15 @@ IME_Quit(SDL_VideoData *videodata) ...@@ -320,18 +320,15 @@ IME_Quit(SDL_VideoData *videodata)
videodata->ime_hwnd_main = 0; videodata->ime_hwnd_main = 0;
videodata->ime_himc = 0; videodata->ime_himc = 0;
if (videodata->ime_himm32) if (videodata->ime_himm32) {
{
FreeLibrary(videodata->ime_himm32); FreeLibrary(videodata->ime_himm32);
videodata->ime_himm32 = 0; videodata->ime_himm32 = 0;
} }
if (videodata->ime_threadmgr) if (videodata->ime_threadmgr) {
{
videodata->ime_threadmgr->lpVtbl->Release(videodata->ime_threadmgr); videodata->ime_threadmgr->lpVtbl->Release(videodata->ime_threadmgr);
videodata->ime_threadmgr = 0; videodata->ime_threadmgr = 0;
} }
if (videodata->ime_com_initialized) if (videodata->ime_com_initialized) {
{
CoUninitialize(); CoUninitialize();
videodata->ime_com_initialized = SDL_FALSE; videodata->ime_com_initialized = SDL_FALSE;
} }
...@@ -354,8 +351,7 @@ IME_GetReadingString(SDL_VideoData *videodata, HWND hwnd) ...@@ -354,8 +351,7 @@ IME_GetReadingString(SDL_VideoData *videodata, HWND hwnd)
return; return;
videodata->ime_readingstring[0] = 0; videodata->ime_readingstring[0] = 0;
if (!osversion.dwOSVersionInfoSize) if (!osversion.dwOSVersionInfoSize) {
{
osversion.dwOSVersionInfoSize = sizeof(osversion); osversion.dwOSVersionInfoSize = sizeof(osversion);
GetVersionExA(&osversion); GetVersionExA(&osversion);
} }
...@@ -367,11 +363,9 @@ IME_GetReadingString(SDL_VideoData *videodata, HWND hwnd) ...@@ -367,11 +363,9 @@ IME_GetReadingString(SDL_VideoData *videodata, HWND hwnd)
if (!himc) if (!himc)
return; return;
if (videodata->GetReadingString) if (videodata->GetReadingString) {
{
len = videodata->GetReadingString(himc, 0, 0, &err, &vertical, &maxuilen); len = videodata->GetReadingString(himc, 0, 0, &err, &vertical, &maxuilen);
if (len) if (len) {
{
if (len > SDL_arraysize(buffer)) if (len > SDL_arraysize(buffer))
len = SDL_arraysize(buffer); len = SDL_arraysize(buffer);
...@@ -379,8 +373,7 @@ IME_GetReadingString(SDL_VideoData *videodata, HWND hwnd) ...@@ -379,8 +373,7 @@ IME_GetReadingString(SDL_VideoData *videodata, HWND hwnd)
} }
SDL_wcslcpy(videodata->ime_readingstring, s, len); SDL_wcslcpy(videodata->ime_readingstring, s, len);
} }
else else {
{
LPINPUTCONTEXT2 lpimc = videodata->ImmLockIMC(himc); LPINPUTCONTEXT2 lpimc = videodata->ImmLockIMC(himc);
LPBYTE p = 0; LPBYTE p = 0;
s = 0; s = 0;
...@@ -434,9 +427,8 @@ IME_GetReadingString(SDL_VideoData *videodata, HWND hwnd) ...@@ -434,9 +427,8 @@ IME_GetReadingString(SDL_VideoData *videodata, HWND hwnd)
break; break;
} }
if (s) if (s)
{
SDL_wcslcpy(videodata->ime_readingstring, s, len + 1); SDL_wcslcpy(videodata->ime_readingstring, s, len + 1);
}
videodata->ImmUnlockIMCC(lpimc->hPrivate); videodata->ImmUnlockIMCC(lpimc->hPrivate);
videodata->ImmUnlockIMC(himc); videodata->ImmUnlockIMC(himc);
} }
...@@ -447,17 +439,15 @@ IME_GetReadingString(SDL_VideoData *videodata, HWND hwnd) ...@@ -447,17 +439,15 @@ IME_GetReadingString(SDL_VideoData *videodata, HWND hwnd)
static void static void
IME_InputLangChanged(SDL_VideoData *videodata) IME_InputLangChanged(SDL_VideoData *videodata)
{ {
UINT uLang = PRIMLANG(); UINT lang = PRIMLANG();
HWND hwndime = 0; HWND hwndime = 0;
IME_UpdateInputLocale(videodata); IME_UpdateInputLocale(videodata);
IME_SetupAPI(videodata); IME_SetupAPI(videodata);
if (uLang != PRIMLANG()) if (lang != PRIMLANG()) {
{
IME_ClearComposition(videodata); IME_ClearComposition(videodata);
} }
hwndime = ImmGetDefaultIMEWnd(videodata->ime_hwnd_current); hwndime = ImmGetDefaultIMEWnd(videodata->ime_hwnd_current);
if (hwndime) if (hwndime) {
{
SendMessageA(hwndime, WM_IME_CONTROL, IMC_OPENSTATUSWINDOW, 0); SendMessageA(hwndime, WM_IME_CONTROL, IMC_OPENSTATUSWINDOW, 0);
SendMessageA(hwndime, WM_IME_CONTROL, IMC_CLOSESTATUSWINDOW, 0); SendMessageA(hwndime, WM_IME_CONTROL, IMC_CLOSESTATUSWINDOW, 0);
} }
...@@ -485,8 +475,7 @@ IME_GetId(SDL_VideoData *videodata, UINT uIndex) ...@@ -485,8 +475,7 @@ IME_GetId(SDL_VideoData *videodata, UINT uIndex)
hklprev = hkl; hklprev = hkl;
dwLang = ((DWORD)hkl & 0xffff); dwLang = ((DWORD)hkl & 0xffff);
if (videodata->ime_uiless && LANG() == LANG_CHT) if (videodata->ime_uiless && LANG() == LANG_CHT) {
{
dwRet[0] = IMEID_CHT_VER_VISTA; dwRet[0] = IMEID_CHT_VER_VISTA;
dwRet[1] = 0; dwRet[1] = 0;
return dwRet[0]; return dwRet[0];
...@@ -495,40 +484,31 @@ IME_GetId(SDL_VideoData *videodata, UINT uIndex) ...@@ -495,40 +484,31 @@ IME_GetId(SDL_VideoData *videodata, UINT uIndex)
&& hkl != CHT_HKL_NEW_CHANG_JIE && hkl != CHT_HKL_NEW_CHANG_JIE
&& hkl != CHT_HKL_NEW_QUICK && hkl != CHT_HKL_NEW_QUICK
&& hkl != CHT_HKL_HK_CANTONESE && hkl != CHT_HKL_HK_CANTONESE
&& hkl != CHS_HKL) && hkl != CHS_HKL) {
{
dwRet[0] = dwRet[1] = 0; dwRet[0] = dwRet[1] = 0;
return dwRet[uIndex]; return dwRet[uIndex];
} }
if (ImmGetIMEFileNameA(hkl, szTemp, sizeof(szTemp) - 1) <= 0) if (ImmGetIMEFileNameA(hkl, szTemp, sizeof(szTemp) - 1) <= 0) {
{
dwRet[0] = dwRet[1] = 0; dwRet[0] = dwRet[1] = 0;
return dwRet[uIndex]; return dwRet[uIndex];
} }
if (!videodata->GetReadingString) if (!videodata->GetReadingString) {
{
#define LCID_INVARIANT MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), SORT_DEFAULT) #define LCID_INVARIANT MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), SORT_DEFAULT)
if (CompareStringA(LCID_INVARIANT, NORM_IGNORECASE, szTemp, -1, CHT_IMEFILENAME1, -1) != 2 if (CompareStringA(LCID_INVARIANT, NORM_IGNORECASE, szTemp, -1, CHT_IMEFILENAME1, -1) != 2
&& CompareStringA(LCID_INVARIANT, NORM_IGNORECASE, szTemp, -1, CHT_IMEFILENAME2, -1) != 2 && CompareStringA(LCID_INVARIANT, NORM_IGNORECASE, szTemp, -1, CHT_IMEFILENAME2, -1) != 2
&& CompareStringA(LCID_INVARIANT, NORM_IGNORECASE, szTemp, -1, CHT_IMEFILENAME3, -1) != 2 && CompareStringA(LCID_INVARIANT, NORM_IGNORECASE, szTemp, -1, CHT_IMEFILENAME3, -1) != 2
&& CompareStringA(LCID_INVARIANT, NORM_IGNORECASE, szTemp, -1, CHS_IMEFILENAME1, -1) != 2 && CompareStringA(LCID_INVARIANT, NORM_IGNORECASE, szTemp, -1, CHS_IMEFILENAME1, -1) != 2
&& CompareStringA(LCID_INVARIANT, NORM_IGNORECASE, szTemp, -1, CHS_IMEFILENAME2, -1) != 2 && CompareStringA(LCID_INVARIANT, NORM_IGNORECASE, szTemp, -1, CHS_IMEFILENAME2, -1) != 2) {
)
{
dwRet[0] = dwRet[1] = 0; dwRet[0] = dwRet[1] = 0;
return dwRet[uIndex]; return dwRet[uIndex];
} }
#undef LCID_INVARIANT #undef LCID_INVARIANT
dwVerSize = GetFileVersionInfoSizeA(szTemp, &dwVerHandle); dwVerSize = GetFileVersionInfoSizeA(szTemp, &dwVerHandle);
if (dwVerSize) if (dwVerSize) {
{
lpVerBuffer = SDL_malloc(dwVerSize); lpVerBuffer = SDL_malloc(dwVerSize);
if (lpVerBuffer) if (lpVerBuffer) {
{ if (GetFileVersionInfoA(szTemp, dwVerHandle, dwVerSize, lpVerBuffer)) {
if (GetFileVersionInfoA(szTemp, dwVerHandle, dwVerSize, lpVerBuffer)) if (VerQueryValueA(lpVerBuffer, "\\", &lpVerData, &cbVerData)) {
{
if (VerQueryValueA(lpVerBuffer, "\\", &lpVerData, &cbVerData))
{
#define pVerFixedInfo ((VS_FIXEDFILEINFO FAR*)lpVerData) #define pVerFixedInfo ((VS_FIXEDFILEINFO FAR*)lpVerData)
DWORD dwVer = pVerFixedInfo->dwFileVersionMS; DWORD dwVer = pVerFixedInfo->dwFileVersionMS;
dwVer = (dwVer & 0x00ff0000) << 8 | (dwVer & 0x000000ff) << 16; dwVer = (dwVer & 0x00ff0000) << 8 | (dwVer & 0x000000ff) << 16;
...@@ -545,9 +525,7 @@ IME_GetId(SDL_VideoData *videodata, UINT uIndex) ...@@ -545,9 +525,7 @@ IME_GetId(SDL_VideoData *videodata, UINT uIndex)
dwLang == LANG_CHS && ( dwLang == LANG_CHS && (
dwVer == MAKEIMEVERSION(4, 1) || dwVer == MAKEIMEVERSION(4, 1) ||
dwVer == MAKEIMEVERSION(4, 2) || dwVer == MAKEIMEVERSION(4, 2) ||
dwVer == MAKEIMEVERSION(5, 3)) dwVer == MAKEIMEVERSION(5, 3))) {
)
{
dwRet[0] = dwVer | dwLang; dwRet[0] = dwVer | dwLang;
dwRet[1] = pVerFixedInfo->dwFileVersionLS; dwRet[1] = pVerFixedInfo->dwFileVersionLS;
SDL_free(lpVerBuffer); SDL_free(lpVerBuffer);
...@@ -588,11 +566,9 @@ IME_SetupAPI(SDL_VideoData *videodata) ...@@ -588,11 +566,9 @@ IME_SetupAPI(SDL_VideoData *videodata)
videodata->ShowReadingWindow = (BOOL (WINAPI *)(HIMC, BOOL)) videodata->ShowReadingWindow = (BOOL (WINAPI *)(HIMC, BOOL))
GetProcAddress(hime, "ShowReadingWindow"); GetProcAddress(hime, "ShowReadingWindow");
if (videodata->ShowReadingWindow) if (videodata->ShowReadingWindow) {
{
HIMC himc = ImmGetContext(videodata->ime_hwnd_current); HIMC himc = ImmGetContext(videodata->ime_hwnd_current);
if (himc) if (himc) {
{
videodata->ShowReadingWindow(himc, FALSE); videodata->ShowReadingWindow(himc, FALSE);
ImmReleaseContext(videodata->ime_hwnd_current, himc); ImmReleaseContext(videodata->ime_hwnd_current, himc);
} }
...@@ -615,12 +591,12 @@ IME_SetWindow(SDL_VideoData* videodata, HWND hwnd) ...@@ -615,12 +591,12 @@ IME_SetWindow(SDL_VideoData* videodata, HWND hwnd)
static void static void
IME_UpdateInputLocale(SDL_VideoData *videodata) IME_UpdateInputLocale(SDL_VideoData *videodata)
{ {
static HKL hklPrevious = 0; static HKL hklprev = 0;
videodata->ime_hkl = GetKeyboardLayout(0); videodata->ime_hkl = GetKeyboardLayout(0);
if (hklPrevious == videodata->ime_hkl) if (hklprev == videodata->ime_hkl)
return; return;
hklPrevious = videodata->ime_hkl; hklprev = videodata->ime_hkl;
} }
static void static void
...@@ -652,21 +628,20 @@ IME_ClearEditing(SDL_VideoData *videodata) ...@@ -652,21 +628,20 @@ IME_ClearEditing(SDL_VideoData *videodata)
static void static void
IME_GetCompositionString(SDL_VideoData *videodata, HIMC himc, DWORD string) IME_GetCompositionString(SDL_VideoData *videodata, HIMC himc, DWORD string)
{ {
LONG Length = ImmGetCompositionStringW(himc, string, videodata->ime_composition, sizeof(videodata->ime_composition)); LONG length = ImmGetCompositionStringW(himc, string, videodata->ime_composition, sizeof(videodata->ime_composition));
if (Length < 0) if (length < 0)
Length = 0; length = 0;
Length /= sizeof(videodata->ime_composition[0]); length /= sizeof(videodata->ime_composition[0]);
videodata->ime_cursor = LOWORD(ImmGetCompositionStringW(himc, GCS_CURSORPOS, 0, 0)); videodata->ime_cursor = LOWORD(ImmGetCompositionStringW(himc, GCS_CURSORPOS, 0, 0));
if (videodata->ime_composition[videodata->ime_cursor] == 0x3000) if (videodata->ime_composition[videodata->ime_cursor] == 0x3000) {
{
int i; int i;
for (i = videodata->ime_cursor + 1; i < Length; ++i) for (i = videodata->ime_cursor + 1; i < length; ++i)
videodata->ime_composition[i - 1] = videodata->ime_composition[i]; videodata->ime_composition[i - 1] = videodata->ime_composition[i];
--Length; --length;
} }
videodata->ime_composition[Length] = 0; videodata->ime_composition[length] = 0;
} }
static void static void
...@@ -686,20 +661,18 @@ static void ...@@ -686,20 +661,18 @@ static void
IME_SendEditingEvent(SDL_VideoData *videodata) IME_SendEditingEvent(SDL_VideoData *videodata)
{ {
char *s = 0; char *s = 0;
WCHAR wBuffer[SDL_TEXTEDITINGEVENT_TEXT_SIZE]; WCHAR buffer[SDL_TEXTEDITINGEVENT_TEXT_SIZE];
wBuffer[0] = 0; buffer[0] = 0;
if (videodata->ime_readingstring[0]) if (videodata->ime_readingstring[0]) {
{
size_t len = SDL_min(SDL_wcslen(videodata->ime_composition), (size_t)videodata->ime_cursor); size_t len = SDL_min(SDL_wcslen(videodata->ime_composition), (size_t)videodata->ime_cursor);
SDL_wcslcpy(wBuffer, videodata->ime_composition, len + 1); SDL_wcslcpy(buffer, videodata->ime_composition, len + 1);
SDL_wcslcat(wBuffer, videodata->ime_readingstring, sizeof(wBuffer)); SDL_wcslcat(buffer, videodata->ime_readingstring, sizeof(buffer));
SDL_wcslcat(wBuffer, &videodata->ime_composition[len], sizeof(wBuffer) - len); SDL_wcslcat(buffer, &videodata->ime_composition[len], sizeof(buffer) - len);
} }
else else {
{ SDL_wcslcpy(buffer, videodata->ime_composition, sizeof(videodata->ime_composition));
SDL_wcslcpy(wBuffer, videodata->ime_composition, sizeof(videodata->ime_composition));
} }
s = WIN_StringToUTF8(wBuffer); s = WIN_StringToUTF8(buffer);
SDL_SendEditingText(s, videodata->ime_cursor + SDL_wcslen(videodata->ime_readingstring), 0); SDL_SendEditingText(s, videodata->ime_cursor + SDL_wcslen(videodata->ime_readingstring), 0);
SDL_free(s); SDL_free(s);
} }
...@@ -726,13 +699,11 @@ IME_HandleMessage(HWND hwnd, UINT msg, WPARAM wParam, LPARAM *lParam, SDL_VideoD ...@@ -726,13 +699,11 @@ IME_HandleMessage(HWND hwnd, UINT msg, WPARAM wParam, LPARAM *lParam, SDL_VideoD
case WM_IME_COMPOSITION: case WM_IME_COMPOSITION:
trap = SDL_TRUE; trap = SDL_TRUE;
himc = ImmGetContext(hwnd); himc = ImmGetContext(hwnd);
if (*lParam & GCS_RESULTSTR) if (*lParam & GCS_RESULTSTR) {
{
IME_GetCompositionString(videodata, himc, GCS_RESULTSTR); IME_GetCompositionString(videodata, himc, GCS_RESULTSTR);
IME_SendInputEvent(videodata); IME_SendInputEvent(videodata);
} }
if (*lParam & GCS_COMPSTR) if (*lParam & GCS_COMPSTR) {
{
if (!videodata->ime_uiless) if (!videodata->ime_uiless)
videodata->ime_readingstring[0] = 0; videodata->ime_readingstring[0] = 0;
...@@ -827,8 +798,7 @@ STDMETHODIMP UIElementSink_QueryInterface(TSFSink *sink, REFIID riid, PVOID *ppv ...@@ -827,8 +798,7 @@ STDMETHODIMP UIElementSink_QueryInterface(TSFSink *sink, REFIID riid, PVOID *ppv
else if (SDL_IsEqualIID(riid, &IID_ITfUIElementSink)) else if (SDL_IsEqualIID(riid, &IID_ITfUIElementSink))
*ppv = (ITfUIElementSink *)sink; *ppv = (ITfUIElementSink *)sink;
if (*ppv) if (*ppv) {
{
TSFSink_AddRef(sink); TSFSink_AddRef(sink);
return S_OK; return S_OK;
} }
...@@ -841,8 +811,7 @@ ITfUIElement *UILess_GetUIElement(SDL_VideoData *videodata, DWORD dwUIElementId) ...@@ -841,8 +811,7 @@ ITfUIElement *UILess_GetUIElement(SDL_VideoData *videodata, DWORD dwUIElementId)
ITfUIElement *pelem = 0; ITfUIElement *pelem = 0;
ITfThreadMgrEx *threadmgrex = videodata->ime_threadmgrex; ITfThreadMgrEx *threadmgrex = videodata->ime_threadmgrex;
if (SUCCEEDED(threadmgrex->lpVtbl->QueryInterface(threadmgrex, &IID_ITfUIElementMgr, (LPVOID *)&puiem))) if (SUCCEEDED(threadmgrex->lpVtbl->QueryInterface(threadmgrex, &IID_ITfUIElementMgr, (LPVOID *)&puiem))) {
{
puiem->lpVtbl->GetUIElement(puiem, dwUIElementId, &pelem); puiem->lpVtbl->GetUIElement(puiem, dwUIElementId, &pelem);
puiem->lpVtbl->Release(puiem); puiem->lpVtbl->Release(puiem);
} }
...@@ -851,45 +820,35 @@ ITfUIElement *UILess_GetUIElement(SDL_VideoData *videodata, DWORD dwUIElementId) ...@@ -851,45 +820,35 @@ ITfUIElement *UILess_GetUIElement(SDL_VideoData *videodata, DWORD dwUIElementId)
STDMETHODIMP UIElementSink_BeginUIElement(TSFSink *sink, DWORD dwUIElementId, BOOL *pbShow) STDMETHODIMP UIElementSink_BeginUIElement(TSFSink *sink, DWORD dwUIElementId, BOOL *pbShow)
{ {
ITfUIElement *pElement = UILess_GetUIElement((SDL_VideoData *)sink->data, dwUIElementId); ITfUIElement *element = UILess_GetUIElement((SDL_VideoData *)sink->data, dwUIElementId);
ITfReadingInformationUIElement *preading = 0; ITfReadingInformationUIElement *preading = 0;
ITfCandidateListUIElement *pcandidates = 0;
SDL_VideoData *videodata = (SDL_VideoData *)sink->data; SDL_VideoData *videodata = (SDL_VideoData *)sink->data;
if (!pElement) if (!element)
return E_INVALIDARG; return E_INVALIDARG;
*pbShow = FALSE; *pbShow = FALSE;
if (SUCCEEDED(pElement->lpVtbl->QueryInterface(pElement, &IID_ITfReadingInformationUIElement, (LPVOID *)&preading))) if (SUCCEEDED(element->lpVtbl->QueryInterface(element, &IID_ITfReadingInformationUIElement, (LPVOID *)&preading))) {
{
BSTR bstr; BSTR bstr;
if (SUCCEEDED(preading->lpVtbl->GetString(preading, &bstr)) && bstr) if (SUCCEEDED(preading->lpVtbl->GetString(preading, &bstr)) && bstr) {
{
WCHAR *s = (WCHAR *)bstr; WCHAR *s = (WCHAR *)bstr;
SysFreeString(bstr); SysFreeString(bstr);
} }
preading->lpVtbl->Release(preading); preading->lpVtbl->Release(preading);
} }
else if (SUCCEEDED(pElement->lpVtbl->QueryInterface(pElement, &IID_ITfCandidateListUIElement, (PVOID *)&pcandidates)))
{
pcandidates->lpVtbl->Release(pcandidates);
}
return S_OK; return S_OK;
} }
STDMETHODIMP UIElementSink_UpdateUIElement(TSFSink *sink, DWORD dwUIElementId) STDMETHODIMP UIElementSink_UpdateUIElement(TSFSink *sink, DWORD dwUIElementId)
{ {
ITfUIElement *pElement = UILess_GetUIElement((SDL_VideoData *)sink->data, dwUIElementId); ITfUIElement *element = UILess_GetUIElement((SDL_VideoData *)sink->data, dwUIElementId);
ITfReadingInformationUIElement *preading = 0; ITfReadingInformationUIElement *preading = 0;
ITfCandidateListUIElement *pcandidates = 0;
SDL_VideoData *videodata = (SDL_VideoData *)sink->data; SDL_VideoData *videodata = (SDL_VideoData *)sink->data;
if (!pElement) if (!element)
return E_INVALIDARG; return E_INVALIDARG;
if (SUCCEEDED(pElement->lpVtbl->QueryInterface(pElement, &IID_ITfReadingInformationUIElement, (LPVOID *)&preading))) if (SUCCEEDED(element->lpVtbl->QueryInterface(element, &IID_ITfReadingInformationUIElement, (LPVOID *)&preading))) {
{
BSTR bstr; BSTR bstr;
if (SUCCEEDED(preading->lpVtbl->GetString(preading, &bstr)) && bstr) if (SUCCEEDED(preading->lpVtbl->GetString(preading, &bstr)) && bstr) {
{
WCHAR *s = (WCHAR *)bstr; WCHAR *s = (WCHAR *)bstr;
SDL_wcslcpy(videodata->ime_readingstring, s, sizeof(videodata->ime_readingstring)); SDL_wcslcpy(videodata->ime_readingstring, s, sizeof(videodata->ime_readingstring));
IME_SendEditingEvent(videodata); IME_SendEditingEvent(videodata);
...@@ -897,32 +856,22 @@ STDMETHODIMP UIElementSink_UpdateUIElement(TSFSink *sink, DWORD dwUIElementId) ...@@ -897,32 +856,22 @@ STDMETHODIMP UIElementSink_UpdateUIElement(TSFSink *sink, DWORD dwUIElementId)
} }
preading->lpVtbl->Release(preading); preading->lpVtbl->Release(preading);
} }
else if (SUCCEEDED(pElement->lpVtbl->QueryInterface(pElement, &IID_ITfCandidateListUIElement, (PVOID *)&pcandidates)))
{
pcandidates->lpVtbl->Release(pcandidates);
}
return S_OK; return S_OK;
} }
STDMETHODIMP UIElementSink_EndUIElement(TSFSink *sink, DWORD dwUIElementId) STDMETHODIMP UIElementSink_EndUIElement(TSFSink *sink, DWORD dwUIElementId)
{ {
ITfUIElement *pElement = UILess_GetUIElement((SDL_VideoData *)sink->data, dwUIElementId); ITfUIElement *element = UILess_GetUIElement((SDL_VideoData *)sink->data, dwUIElementId);
ITfReadingInformationUIElement *preading = 0; ITfReadingInformationUIElement *preading = 0;
ITfCandidateListUIElement *pcandidates = 0;
SDL_VideoData *videodata = (SDL_VideoData *)sink->data; SDL_VideoData *videodata = (SDL_VideoData *)sink->data;
if (!pElement) if (!element)
return E_INVALIDARG; return E_INVALIDARG;
if (SUCCEEDED(pElement->lpVtbl->QueryInterface(pElement, &IID_ITfReadingInformationUIElement, (LPVOID *)&preading))) if (SUCCEEDED(element->lpVtbl->QueryInterface(element, &IID_ITfReadingInformationUIElement, (LPVOID *)&preading))) {
{
videodata->ime_readingstring[0] = 0; videodata->ime_readingstring[0] = 0;
IME_SendEditingEvent(videodata); IME_SendEditingEvent(videodata);
preading->lpVtbl->Release(preading); preading->lpVtbl->Release(preading);
} }
else if (SUCCEEDED(pElement->lpVtbl->QueryInterface(pElement, &IID_ITfCandidateListUIElement, (PVOID *)&pcandidates)))
{
pcandidates->lpVtbl->Release(pcandidates);
}
return S_OK; return S_OK;
} }
...@@ -937,8 +886,7 @@ STDMETHODIMP IPPASink_QueryInterface(TSFSink *sink, REFIID riid, PVOID *ppv) ...@@ -937,8 +886,7 @@ STDMETHODIMP IPPASink_QueryInterface(TSFSink *sink, REFIID riid, PVOID *ppv)
else if (SDL_IsEqualIID(riid, &IID_ITfInputProcessorProfileActivationSink)) else if (SDL_IsEqualIID(riid, &IID_ITfInputProcessorProfileActivationSink))
*ppv = (ITfInputProcessorProfileActivationSink *)sink; *ppv = (ITfInputProcessorProfileActivationSink *)sink;
if (*ppv) if (*ppv) {
{
TSFSink_AddRef(sink); TSFSink_AddRef(sink);
return S_OK; return S_OK;
} }
...@@ -976,8 +924,7 @@ UILess_EnableUIUpdates(SDL_VideoData *videodata) ...@@ -976,8 +924,7 @@ UILess_EnableUIUpdates(SDL_VideoData *videodata)
if (!videodata->ime_threadmgrex || videodata->ime_uielemsinkcookie != TF_INVALID_COOKIE) if (!videodata->ime_threadmgrex || videodata->ime_uielemsinkcookie != TF_INVALID_COOKIE)
return; return;
if (SUCCEEDED(videodata->ime_threadmgrex->lpVtbl->QueryInterface(videodata->ime_threadmgrex, &IID_ITfSource, (LPVOID *)&source))) if (SUCCEEDED(videodata->ime_threadmgrex->lpVtbl->QueryInterface(videodata->ime_threadmgrex, &IID_ITfSource, (LPVOID *)&source))) {
{
source->lpVtbl->AdviseSink(source, &IID_ITfUIElementSink, (IUnknown *)videodata->ime_uielemsink, &videodata->ime_uielemsinkcookie); source->lpVtbl->AdviseSink(source, &IID_ITfUIElementSink, (IUnknown *)videodata->ime_uielemsink, &videodata->ime_uielemsinkcookie);
source->lpVtbl->Release(source); source->lpVtbl->Release(source);
} }
...@@ -990,8 +937,7 @@ UILess_DisableUIUpdates(SDL_VideoData *videodata) ...@@ -990,8 +937,7 @@ UILess_DisableUIUpdates(SDL_VideoData *videodata)
if (!videodata->ime_threadmgrex || videodata->ime_uielemsinkcookie == TF_INVALID_COOKIE) if (!videodata->ime_threadmgrex || videodata->ime_uielemsinkcookie == TF_INVALID_COOKIE)
return; return;
if (SUCCEEDED(videodata->ime_threadmgrex->lpVtbl->QueryInterface(videodata->ime_threadmgrex, &IID_ITfSource, (LPVOID *)&source))) if (SUCCEEDED(videodata->ime_threadmgrex->lpVtbl->QueryInterface(videodata->ime_threadmgrex, &IID_ITfSource, (LPVOID *)&source))) {
{
source->lpVtbl->UnadviseSink(source, videodata->ime_uielemsinkcookie); source->lpVtbl->UnadviseSink(source, videodata->ime_uielemsinkcookie);
videodata->ime_uielemsinkcookie = TF_INVALID_COOKIE; videodata->ime_uielemsinkcookie = TF_INVALID_COOKIE;
source->lpVtbl->Release(source); source->lpVtbl->Release(source);
...@@ -1021,12 +967,9 @@ UILess_SetupSinks(SDL_VideoData *videodata) ...@@ -1021,12 +967,9 @@ UILess_SetupSinks(SDL_VideoData *videodata)
videodata->ime_ippasink->refcount = 1; videodata->ime_ippasink->refcount = 1;
videodata->ime_ippasink->data = videodata; videodata->ime_ippasink->data = videodata;
if (SUCCEEDED(videodata->ime_threadmgrex->lpVtbl->QueryInterface(videodata->ime_threadmgrex, &IID_ITfSource, (LPVOID *)&source))) if (SUCCEEDED(videodata->ime_threadmgrex->lpVtbl->QueryInterface(videodata->ime_threadmgrex, &IID_ITfSource, (LPVOID *)&source))) {
{ if (SUCCEEDED(source->lpVtbl->AdviseSink(source, &IID_ITfUIElementSink, (IUnknown *)videodata->ime_uielemsink, &videodata->ime_uielemsinkcookie))) {
if (SUCCEEDED(source->lpVtbl->AdviseSink(source, &IID_ITfUIElementSink, (IUnknown *)videodata->ime_uielemsink, &videodata->ime_uielemsinkcookie))) if (SUCCEEDED(source->lpVtbl->AdviseSink(source, &IID_ITfInputProcessorProfileActivationSink, (IUnknown *)videodata->ime_ippasink, &videodata->ime_alpnsinkcookie))) {
{
if (SUCCEEDED(source->lpVtbl->AdviseSink(source, &IID_ITfInputProcessorProfileActivationSink, (IUnknown *)videodata->ime_ippasink, &videodata->ime_alpnsinkcookie)))
{
result = SDL_TRUE; result = SDL_TRUE;
} }
} }
...@@ -1046,12 +989,11 @@ UILess_SetupSinks(SDL_VideoData *videodata) ...@@ -1046,12 +989,11 @@ UILess_SetupSinks(SDL_VideoData *videodata)
static void static void
UILess_ReleaseSinks(SDL_VideoData *videodata) UILess_ReleaseSinks(SDL_VideoData *videodata)
{ {
ITfSource *Source = 0; ITfSource *source = 0;
if (videodata->ime_threadmgrex && SUCCEEDED(videodata->ime_threadmgrex->lpVtbl->QueryInterface(videodata->ime_threadmgrex, &IID_ITfSource, &Source))) if (videodata->ime_threadmgrex && SUCCEEDED(videodata->ime_threadmgrex->lpVtbl->QueryInterface(videodata->ime_threadmgrex, &IID_ITfSource, &source))) {
{ source->lpVtbl->UnadviseSink(source, videodata->ime_uielemsinkcookie);
Source->lpVtbl->UnadviseSink(Source, videodata->ime_uielemsinkcookie); source->lpVtbl->UnadviseSink(source, videodata->ime_alpnsinkcookie);
Source->lpVtbl->UnadviseSink(Source, videodata->ime_alpnsinkcookie); SAFE_RELEASE(source);
SAFE_RELEASE(Source);
videodata->ime_threadmgrex->lpVtbl->Deactivate(videodata->ime_threadmgrex); videodata->ime_threadmgrex->lpVtbl->Deactivate(videodata->ime_threadmgrex);
SAFE_RELEASE(videodata->ime_threadmgrex); SAFE_RELEASE(videodata->ime_threadmgrex);
TSFSink_Release(videodata->ime_uielemsink); TSFSink_Release(videodata->ime_uielemsink);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment