Module: wine Branch: master Commit: 08e2edce964ef6f58f3fd874bc5001f8b9ec0292 URL: https://gitlab.winehq.org/wine/wine/-/commit/08e2edce964ef6f58f3fd874bc5001f...
Author: Rémi Bernon rbernon@codeweavers.com Date: Tue Apr 25 12:14:54 2023 +0200
imm32: Send messages one by one in ImmGenerateMessage.
---
dlls/imm32/imm.c | 46 ++++++++++++++-------------------------------- dlls/imm32/tests/imm32.c | 23 ++++++++++------------- 2 files changed, 24 insertions(+), 45 deletions(-)
diff --git a/dlls/imm32/imm.c b/dlls/imm32/imm.c index 7d4f4b4c13f..dfe81ddaaf7 100644 --- a/dlls/imm32/imm.c +++ b/dlls/imm32/imm.c @@ -828,13 +828,6 @@ static void imc_post_message( struct imc *imc, TRANSMSG *message ) PostMessageW( target, message->message, message->wParam, message->lParam ); }
-static void imc_send_message( struct imc *imc, TRANSMSG *message ) -{ - HWND target; - if (!(target = GetFocus()) && !(target = imc->IMC.hWnd)) return; - SendMessageW( target, message->message, message->wParam, message->lParam ); -} - /*********************************************************************** * ImmSetActiveContext (IMM32.@) */ @@ -3049,36 +3042,25 @@ DWORD WINAPI ImmGetIMCCSize(HIMCC imcc) /*********************************************************************** * ImmGenerateMessage(IMM32.@) */ -BOOL WINAPI ImmGenerateMessage(HIMC hIMC) +BOOL WINAPI ImmGenerateMessage( HIMC himc ) { - struct imc *data = get_imc_data( hIMC ); - - if (!data) - { - SetLastError(ERROR_INVALID_HANDLE); - return FALSE; - } - - TRACE("%li messages queued\n",data->IMC.dwNumMsgBuf); - if (data->IMC.dwNumMsgBuf > 0) - { - LPTRANSMSG lpTransMsg; - HIMCC hMsgBuf; - DWORD i, dwNumMsgBuf; + INPUTCONTEXT *ctx;
- /* We are going to detach our hMsgBuff so that if processing messages - generates new messages they go into a new buffer */ - hMsgBuf = data->IMC.hMsgBuf; - dwNumMsgBuf = data->IMC.dwNumMsgBuf; + TRACE( "himc %p\n", himc );
- data->IMC.hMsgBuf = ImmCreateIMCC(0); - data->IMC.dwNumMsgBuf = 0; + if (NtUserQueryInputContext( himc, NtUserInputContextThreadId ) != GetCurrentThreadId()) return FALSE; + if (!(ctx = ImmLockIMC( himc ))) return FALSE;
- lpTransMsg = ImmLockIMCC(hMsgBuf); - for (i = 0; i < dwNumMsgBuf; i++) imc_send_message( data, lpTransMsg + i ); - ImmUnlockIMCC(hMsgBuf); - ImmDestroyIMCC(hMsgBuf); + while (ctx->dwNumMsgBuf--) + { + TRANSMSG *msgs, msg; + if (!(msgs = ImmLockIMCC( ctx->hMsgBuf ))) return FALSE; + msg = msgs[0]; + memmove( msgs, msgs + 1, ctx->dwNumMsgBuf * sizeof(*msgs) ); + ImmUnlockIMCC( ctx->hMsgBuf ); + SendMessageW( ctx->hWnd, msg.message, msg.wParam, msg.lParam ); } + ctx->dwNumMsgBuf++;
return TRUE; } diff --git a/dlls/imm32/tests/imm32.c b/dlls/imm32/tests/imm32.c index 344729b9866..093b79ff86b 100644 --- a/dlls/imm32/tests/imm32.c +++ b/dlls/imm32/tests/imm32.c @@ -1322,8 +1322,8 @@ static void test_cross_thread_himc(void)
ok_ret( 1, ImmGenerateMessage( himc[1] ) );
- todo_wine ok_ret( 0, ImmGenerateMessage( params.himc[0] ) ); - todo_wine ok_ret( 0, ImmGenerateMessage( params.himc[1] ) ); + ok_ret( 0, ImmGenerateMessage( params.himc[0] ) ); + ok_ret( 0, ImmGenerateMessage( params.himc[1] ) );
/* ImmAssociateContext should fail with cross thread HWND or HIMC */
@@ -6619,12 +6619,10 @@ static void test_ImmGenerateMessage(void) { .hkl = expect_ime, .himc = default_himc, .func = MSG_TEST_WIN, .message = {.msg = WM_IME_COMPOSITION, .wparam = 0, .lparam = GCS_COMPSTR}, - .todo = TRUE, }, { .hkl = expect_ime, .himc = default_himc, .func = MSG_IME_UI, .message = {.msg = WM_IME_COMPOSITION, .wparam = 0, .lparam = GCS_COMPSTR}, - .todo = TRUE, }, {0}, }; @@ -6673,34 +6671,33 @@ static void test_ImmGenerateMessage(void)
ctx->dwNumMsgBuf = 1; ok_ret( 1, ImmGenerateMessage( himc ) ); - todo_wine ok_seq( empty_sequence ); + ok_seq( empty_sequence ); ok_eq( 0, ctx->dwNumMsgBuf, UINT, "%u" ); - todo_wine ok_ret( sizeof(*msgs), ImmGetIMCCSize( ctx->hMsgBuf ) ); + ok_ret( sizeof(*msgs), ImmGetIMCCSize( ctx->hMsgBuf ) ); tmp_msgs = ImmLockIMCC( ctx->hMsgBuf ); - todo_wine ok_eq( msgs, tmp_msgs, TRANSMSG *, "%p" ); + ok_eq( msgs, tmp_msgs, TRANSMSG *, "%p" ); ok_ret( 0, ImmUnlockIMCC( ctx->hMsgBuf ) );
ctx->hWnd = hwnd; ctx->dwNumMsgBuf = 0; ok_ret( 1, ImmGenerateMessage( himc ) ); ok_seq( empty_sequence ); - todo_wine ok_ret( sizeof(*msgs), ImmGetIMCCSize( ctx->hMsgBuf ) ); + ok_ret( sizeof(*msgs), ImmGetIMCCSize( ctx->hMsgBuf ) ); tmp_msgs = ImmLockIMCC( ctx->hMsgBuf ); - todo_wine ok_eq( msgs, tmp_msgs, TRANSMSG *, "%p" ); + ok_eq( msgs, tmp_msgs, TRANSMSG *, "%p" ); ok_ret( 0, ImmUnlockIMCC( ctx->hMsgBuf ) ); - if (!tmp_msgs) ctx->hMsgBuf = ImmReSizeIMCC( ctx->hMsgBuf, sizeof(*msgs) );
ctx->dwNumMsgBuf = 1; ok_ret( 1, ImmGenerateMessage( himc ) ); ok_seq( generate_sequence ); ok_eq( 0, ctx->dwNumMsgBuf, UINT, "%u" ); - todo_wine ok_ret( sizeof(*msgs), ImmGetIMCCSize( ctx->hMsgBuf ) ); + ok_ret( sizeof(*msgs), ImmGetIMCCSize( ctx->hMsgBuf ) ); tmp_msgs = ImmLockIMCC( ctx->hMsgBuf ); - todo_wine ok_eq( msgs, tmp_msgs, TRANSMSG *, "%p" ); + ok_eq( msgs, tmp_msgs, TRANSMSG *, "%p" ); ok_ret( 0, ImmUnlockIMCC( ctx->hMsgBuf ) );
tmp_msgs = ImmLockIMCC( ctx->hMsgBuf ); - todo_wine ok_eq( msgs, tmp_msgs, TRANSMSG *, "%p" ); + ok_eq( msgs, tmp_msgs, TRANSMSG *, "%p" ); ok_ret( 0, ImmUnlockIMCC( ctx->hMsgBuf ) );
ok_ret( 1, ImmUnlockIMC( himc ) );