winex11.drv: Handle arbitrary length composed input.

Kusanagi Kouichi slash at ma.neweb.ne.jp
Wed Mar 19 04:16:36 CDT 2008


Fix bug #9838. http://bugs.winehq.org/show_bug.cgi?id=9838
---
 dlls/winex11.drv/keyboard.c |   25 ++++++++++++++++---------
 dlls/winex11.drv/xim.c      |   16 ++++++++++------
 2 files changed, 26 insertions(+), 15 deletions(-)

diff --git a/dlls/winex11.drv/keyboard.c b/dlls/winex11.drv/keyboard.c
index 33640db..386a471 100644
--- a/dlls/winex11.drv/keyboard.c
+++ b/dlls/winex11.drv/keyboard.c
@@ -1365,22 +1365,29 @@ void X11DRV_KeyEvent( HWND hwnd, XEvent *xev )
     wine_tsx11_lock();
     /* Clients should pass only KeyPress events to XmbLookupString */
     if (xic && event->type == KeyPress)
+    {
         ascii_chars = XmbLookupString(xic, event, Str, sizeof(Str), &keysym, &status);
+
+        if (status == XBufferOverflow)
+        {
+            char buf[ascii_chars];
+
+            ascii_chars = XmbLookupString(xic, event, buf, sizeof buf, &keysym, &status);
+            X11DRV_XIMLookupChars( buf, ascii_chars );
+            return;
+        }
+        else if (status == XLookupChars)
+        {
+            X11DRV_XIMLookupChars( Str, ascii_chars );
+            return;
+        }
+    }
     else
         ascii_chars = XLookupString(event, Str, sizeof(Str), &keysym, NULL);
     wine_tsx11_unlock();
 
     TRACE_(key)("nbyte = %d, status 0x%x\n", ascii_chars, status);
 
-    if (status == XBufferOverflow)
-        ERR("Buffer Overflow need %i!\n",ascii_chars);
-
-    if (status == XLookupChars)
-    {
-        X11DRV_XIMLookupChars( Str, ascii_chars );
-        return;
-    }
-
     /* If XKB extensions are used, the state mask for AltGr will use the group
        index instead of the modifier mask. The group index is set in bits
        13-14 of the state field in the XKeyEvent structure. So if AltGr is
diff --git a/dlls/winex11.drv/xim.c b/dlls/winex11.drv/xim.c
index 7cf1099..869f958 100644
--- a/dlls/winex11.drv/xim.c
+++ b/dlls/winex11.drv/xim.c
@@ -239,15 +239,19 @@ static BOOL X11DRV_ImmSetInternalString(DWORD dwIndex, DWORD dwOffset,
 void X11DRV_XIMLookupChars( const char *str, DWORD count )
 {
     DWORD dwOutput;
-    WCHAR wcOutput[64];
-    HWND focus;
 
-    dwOutput = MultiByteToWideChar(CP_UNIXCP, 0, str, count, wcOutput, sizeof(wcOutput)/sizeof(WCHAR));
+    dwOutput = MultiByteToWideChar(CP_UNIXCP, 0, str, count, NULL, 0);
+    {
+        WCHAR wcOutput[dwOutput];
+        HWND focus;
+
+        dwOutput = MultiByteToWideChar(CP_UNIXCP, 0, str, count, wcOutput, dwOutput);
 
-    if (pImmAssociateContext && (focus = GetFocus()))
-        pImmAssociateContext(focus,root_context);
+        if (pImmAssociateContext && (focus = GetFocus()))
+            pImmAssociateContext(focus, root_context);
 
-    X11DRV_ImmSetInternalString(GCS_RESULTSTR,0,0,wcOutput,dwOutput);
+        X11DRV_ImmSetInternalString(GCS_RESULTSTR, 0, 0, wcOutput, dwOutput);
+    }
 }
 
 static void X11DRV_ImmSetOpenStatus(BOOL fOpen)
-- 
1.5.4.4




More information about the wine-patches mailing list