Commit 45b096ab authored by Rémi Bernon's avatar Rémi Bernon Committed by Alexandre Julliard

user32: Move WM_IME_COMPOSITION DefWindowProc handlers in separate helpers.

parent 93e5d7b3
......@@ -25,6 +25,59 @@
WINE_DEFAULT_DEBUG_CHANNEL(win);
static void default_ime_compositionW( HWND hwnd, WPARAM wparam, LPARAM lparam )
{
WCHAR *buf = NULL;
LONG size, i;
HIMC himc;
if (!(lparam & GCS_RESULTSTR) || !(himc = ImmGetContext( hwnd ))) return;
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 );
}
static void default_ime_compositionA( HWND hwnd, WPARAM wparam, LPARAM lparam )
{
unsigned char lead = 0;
char *buf = NULL;
LONG size, i;
HIMC himc;
if (!(lparam & GCS_RESULTSTR) || !(himc = ImmGetContext( hwnd ))) return;
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 );
}
/***********************************************************************
* DefWindowProcA (USER32.@)
......@@ -66,41 +119,7 @@ LRESULT WINAPI DefWindowProcA( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam
break;
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 );
}
}
default_ime_compositionA( hwnd, wParam, lParam );
/* fall through */
default:
......@@ -159,26 +178,7 @@ LRESULT WINAPI DefWindowProcW(
break;
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 );
}
}
default_ime_compositionW( hwnd, wParam, lParam );
/* fall through */
default:
......
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