Kusanagi Kouichi : winex11: Update caret position.

Alexandre Julliard julliard at winehq.org
Fri Apr 18 07:27:25 CDT 2008


Module: wine
Branch: master
Commit: bb8d1ca672b545900d6916a3716e71a39fcf3565
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=bb8d1ca672b545900d6916a3716e71a39fcf3565

Author: Kusanagi Kouichi <slash at ma.neweb.ne.jp>
Date:   Fri Apr 18 09:48:31 2008 +0900

winex11: Update caret position.

---

 dlls/winex11.drv/ime.c    |   26 ++++++++++++++++++++++++++
 dlls/winex11.drv/x11drv.h |    1 +
 dlls/winex11.drv/xim.c    |    7 ++-----
 3 files changed, 29 insertions(+), 5 deletions(-)

diff --git a/dlls/winex11.drv/ime.c b/dlls/winex11.drv/ime.c
index a1c229e..e4a2dd7 100644
--- a/dlls/winex11.drv/ime.c
+++ b/dlls/winex11.drv/ime.c
@@ -1012,6 +1012,32 @@ INT IME_GetCursorPos()
     return rc;
 }
 
+void IME_SetCursorPos(DWORD pos)
+{
+    LPINPUTCONTEXT lpIMC;
+    LPCOMPOSITIONSTRING compstr;
+
+    if (!hSelectedFrom)
+        return;
+
+    lpIMC = LockRealIMC(FROM_X11);
+    if (!lpIMC)
+        return;
+
+    compstr = (LPCOMPOSITIONSTRING)ImmLockIMCC(lpIMC->hCompStr);
+    if (!compstr)
+    {
+        UnlockRealIMC(FROM_X11);
+        return;
+    }
+
+    compstr->dwCursorPos = pos;
+    ImmUnlockIMCC(lpIMC->hCompStr);
+    UnlockRealIMC(FROM_X11);
+    GenerateIMEMessage(FROM_X11, WM_IME_COMPOSITION, pos, GCS_CURSORPOS);
+    return;
+}
+
 void IME_UpdateAssociation(HWND focus)
 {
     ImmGetContext(focus);
diff --git a/dlls/winex11.drv/x11drv.h b/dlls/winex11.drv/x11drv.h
index 30b339e..90a2abd 100644
--- a/dlls/winex11.drv/x11drv.h
+++ b/dlls/winex11.drv/x11drv.h
@@ -280,6 +280,7 @@ extern void IME_SetOpenStatus(BOOL fOpen);
 extern void IME_XIMPresent(BOOL present);
 extern LRESULT IME_SendMessageToSelectedHWND(UINT msg, WPARAM wParam, LPARAM lParam);
 extern INT IME_GetCursorPos();
+extern void IME_SetCursorPos(DWORD pos);
 extern void IME_UpdateAssociation(HWND focus);
 extern BOOL IME_SetCompositionString(DWORD dwIndex, LPCVOID lpComp,
                                      DWORD dwCompLen, LPCVOID lpRead,
diff --git a/dlls/winex11.drv/xim.c b/dlls/winex11.drv/xim.c
index e8bf3bb..265f9c8 100644
--- a/dlls/winex11.drv/xim.c
+++ b/dlls/winex11.drv/xim.c
@@ -48,7 +48,6 @@ static LPBYTE CompositionString = NULL;
 static DWORD dwCompStringSize = 0;
 static LPBYTE ResultString = NULL;
 static DWORD dwResultStringSize = 0;
-static DWORD dwPreeditPos = 0;
 
 #define STYLE_OFFTHESPOT (XIMPreeditArea | XIMStatusArea)
 #define STYLE_OVERTHESPOT (XIMPreeditPosition | XIMStatusNothing)
@@ -216,7 +215,6 @@ static int XIMPreEditStartCallback(XIC ic, XPointer client_data, XPointer call_d
     TRACE("PreEditStartCallback %p\n",ic);
     X11DRV_ImmSetOpenStatus(TRUE);
     ximInComposeMode = TRUE;
-    IME_SendMessageToSelectedHWND(EM_GETSEL, 0, (LPARAM)&dwPreeditPos);
     return -1;
 }
 
@@ -225,7 +223,6 @@ static void XIMPreEditDoneCallback(XIC ic, XPointer client_data, XPointer call_d
     TRACE("PreeditDoneCallback %p\n",ic);
     ximInComposeMode = FALSE;
     X11DRV_ImmSetOpenStatus(FALSE);
-    dwPreeditPos = 0;
 }
 
 static void XIMPreEditDrawCallback(XIM ic, XPointer client_data,
@@ -271,6 +268,7 @@ static void XIMPreEditDrawCallback(XIM ic, XPointer client_data,
         }
         else
             X11DRV_ImmSetInternalString (GCS_COMPSTR, sel, len, NULL, 0);
+        IME_SetCursorPos(P_DR->caret);
     }
     TRACE("Finished\n");
 }
@@ -311,8 +309,7 @@ static void XIMPreEditCaretCallback(XIC ic, XPointer client_data,
                 FIXME("Not implemented\n");
                 break;
         }
-        IME_SendMessageToSelectedHWND( EM_SETSEL, dwPreeditPos + pos,
-                     dwPreeditPos + pos);
+        IME_SetCursorPos(pos);
         P_C->position = pos;
     }
     TRACE("Finished\n");




More information about the wine-cvs mailing list