Commit 4adfb1be authored by Akihiro Sagawa's avatar Akihiro Sagawa Committed by Alexandre Julliard

user32: Send WM_IME_CHAR messages from DefWindowProc.

parent 4f14f706
......@@ -385,7 +385,7 @@ static LRESULT WINAPI test_ime_wnd_proc(HWND hWnd, UINT msg, WPARAM wParam, LPAR
ime_composition_test.catch_ime_char = FALSE;
SendMessageA(hwndIme, msg, wParam, lParam);
todo_wine ok(!ime_composition_test.catch_ime_char, "WM_IME_CHAR is sent\n");
ok(!ime_composition_test.catch_ime_char, "WM_IME_CHAR is sent\n");
imc = ImmGetContext(hWnd);
size = ImmGetCompositionStringW(imc, GCS_RESULTSTR,
......@@ -513,12 +513,6 @@ static void test_ImmGetCompositionString(void)
SetFocus(hwndChild);
/* FIXME: In wine, IME UI window is created in ImmSetOpenStatus().
So, we prepare it here to generate WM_IME_CHAR messages. */
imc = ImmGetContext(hwndChild);
ImmSetOpenStatus(imc, FALSE);
ImmReleaseContext(hwndChild, imc);
ime_composition_test.timer_id = MY_TIMER;
ime_composition_test.start = GetTickCount();
SetTimer(hwndChild, ime_composition_test.timer_id, 100, NULL);
......
......@@ -854,8 +854,44 @@ LRESULT WINAPI DefWindowProcA( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam
result = PostMessageA( hwnd, WM_KEYUP, wParam, lParam );
break;
case WM_IME_STARTCOMPOSITION:
case WM_IME_COMPOSITION:
if (lParam & GCS_RESULTSTR)
{
LONG size, i;
unsigned char lead = 0;
char *buf = NULL;
HIMC himc = ImmGetContext( hwnd );
if (himc)
{
if ((size = ImmGetCompositionStringA( himc, GCS_RESULTSTR, NULL, 0 )))
{
if (!(buf = HeapAlloc( GetProcessHeap(), 0, size ))) size = 0;
else size = ImmGetCompositionStringA( himc, GCS_RESULTSTR, buf, size );
}
ImmReleaseContext( hwnd, himc );
for (i = 0; i < size; i++)
{
unsigned char c = buf[i];
if (!lead)
{
if (IsDBCSLeadByte( c ))
lead = c;
else
SendMessageA( hwnd, WM_IME_CHAR, c, 1 );
}
else
{
SendMessageA( hwnd, WM_IME_CHAR, MAKEWORD(c, lead), 1 );
lead = 0;
}
}
HeapFree( GetProcessHeap(), 0, buf );
}
}
/* fall through */
case WM_IME_STARTCOMPOSITION:
case WM_IME_ENDCOMPOSITION:
case WM_IME_SELECT:
case WM_IME_NOTIFY:
......@@ -1006,8 +1042,29 @@ LRESULT WINAPI DefWindowProcW(
}
break;
case WM_IME_STARTCOMPOSITION:
case WM_IME_COMPOSITION:
if (lParam & GCS_RESULTSTR)
{
LONG size, i;
WCHAR *buf = NULL;
HIMC himc = ImmGetContext( hwnd );
if (himc)
{
if ((size = ImmGetCompositionStringW( himc, GCS_RESULTSTR, NULL, 0 )))
{
if (!(buf = HeapAlloc( GetProcessHeap(), 0, size * sizeof(WCHAR) ))) size = 0;
else size = ImmGetCompositionStringW( himc, GCS_RESULTSTR, buf, size * sizeof(WCHAR) );
}
ImmReleaseContext( hwnd, himc );
for (i = 0; i < size / sizeof(WCHAR); i++)
SendMessageW( hwnd, WM_IME_CHAR, buf[i], 1 );
HeapFree( GetProcessHeap(), 0, buf );
}
}
/* fall through */
case WM_IME_STARTCOMPOSITION:
case WM_IME_ENDCOMPOSITION:
case WM_IME_SELECT:
case WM_IME_NOTIFY:
......
......@@ -459,43 +459,6 @@ static void GenerateIMEMessage(HIMC hIMC, UINT msg, WPARAM wParam, LPARAM lParam
UnlockRealIMC(hIMC);
}
static void GenerateIMECHARMessages(HIMC hIMC, LPWSTR String, DWORD length)
{
LPINPUTCONTEXT lpIMC;
LPTRANSMSG lpTransMsg;
DWORD i;
if (length <= 0)
return;
lpIMC = LockRealIMC(hIMC);
if (lpIMC == NULL)
return;
lpIMC->hMsgBuf = ImmReSizeIMCC(lpIMC->hMsgBuf, (lpIMC->dwNumMsgBuf + length) * sizeof(TRANSMSG));
if (!lpIMC->hMsgBuf)
return;
lpTransMsg = ImmLockIMCC(lpIMC->hMsgBuf);
if (!lpTransMsg)
return;
lpTransMsg += lpIMC->dwNumMsgBuf;
for (i = 0; i < length; i++)
{
lpTransMsg->message = WM_IME_CHAR;
lpTransMsg->wParam = String[i];
lpTransMsg->lParam = 1;
lpTransMsg++;
}
ImmUnlockIMCC(lpIMC->hMsgBuf);
lpIMC->dwNumMsgBuf += length;
ImmGenerateMessage(RealIMC(hIMC));
UnlockRealIMC(hIMC);
}
static BOOL GenerateMessageToTransKey(LPDWORD lpTransBuf, UINT *uNumTranMsgs,
UINT msg, WPARAM wParam, LPARAM lParam)
{
......@@ -1166,26 +1129,7 @@ static void PaintDefaultIMEWnd(HIMC hIMC, HWND hwnd)
static void DefaultIMEComposition(HIMC hIMC, HWND hwnd, LPARAM lParam)
{
TRACE("IME message WM_IME_COMPOSITION 0x%lx\n", lParam);
if (lParam & GCS_RESULTSTR)
{
LPCOMPOSITIONSTRING compstr;
LPBYTE compdata;
LPWSTR ResultStr;
LPINPUTCONTEXT lpIMC;
lpIMC = LockRealIMC(hIMC);
if (lpIMC == NULL)
return;
TRACE("Posting result as IME_CHAR\n");
compdata = ImmLockIMCC(lpIMC->hCompStr);
compstr = (LPCOMPOSITIONSTRING)compdata;
ResultStr = (LPWSTR)(compdata + compstr->dwResultStrOffset);
GenerateIMECHARMessages(hIMC, ResultStr, compstr->dwResultStrLen);
ImmUnlockIMCC(lpIMC->hCompStr);
UnlockRealIMC(hIMC);
}
else
if (!(lParam & GCS_RESULTSTR))
UpdateDataInDefaultIMEWindow(hIMC, hwnd, TRUE);
}
......
......@@ -496,45 +496,6 @@ static void GenerateIMEMessage(HIMC hIMC, UINT msg, WPARAM wParam,
UnlockRealIMC(hIMC);
}
static void GenerateIMECHARMessages(HIMC hIMC, LPWSTR String, DWORD length)
{
LPINPUTCONTEXT lpIMC;
LPTRANSMSG lpTransMsg;
DWORD i;
if (length <= 0)
return;
lpIMC = LockRealIMC(hIMC);
if (lpIMC == NULL)
return;
lpIMC->hMsgBuf = ImmReSizeIMCC(lpIMC->hMsgBuf,
(lpIMC->dwNumMsgBuf + length) *
sizeof(TRANSMSG));
if (!lpIMC->hMsgBuf)
return;
lpTransMsg = ImmLockIMCC(lpIMC->hMsgBuf);
if (!lpTransMsg)
return;
lpTransMsg += lpIMC->dwNumMsgBuf;
for (i = 0; i < length; i++)
{
lpTransMsg->message = WM_IME_CHAR;
lpTransMsg->wParam = String[i];
lpTransMsg->lParam = 1;
lpTransMsg ++;
}
ImmUnlockIMCC(lpIMC->hMsgBuf);
lpIMC->dwNumMsgBuf+=length;
ImmGenerateMessage(RealIMC(hIMC));
UnlockRealIMC(hIMC);
}
static BOOL IME_RemoveFromSelected(HIMC hIMC)
{
int i;
......@@ -1256,26 +1217,7 @@ static void UpdateDefaultIMEWindow(HIMC hIMC, HWND hwnd)
static void DefaultIMEComposition(HIMC hIMC, HWND hwnd, LPARAM lParam)
{
TRACE("IME message WM_IME_COMPOSITION 0x%lx\n", lParam);
if (lParam & GCS_RESULTSTR)
{
LPCOMPOSITIONSTRING compstr;
LPBYTE compdata;
LPWSTR ResultStr;
LPINPUTCONTEXT lpIMC;
lpIMC = LockRealIMC(hIMC);
if (lpIMC == NULL)
return;
TRACE("Posting result as IME_CHAR\n");
compdata = ImmLockIMCC(lpIMC->hCompStr);
compstr = (LPCOMPOSITIONSTRING)compdata;
ResultStr = (LPWSTR)(compdata + compstr->dwResultStrOffset);
GenerateIMECHARMessages(hIMC, ResultStr, compstr->dwResultStrLen);
ImmUnlockIMCC(lpIMC->hCompStr);
UnlockRealIMC(hIMC);
}
else
if (!(lParam & GCS_RESULTSTR))
UpdateDefaultIMEWindow(hIMC, hwnd);
}
......
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