[PATCH] riched20: Handle GCS_COMPSTR, GCS_CURSORPOS on WM_IME_COMPOSITION.
Alex Kwak
take-me-home at kakao.com
Tue Mar 29 03:47:50 CDT 2022
previously, doesn't handle GCS_RESULTSTR message. Therefore, it makes
start index of IME have wrong position.
as a result, Some IME have problems inserting characters in the wrong
place.
GCS_CURSORPOS is an event that location of the caret in IME, but
WM_IME_COMPOSITION always calls DeleteSelection and attempts to adjust
the location, causing the caret to be misplaced.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=52700
Signed-off-by: Alex Kwak <take-me-home at kakao.com>
---
v2: fix c++ style comment to c style comment
---
dlls/riched20/editor.c | 41 +++++++++++++++++++++++++++++------------
1 file changed, 29 insertions(+), 12 deletions(-)
diff --git a/dlls/riched20/editor.c b/dlls/riched20/editor.c
index a8cf3175591..2816381a77e 100644
--- a/dlls/riched20/editor.c
+++ b/dlls/riched20/editor.c
@@ -4097,40 +4097,57 @@ 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;
}
case WM_IME_COMPOSITION:
{
- HIMC hIMC;
-
- 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))
{
+ HIMC hIMC = ITextHost_TxImmGetContext(editor->texthost);
+ ME_Style *style = style_get_insert_style( editor, editor->pCursors );
LPWSTR lpCompStr = NULL;
DWORD dwBufLen;
DWORD dwIndex = lParam & GCS_RESULTSTR;
+ DWORD dwBufStrLen;
if (!dwIndex)
dwIndex = GCS_COMPSTR;
+ ME_DeleteSelection(editor);
+ ME_SaveTempStyle(editor, style);
+
dwBufLen = ImmGetCompositionStringW(hIMC, dwIndex, NULL, 0);
- lpCompStr = HeapAlloc(GetProcessHeap(),0,dwBufLen + sizeof(WCHAR));
+ dwBufStrLen = dwBufLen / sizeof(WCHAR);
+ lpCompStr = HeapAlloc(GetProcessHeap(), 0, dwBufLen + sizeof(WCHAR));
ImmGetCompositionStringW(hIMC, dwIndex, lpCompStr, dwBufLen);
- lpCompStr[dwBufLen/sizeof(WCHAR)] = 0;
- ME_InsertTextFromCursor(editor,0,lpCompStr,dwBufLen/sizeof(WCHAR),style);
+ lpCompStr[dwBufStrLen] = 0;
+ ME_InsertTextFromCursor(editor, 0, lpCompStr, dwBufStrLen, style);
HeapFree(GetProcessHeap(), 0, lpCompStr);
if (dwIndex == GCS_COMPSTR)
+ {
set_selection_cursors(editor,editor->imeStartIndex,
- editor->imeStartIndex + dwBufLen/sizeof(WCHAR));
+ editor->imeStartIndex + dwBufStrLen);
+ }
+ else
+ {
+ /*
+ * During Composition, change the start position if the completed
+ * characters are reflected.
+ */
+ editor->imeStartIndex += dwBufStrLen;
+ }
+ ME_ReleaseStyle(style);
}
- ME_ReleaseStyle(style);
+ else if (lParam & GCS_CURSORPOS)
+ {
+ set_selection_cursors(editor, editor->imeStartIndex,
+ editor->imeStartIndex + (DWORD) wParam);
+ }
+
ME_CommitUndo(editor);
ME_UpdateRepaint(editor, FALSE);
return 0;
--
2.32.0
More information about the wine-devel
mailing list