From: Alex Kwak Subject: [PATCH v2] riched20: Send CPS_COMPLETE from mouse click event. Message-Id: <20220331022248.111076-1-take-me-home@kakao.com> Date: Thu, 31 Mar 2022 11:22:48 +0900 When IME is in the Composition state and trying to move cursor, the composition string in the IME is inserted wrong places in next keyboard event. so, notify IME that composition has been completed and handle events related to click buttons after completing IME operations. Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=52754 Signed-off-by: Alex Kwak --- v2: Initialize imeStartIndex with -1 on ME_MakeEditor. --- dlls/riched20/editor.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/dlls/riched20/editor.c b/dlls/riched20/editor.c index a8cf3175591..ff6edfc145f 100644 --- a/dlls/riched20/editor.c +++ b/dlls/riched20/editor.c @@ -243,6 +243,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(richedit); static BOOL ME_UpdateLinkAttribute(ME_TextEditor *editor, ME_Cursor *start, int nChars); +static BOOL ME_NotifyIMECPSComplete(ME_TextEditor *editor); HINSTANCE dll_instance = NULL; BOOL me_debug = FALSE; @@ -3045,6 +3046,8 @@ ME_TextEditor *ME_MakeEditor(ITextHost *texthost, BOOL bEmulateVersion10) ed->back_style = TXTBACK_OPAQUE; ITextHost_TxGetBackStyle( ed->texthost, &ed->back_style ); + ed->imeStartIndex = -1; + list_init( &ed->reobj_list ); OleInitialize(NULL); @@ -3888,6 +3891,7 @@ LRESULT editor_handle_message( ME_TextEditor *editor, UINT msg, WPARAM wParam, case WM_LBUTTONDOWN: { ME_CommitUndo(editor); /* End coalesced undos for typed characters */ + ME_NotifyIMECPSComplete(editor); ITextHost_TxSetFocus(editor->texthost); ME_LButtonDown(editor, (short)LOWORD(lParam), (short)HIWORD(lParam), ME_CalculateClickCount(editor, msg, wParam, lParam)); @@ -3918,6 +3922,7 @@ LRESULT editor_handle_message( ME_TextEditor *editor, UINT msg, WPARAM wParam, case WM_RBUTTONDOWN: case WM_RBUTTONDBLCLK: ME_CommitUndo(editor); /* End coalesced undos for typed characters */ + ME_NotifyIMECPSComplete(editor); link_notify( editor, msg, wParam, lParam ); goto do_default; case WM_CONTEXTMENU: @@ -4549,3 +4554,20 @@ static BOOL ME_UpdateLinkAttribute(ME_TextEditor *editor, ME_Cursor *start, int } while (nChars > 0); return modified; } + +static BOOL ME_NotifyIMECPSComplete(ME_TextEditor *editor) +{ + if (editor->imeStartIndex >= 0) + { + HIMC hIMC = ITextHost_TxImmGetContext(editor->texthost); + if (hIMC) + { + ME_DeleteSelection(editor); + editor->imeStartIndex = ME_GetCursorOfs(&editor->pCursors[0]); + ImmNotifyIME(hIMC, NI_COMPOSITIONSTR, CPS_COMPLETE, 0); + ITextHost_TxImmReleaseContext(editor->texthost, hIMC); + return TRUE; + } + } + return FALSE; +} -- 2.32.0