[PATCH] riched20: Send CPS_COMPLETE from mouse click event.

Alex Kwak take-me-home at kakao.com
Wed Mar 30 20:31:34 CDT 2022


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 <take-me-home at kakao.com>
---
 dlls/riched20/editor.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/dlls/riched20/editor.c b/dlls/riched20/editor.c
index a8cf3175591..f8b28bfaef0 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;
@@ -3888,6 +3889,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 +3920,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 +4552,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




More information about the wine-devel mailing list