From: André Hentschel Subject: imm32: Test and fix ImmIsUIMessageA/W Message-Id: <4E05ED15.8080205@dawncrow.de> Date: Sat, 25 Jun 2011 16:13:41 +0200 This fixes http://bugs.winehq.org/show_bug.cgi?id=27554 and most likely also http://bugs.winehq.org/show_bug.cgi?id=25562 I used the test and fix way because otherwise i had to introduce a todo entry in the test struct which later could have been removed. --- dlls/imm32/imm.c | 58 +++++++++++++++++++++++---------------------- dlls/imm32/tests/imm32.c | 51 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 81 insertions(+), 28 deletions(-) diff --git a/dlls/imm32/imm.c b/dlls/imm32/imm.c index 00a7c6a..fe394e3 100644 --- a/dlls/imm32/imm.c +++ b/dlls/imm32/imm.c @@ -1885,21 +1885,21 @@ BOOL WINAPI ImmIsUIMessageA( TRACE("(%p, %x, %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) - PostMessageA(IMM_GetThreadData()->hwndDefault, msg, wParam, lParam); + (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) + SendMessageA(hWndIME, msg, wParam, lParam); rc = TRUE; } @@ -1913,22 +1913,24 @@ BOOL WINAPI ImmIsUIMessageW( HWND hWndIME, UINT msg, WPARAM wParam, LPARAM lParam) { BOOL rc = FALSE; - TRACE("(%p, %d, %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) || - (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) - PostMessageW(IMM_GetThreadData()->hwndDefault, msg, wParam, lParam); + (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; } diff --git a/dlls/imm32/tests/imm32.c b/dlls/imm32/tests/imm32.c index 9f40953..39bedb2 100644 --- a/dlls/imm32/tests/imm32.c +++ b/dlls/imm32/tests/imm32.c @@ -28,6 +28,7 @@ #define NUMELEMS(array) (sizeof((array))/sizeof((array)[0])) 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 @@ -156,6 +157,7 @@ static BOOL init(void) { hmod = GetModuleHandleA("imm32.dll"); pImmAssociateContextEx = (void*)GetProcAddress(hmod, "ImmAssociateContextEx"); + pImmIsUIMessageA = (void*)GetProcAddress(hmod, "ImmIsUIMessageA"); wc.cbSize = sizeof(WNDCLASSEX); 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"); } +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) { if (init()) { @@ -516,6 +566,7 @@ START_TEST(imm32) { test_ImmIME(); test_ImmAssociateContextEx(); test_ImmThreads(); + test_ImmIsUIMessage(); } cleanup(); } -- Best Regards, André Hentschel