Dylan Smith : richedit: Store mouse captured state rather than calling GetCapture.

Alexandre Julliard julliard at winehq.org
Mon Jan 12 10:41:18 CST 2009


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

Author: Dylan Smith <dylan.ah.smith at gmail.com>
Date:   Sun Jan 11 02:59:20 2009 -0500

richedit: Store mouse captured state rather than calling GetCapture.

Windowless richedit control will not be able to call GetCapture without
a handle to the host window (and there is no ITextHost_TxGetCapture
method), but there is a ITextHost_TxSetCapture method available for
setting and releasing the capture on the mouse.  This means that the
richedit control will need to keep track of whether it has captured the
mouse or not to implement windowless richedit controls.

---

 dlls/riched20/editor.c  |   12 ++++++++----
 dlls/riched20/editstr.h |    2 ++
 2 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/dlls/riched20/editor.c b/dlls/riched20/editor.c
index 47e50b3..d4f60e4 100644
--- a/dlls/riched20/editor.c
+++ b/dlls/riched20/editor.c
@@ -2530,7 +2530,7 @@ static BOOL ME_SetCursor(ME_TextEditor *editor)
   }
   ScreenToClient(editor->hWnd, &pt);
 
-  if (editor->nSelectionType == stLine && GetCapture() == editor->hWnd) {
+  if (editor->nSelectionType == stLine && editor->bMouseCaptured) {
       SetCursor(hLeft);
       return TRUE;
   }
@@ -2670,6 +2670,7 @@ ME_TextEditor *ME_MakeEditor(HWND hWnd, BOOL bEmulateVersion10)
   ed->mode = TM_RICHTEXT | TM_MULTILEVELUNDO | TM_MULTICODEPAGE;
   ed->AutoURLDetect_bEnable = FALSE;
   ed->bHaveFocus = FALSE;
+  ed->bMouseCaptured = FALSE;
   for (i=0; i<HFONT_CACHE_SIZE; i++)
   {
     ed->pFontCache[i].nRefs = 0;
@@ -3874,6 +3875,7 @@ LRESULT ME_HandleMessage(ME_TextEditor *editor, UINT msg, WPARAM wParam,
     ME_LButtonDown(editor, (short)LOWORD(lParam), (short)HIWORD(lParam),
                    ME_CalculateClickCount(editor, msg, wParam, lParam));
     SetCapture(editor->hWnd);
+    editor->bMouseCaptured = TRUE;
     ME_LinkNotify(editor,msg,wParam,lParam);
     if (!ME_SetCursor(editor)) goto do_default;
     break;
@@ -3882,16 +3884,18 @@ LRESULT ME_HandleMessage(ME_TextEditor *editor, UINT msg, WPARAM wParam,
     if ((editor->nEventMask & ENM_MOUSEEVENTS) &&
         !ME_FilterEvent(editor, msg, &wParam, &lParam))
       return 0;
-    if (GetCapture() == editor->hWnd)
+    if (editor->bMouseCaptured)
       ME_MouseMove(editor, (short)LOWORD(lParam), (short)HIWORD(lParam));
     ME_LinkNotify(editor,msg,wParam,lParam);
     /* Set cursor if mouse is captured, since WM_SETCURSOR won't be received. */
-    if (GetCapture() == editor->hWnd)
+    if (editor->bMouseCaptured)
         ME_SetCursor(editor);
     break;
   case WM_LBUTTONUP:
-    if (GetCapture() == editor->hWnd)
+    if (editor->bMouseCaptured) {
       ReleaseCapture();
+      editor->bMouseCaptured = FALSE;
+    }
     if (editor->nSelectionType == stDocument)
       editor->nSelectionType = stPosition;
     if ((editor->nEventMask & ENM_MOUSEEVENTS) &&
diff --git a/dlls/riched20/editstr.h b/dlls/riched20/editstr.h
index cde05f9..6850ca7 100644
--- a/dlls/riched20/editstr.h
+++ b/dlls/riched20/editstr.h
@@ -376,6 +376,8 @@ typedef struct tagME_TextEditor
 
   /* Cache previously set vertical scrollbar info */
   SCROLLINFO vert_si;
+
+  BOOL bMouseCaptured;
 } ME_TextEditor;
 
 typedef struct tagME_Context




More information about the wine-cvs mailing list