imm32: Test and fix ImmIsUIMessageA/W.

This commit is contained in:
André Hentschel 2011-06-25 16:13:41 +02:00 committed by Alexandre Julliard
parent 9916931d41
commit 7673d67c1e
2 changed files with 82 additions and 29 deletions

View File

@ -1885,21 +1885,21 @@ BOOL WINAPI ImmIsUIMessageA(
TRACE("(%p, %x, %ld, %ld)\n", hWndIME, msg, wParam, lParam); TRACE("(%p, %x, %ld, %ld)\n", hWndIME, msg, wParam, lParam);
if ((msg >= WM_IME_STARTCOMPOSITION && msg <= WM_IME_KEYLAST) || if ((msg >= WM_IME_STARTCOMPOSITION && msg <= WM_IME_KEYLAST) ||
(msg >= WM_IME_SETCONTEXT && msg <= WM_IME_KEYUP) || (msg == WM_IME_SETCONTEXT) ||
(msg == WM_MSIME_SERVICE) || (msg == WM_IME_NOTIFY) ||
(msg == WM_MSIME_RECONVERTOPTIONS) || (msg == WM_IME_COMPOSITIONFULL) ||
(msg == WM_MSIME_MOUSE) || (msg == WM_IME_SELECT) ||
(msg == WM_MSIME_RECONVERTREQUEST) || (msg == WM_IME_SELECT) ||
(msg == WM_MSIME_RECONVERT) || (msg == 0x287 /* FIXME: WM_IME_SYSTEM */) ||
(msg == WM_MSIME_QUERYPOSITION) || (msg == WM_MSIME_RECONVERTOPTIONS) ||
(msg == WM_MSIME_DOCUMENTFEED)) (msg == WM_MSIME_MOUSE) ||
(msg == WM_MSIME_RECONVERTREQUEST) ||
(msg == WM_MSIME_RECONVERT) ||
(msg == WM_MSIME_QUERYPOSITION) ||
(msg == WM_MSIME_DOCUMENTFEED))
{ {
if (!IMM_GetThreadData()->hwndDefault) if (hWndIME)
ImmGetDefaultIMEWnd(NULL); SendMessageA(hWndIME, msg, wParam, lParam);
if (hWndIME == NULL)
PostMessageA(IMM_GetThreadData()->hwndDefault, msg, wParam, lParam);
rc = TRUE; rc = TRUE;
} }
@ -1913,22 +1913,24 @@ BOOL WINAPI ImmIsUIMessageW(
HWND hWndIME, UINT msg, WPARAM wParam, LPARAM lParam) HWND hWndIME, UINT msg, WPARAM wParam, LPARAM lParam)
{ {
BOOL rc = FALSE; BOOL rc = FALSE;
TRACE("(%p, %d, %ld, %ld):\n", hWndIME, msg, wParam, lParam);
if ((msg >= WM_IME_STARTCOMPOSITION && msg <= WM_IME_KEYLAST) ||
(msg >= WM_IME_SETCONTEXT && msg <= WM_IME_KEYUP) ||
(msg == WM_MSIME_SERVICE) ||
(msg == WM_MSIME_RECONVERTOPTIONS) ||
(msg == WM_MSIME_MOUSE) ||
(msg == WM_MSIME_RECONVERTREQUEST) ||
(msg == WM_MSIME_RECONVERT) ||
(msg == WM_MSIME_QUERYPOSITION) ||
(msg == WM_MSIME_DOCUMENTFEED))
{
if (!IMM_GetThreadData()->hwndDefault)
ImmGetDefaultIMEWnd(NULL);
if (hWndIME == NULL) TRACE("(%p, %x, %ld, %ld)\n", hWndIME, msg, wParam, lParam);
PostMessageW(IMM_GetThreadData()->hwndDefault, msg, wParam, lParam); if ((msg >= WM_IME_STARTCOMPOSITION && msg <= WM_IME_KEYLAST) ||
(msg == WM_IME_SETCONTEXT) ||
(msg == WM_IME_NOTIFY) ||
(msg == WM_IME_COMPOSITIONFULL) ||
(msg == WM_IME_SELECT) ||
(msg == WM_IME_SELECT) ||
(msg == 0x287 /* FIXME: WM_IME_SYSTEM */) ||
(msg == WM_MSIME_RECONVERTOPTIONS) ||
(msg == WM_MSIME_MOUSE) ||
(msg == WM_MSIME_RECONVERTREQUEST) ||
(msg == WM_MSIME_RECONVERT) ||
(msg == WM_MSIME_QUERYPOSITION) ||
(msg == WM_MSIME_DOCUMENTFEED))
{
if (hWndIME)
SendMessageW(hWndIME, msg, wParam, lParam);
rc = TRUE; rc = TRUE;
} }

View File

@ -28,6 +28,7 @@
#define NUMELEMS(array) (sizeof((array))/sizeof((array)[0])) #define NUMELEMS(array) (sizeof((array))/sizeof((array)[0]))
static BOOL (WINAPI *pImmAssociateContextEx)(HWND,HIMC,DWORD); static BOOL (WINAPI *pImmAssociateContextEx)(HWND,HIMC,DWORD);
static BOOL (WINAPI *pImmIsUIMessageA)(HWND,UINT,WPARAM,LPARAM);
/* /*
* msgspy - record and analyse message traces sent to a certain window * msgspy - record and analyse message traces sent to a certain window
@ -156,6 +157,7 @@ static BOOL init(void) {
hmod = GetModuleHandleA("imm32.dll"); hmod = GetModuleHandleA("imm32.dll");
pImmAssociateContextEx = (void*)GetProcAddress(hmod, "ImmAssociateContextEx"); pImmAssociateContextEx = (void*)GetProcAddress(hmod, "ImmAssociateContextEx");
pImmIsUIMessageA = (void*)GetProcAddress(hmod, "ImmIsUIMessageA");
wc.cbSize = sizeof(WNDCLASSEX); wc.cbSize = sizeof(WNDCLASSEX);
wc.style = 0; wc.style = 0;
@ -507,6 +509,54 @@ static void test_ImmThreads(void)
todo_wine ok(himc == NULL, "Should not be able to get himc from other process window\n"); todo_wine ok(himc == NULL, "Should not be able to get himc from other process window\n");
} }
static void test_ImmIsUIMessage(void)
{
struct test
{
UINT msg;
BOOL ret;
};
static const struct test tests[] =
{
{ WM_MOUSEMOVE, FALSE },
{ WM_IME_STARTCOMPOSITION, TRUE },
{ WM_IME_ENDCOMPOSITION, TRUE },
{ WM_IME_COMPOSITION, TRUE },
{ WM_IME_SETCONTEXT, TRUE },
{ WM_IME_NOTIFY, TRUE },
{ WM_IME_CONTROL, FALSE },
{ WM_IME_COMPOSITIONFULL, TRUE },
{ WM_IME_SELECT, TRUE },
{ WM_IME_CHAR, FALSE },
{ 0x287 /* FIXME */, TRUE },
{ WM_IME_REQUEST, FALSE },
{ WM_IME_KEYDOWN, FALSE },
{ WM_IME_KEYUP, FALSE },
{ 0, FALSE } /* mark the end */
};
const struct test *test;
BOOL ret;
if (!pImmIsUIMessageA) return;
for (test = tests; test->msg; test++)
{
msg_spy_flush_msgs();
ret = pImmIsUIMessageA(NULL, test->msg, 0, 0);
ok(ret == test->ret, "ImmIsUIMessageA returned %x for %x\n", ret, test->msg);
ok(!msg_spy_find_msg(test->msg), "Windows does not send 0x%x for NULL hwnd\n", test->msg);
ret = pImmIsUIMessageA(hwnd, test->msg, 0, 0);
ok(ret == test->ret, "ImmIsUIMessageA returned %x for %x\n", ret, test->msg);
if (ret)
ok(msg_spy_find_msg(test->msg) != NULL, "Windows does send 0x%x\n", test->msg);
else
ok(!msg_spy_find_msg(test->msg), "Windows does not send 0x%x\n", test->msg);
}
}
START_TEST(imm32) { START_TEST(imm32) {
if (init()) if (init())
{ {
@ -516,6 +566,7 @@ START_TEST(imm32) {
test_ImmIME(); test_ImmIME();
test_ImmAssociateContextEx(); test_ImmAssociateContextEx();
test_ImmThreads(); test_ImmThreads();
test_ImmIsUIMessage();
} }
cleanup(); cleanup();
} }