Huw Davies : riched20: Handle WM_CHAR's unicode conversion in the host.

Alexandre Julliard julliard at winehq.org
Thu Mar 11 15:59:34 CST 2021


Module: wine
Branch: master
Commit: 9fa993022eab6408243e440f962d1c20a624b803
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=9fa993022eab6408243e440f962d1c20a624b803

Author: Huw Davies <huw at codeweavers.com>
Date:   Thu Mar 11 08:51:02 2021 +0000

riched20: Handle WM_CHAR's unicode conversion in the host.

Signed-off-by: Huw Davies <huw at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/riched20/editor.c  | 23 ++++++-----------------
 dlls/riched20/txthost.c |  8 ++++++++
 2 files changed, 14 insertions(+), 17 deletions(-)

diff --git a/dlls/riched20/editor.c b/dlls/riched20/editor.c
index cacad463963..3d17d2d974f 100644
--- a/dlls/riched20/editor.c
+++ b/dlls/riched20/editor.c
@@ -2744,11 +2744,8 @@ ME_KeyDown(ME_TextEditor *editor, WORD nKey)
   return FALSE;
 }
 
-static LRESULT ME_Char(ME_TextEditor *editor, WPARAM charCode,
-                       LPARAM flags, BOOL unicode)
+static LRESULT handle_wm_char( ME_TextEditor *editor, WCHAR wstr, LPARAM flags )
 {
-  WCHAR wstr;
-
   if (editor->bMouseCaptured)
     return 0;
 
@@ -2758,14 +2755,6 @@ static LRESULT ME_Char(ME_TextEditor *editor, WPARAM charCode,
     return 0; /* FIXME really 0 ? */
   }
 
-  if (unicode)
-      wstr = (WCHAR)charCode;
-  else
-  {
-      CHAR charA = charCode;
-      MultiByteToWideChar(CP_ACP, 0, &charA, 1, &wstr, 1);
-  }
-
   if (editor->bEmulateVersion10 && wstr == '\r')
       handle_enter(editor);
 
@@ -4379,7 +4368,7 @@ LRESULT ME_HandleMessage(ME_TextEditor *editor, UINT msg, WPARAM wParam,
     if ((editor->nEventMask & ENM_KEYEVENTS) &&
         !ME_FilterEvent(editor, msg, &wParam, &lParam))
       return 0;
-    return ME_Char(editor, wParam, lParam, unicode);
+    return handle_wm_char( editor, wParam, lParam );
   case WM_UNICHAR:
     if (unicode)
     {
@@ -4389,11 +4378,11 @@ LRESULT ME_HandleMessage(ME_TextEditor *editor, UINT msg, WPARAM wParam,
             if(wParam > 0xffff) /* convert to surrogates */
             {
                 wParam -= 0x10000;
-                ME_Char(editor, (wParam >> 10) + 0xd800, 0, TRUE);
-                ME_Char(editor, (wParam & 0x03ff) + 0xdc00, 0, TRUE);
-            } else {
-              ME_Char(editor, wParam, 0, TRUE);
+                handle_wm_char( editor, (wParam >> 10) + 0xd800, 0 );
+                handle_wm_char( editor, (wParam & 0x03ff) + 0xdc00, 0 );
             }
+            else
+                handle_wm_char( editor, wParam, 0 );
         }
         return 0;
     }
diff --git a/dlls/riched20/txthost.c b/dlls/riched20/txthost.c
index 17b6daf7517..ac561ef4c83 100644
--- a/dlls/riched20/txthost.c
+++ b/dlls/riched20/txthost.c
@@ -780,6 +780,14 @@ static LRESULT RichEditWndProc_common( HWND hwnd, UINT msg, WPARAM wparam,
     editor = host->editor;
     switch (msg)
     {
+    case WM_CHAR:
+    {
+        WCHAR wc = wparam;
+
+        if (!unicode) MultiByteToWideChar( CP_ACP, 0, (char *)&wparam, 1, &wc, 1 );
+        hr = ITextServices_TxSendMessage( host->text_srv, msg, wc, lparam, &res );
+        break;
+    }
     case WM_DESTROY:
         ITextHost_Release( &host->ITextHost_iface );
         return 0;




More information about the wine-cvs mailing list