imm32: Post messages to the target window in ImmTranslateMessage.

This commit is contained in:
Rémi Bernon 2023-05-01 11:34:58 +02:00 committed by Alexandre Julliard
parent 1c96ed9bd9
commit f99ad772d1
2 changed files with 13 additions and 25 deletions

View file

@ -821,13 +821,6 @@ BOOL WINAPI DllMain( HINSTANCE instance, DWORD reason, void *reserved )
return TRUE;
}
static void imc_post_message( struct imc *imc, TRANSMSG *message )
{
HWND target;
if (!(target = GetFocus()) && !(target = imc->IMC.hWnd)) return;
PostMessageW( target, message->message, message->wParam, message->lParam );
}
/***********************************************************************
* ImmSetActiveContext (IMM32.@)
*/
@ -3104,6 +3097,7 @@ BOOL WINAPI ImmTranslateMessage( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lpar
};
TRANSMSGLIST list;
} buffer = {.uMsgCount = ARRAY_SIZE(buffer.TransMsg)};
TRANSMSG *msgs = buffer.TransMsg;
UINT scan, vkey, count, i;
struct imc *data;
struct ime *ime;
@ -3119,7 +3113,7 @@ BOOL WINAPI ImmTranslateMessage( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lpar
if ((vkey = data->vkey) == VK_PROCESSKEY) return FALSE;
data->vkey = VK_PROCESSKEY;
GetKeyboardState( state );
scan = lparam >> 0x10 & 0xff;
scan = lparam >> 0x10;
if (ime->info.fdwProperty & IME_PROP_KBD_CHAR_FIRST)
{
@ -3129,10 +3123,10 @@ BOOL WINAPI ImmTranslateMessage( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lpar
}
count = ime->pImeToAsciiEx( vkey, scan, state, &buffer.list, 0, data->handle );
TRACE( "%u messages generated\n", count );
if (count >= ARRAY_SIZE(buffer.TransMsg)) return 0;
if (count > ARRAY_SIZE(buffer.TransMsg)) ImmGenerateMessage( data->handle );
else for (i = 0; i < count; i++) imc_post_message( data, buffer.TransMsg + i );
for (i = 0; i < count; i++) PostMessageW( hwnd, msgs[i].message, msgs[i].wParam, msgs[i].lParam );
TRACE( "%u messages generated\n", count );
return count > 0;
}

View file

@ -6961,7 +6961,7 @@ static void test_ImmTranslateMessage( BOOL kbd_char_first )
.hkl = expect_ime, .himc = default_himc, .func = IME_PROCESS_KEY,
.process_key = {.vkey = 'Q', .lparam = MAKELONG(2, 0xc010)},
},
{.todo = TRUE},
{0},
};
const struct ime_call to_ascii_ex_0[] =
{
@ -6994,7 +6994,6 @@ static void test_ImmTranslateMessage( BOOL kbd_char_first )
{
.hkl = expect_ime, .himc = 0/*himc*/, .func = IME_TO_ASCII_EX,
.to_ascii_ex = {.vkey = kbd_char_first ? MAKELONG('Q', 'q') : 'Q', .vsc = 0x210},
.todo_value = TRUE,
},
{
.hkl = expect_ime, .himc = 0/*himc*/, .func = IME_PROCESS_KEY,
@ -7003,7 +7002,6 @@ static void test_ImmTranslateMessage( BOOL kbd_char_first )
{
.hkl = expect_ime, .himc = 0/*himc*/, .func = IME_TO_ASCII_EX,
.to_ascii_ex = {.vkey = kbd_char_first ? MAKELONG('Q', 'q') : 'Q', .vsc = 0x410},
.todo_value = TRUE,
},
{0},
};
@ -7016,7 +7014,6 @@ static void test_ImmTranslateMessage( BOOL kbd_char_first )
{
.hkl = expect_ime, .himc = 0/*himc*/, .func = IME_TO_ASCII_EX,
.to_ascii_ex = {.vkey = kbd_char_first ? MAKELONG('Q', 'q') : 'Q', .vsc = 0xa10},
.todo_value = TRUE,
},
{
.hkl = expect_ime, .himc = 0/*himc*/, .func = IME_PROCESS_KEY,
@ -7025,7 +7022,6 @@ static void test_ImmTranslateMessage( BOOL kbd_char_first )
{
.hkl = expect_ime, .himc = 0/*himc*/, .func = IME_TO_ASCII_EX,
.to_ascii_ex = {.vkey = kbd_char_first ? MAKELONG('Q', 'q') : 'Q', .vsc = 0xc10},
.todo_value = TRUE,
},
{0},
};
@ -7049,7 +7045,7 @@ static void test_ImmTranslateMessage( BOOL kbd_char_first )
INPUTCONTEXT *ctx;
HIMC himc;
HKL hkl;
UINT i, ret;
UINT i;
ime_info.fdwProperty = IME_PROP_END_UNLOAD | IME_PROP_UNICODE;
if (kbd_char_first) ime_info.fdwProperty |= IME_PROP_KBD_CHAR_FIRST;
@ -7108,16 +7104,15 @@ static void test_ImmTranslateMessage( BOOL kbd_char_first )
ctx->hWnd = hwnd;
ok_ret( 2, ImmProcessKey( hwnd, expect_ime, 'Q', MAKELONG(2, 0x210), 0 ) );
ret = ImmTranslateMessage( hwnd, WM_KEYUP, 'Q', MAKELONG(2, 0x210) );
todo_wine ok_eq( 1, ret, UINT, "%u" );
ok_ret( 1, ImmTranslateMessage( hwnd, WM_KEYUP, 'Q', MAKELONG(2, 0x210) ) );
ok_ret( 2, ImmProcessKey( hwnd, expect_ime, 'Q', MAKELONG(2, 0x410), 0 ) );
ok_ret( 0, ImmTranslateMessage( hwnd, WM_KEYUP, 'Q', MAKELONG(2, 0x410) ) );
ok_ret( VK_PROCESSKEY, ImmGetVirtualKey( hwnd ) );
ok_seq( to_ascii_ex_2 );
process_messages();
todo_wine ok_seq( post_messages );
ok_seq( post_messages );
ok_ret( 1, ImmGenerateMessage( himc ) );
todo_wine ok_seq( sent_messages );
ok_seq( sent_messages );
ok_ret( 2, ImmProcessKey( hwnd, expect_ime, 'Q', MAKELONG(2, 0xa10), 0 ) );
ok_ret( 0, ImmTranslateMessage( hwnd, WM_KEYUP, 'Q', MAKELONG(2, 0xa10) ) );
@ -7128,12 +7123,11 @@ static void test_ImmTranslateMessage( BOOL kbd_char_first )
process_messages();
ok_seq( empty_sequence );
ok_ret( 1, ImmGenerateMessage( himc ) );
todo_wine ok_seq( sent_messages );
ok_seq( sent_messages );
ctx->hWnd = 0;
ok_ret( 2, ImmProcessKey( other_hwnd, expect_ime, 'Q', MAKELONG(2, 0x210), 0 ) );
ret = ImmTranslateMessage( other_hwnd, WM_KEYUP, 'Q', MAKELONG(2, 0x210) );
todo_wine ok_eq( 1, ret, UINT, "%u" );
ok_ret( 1, ImmTranslateMessage( other_hwnd, WM_KEYUP, 'Q', MAKELONG(2, 0x210) ) );
ok_ret( 2, ImmProcessKey( other_hwnd, expect_ime, 'Q', MAKELONG(2, 0x410), 0 ) );
ok_ret( 0, ImmTranslateMessage( other_hwnd, WM_KEYUP, 'Q', MAKELONG(2, 0x410) ) );
ok_ret( VK_PROCESSKEY, ImmGetVirtualKey( other_hwnd ) );
@ -7141,7 +7135,7 @@ static void test_ImmTranslateMessage( BOOL kbd_char_first )
process_messages_( hwnd );
ok_seq( empty_sequence );
process_messages_( other_hwnd );
todo_wine ok_seq( post_messages );
ok_seq( post_messages );
ok_ret( 1, ImmGenerateMessage( himc ) );
ok_seq( empty_sequence );