[PATCH v3] dlls: Flush CompositionString after X11DRV_XIMLookupChars.

Alex Kwak take-me-home at kakao.com
Wed Mar 16 07:47:02 CDT 2022


There is no flushing after X11DRV_XIMLookupChars on wine11xdrv. for
this reason, the characters of the GUI are not updated.

In addition, in IME_SetResultString on wine11xdrv, the bInComposition
flag is not deactivated after generating WM_IME_ENDCOMPOSITION, so that
the WM_IME_STARTCOMPOSITION message is not generated in the next
composition.

Also, when WM_IME_COMPOSITION is processed in editor_handle_message on
riched20, the existing selection is removed and the characters being
entered disappear.
WM_IME_STARTCOMPOSITION occurs when attempting to input after full
selection, and ME_DeleteSelection is called, which causes the exact
location of the cursor to be lost.

Signed-off-by: Alex Kwak <take-me-home at kakao.com>
---
v2: Fix test breakage.
v3: Fix comment style
---
 dlls/riched20/editor.c |  3 +--
 dlls/winex11.drv/ime.c |  5 ++---
 dlls/winex11.drv/xim.c | 10 ++++++++++
 3 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/dlls/riched20/editor.c b/dlls/riched20/editor.c
index a8cf3175591..33437a6d6e3 100644
--- a/dlls/riched20/editor.c
+++ b/dlls/riched20/editor.c
@@ -4097,8 +4097,8 @@ LRESULT editor_handle_message( ME_TextEditor *editor, UINT msg, WPARAM wParam,
     return 0;
   case WM_IME_STARTCOMPOSITION:
   {
-    editor->imeStartIndex=ME_GetCursorOfs(&editor->pCursors[0]);
     ME_DeleteSelection(editor);
+    editor->imeStartIndex=ME_GetCursorOfs(&editor->pCursors[0]);
     ME_CommitUndo(editor);
     ME_UpdateRepaint(editor, FALSE);
     return 0;
@@ -4109,7 +4109,6 @@ LRESULT editor_handle_message( ME_TextEditor *editor, UINT msg, WPARAM wParam,
 
     ME_Style *style = style_get_insert_style( editor, editor->pCursors );
     hIMC = ITextHost_TxImmGetContext(editor->texthost);
-    ME_DeleteSelection(editor);
     ME_SaveTempStyle(editor, style);
     if (lParam & (GCS_RESULTSTR|GCS_COMPSTR))
     {
diff --git a/dlls/winex11.drv/ime.c b/dlls/winex11.drv/ime.c
index c1584930861..db2ff5d85cc 100644
--- a/dlls/winex11.drv/ime.c
+++ b/dlls/winex11.drv/ime.c
@@ -1049,10 +1049,9 @@ void IME_SetResultString(LPWSTR lpResult, DWORD dwResultLen)
     GenerateIMEMessage(imc, WM_IME_COMPOSITION, 0, GCS_COMPSTR);
     GenerateIMEMessage(imc, WM_IME_COMPOSITION, lpResult[0], GCS_RESULTSTR|GCS_RESULTCLAUSE);
     GenerateIMEMessage(imc, WM_IME_ENDCOMPOSITION, 0, 0);
+    myPrivate->bInComposition = FALSE;
 
-    if (!inComp)
-        ImmSetOpenStatus(imc, FALSE);
-
+    ImmSetOpenStatus(imc, FALSE);
     ImmUnlockIMC(imc);
 }
 
diff --git a/dlls/winex11.drv/xim.c b/dlls/winex11.drv/xim.c
index 3994c2106cc..66c56c177ac 100644
--- a/dlls/winex11.drv/xim.c
+++ b/dlls/winex11.drv/xim.c
@@ -117,6 +117,16 @@ void X11DRV_XIMLookupChars( const char *str, DWORD count )
 
     IME_SetResultString(wcOutput, dwOutput);
     HeapFree(GetProcessHeap(), 0, wcOutput);
+
+    /*
+     * After then if `CompositionString` is remaining, flushing it.
+     * i.e., Korean
+     */
+    if (CompositionString)
+    {
+        IME_SetCompositionString(SCS_SETSTR, CompositionString,
+                                 dwCompStringLength, NULL, 0);
+    }
 }
 
 static BOOL XIMPreEditStateNotifyCallback(XIC xic, XPointer p, XPointer data)
-- 
2.32.0




More information about the wine-devel mailing list