Huw Davies : riched20: Don't mess with the caret if we don't have focus.

Alexandre Julliard julliard at wine.codeweavers.com
Wed Jun 6 07:41:52 CDT 2007


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

Author: Huw Davies <huw at codeweavers.com>
Date:   Tue Jun  5 13:56:55 2007 +0100

riched20: Don't mess with the caret if we don't have focus.

---

 dlls/riched20/caret.c   |   17 ++++++++++++-----
 dlls/riched20/editor.c  |    3 +++
 dlls/riched20/editstr.h |    1 +
 3 files changed, 16 insertions(+), 5 deletions(-)

diff --git a/dlls/riched20/caret.c b/dlls/riched20/caret.c
index 5f3259e..f2ca595 100644
--- a/dlls/riched20/caret.c
+++ b/dlls/riched20/caret.c
@@ -232,21 +232,28 @@ ME_MoveCaret(ME_TextEditor *editor)
 
   ME_WrapMarkedParagraphs(editor);
   ME_GetCursorCoordinates(editor, &editor->pCursors[0], &x, &y, &height);
-  CreateCaret(editor->hWnd, NULL, 0, height);
-  SetCaretPos(x, y);
+  if(editor->bHaveFocus)
+  {
+    CreateCaret(editor->hWnd, NULL, 0, height);
+    SetCaretPos(x, y);
+  }
 }
 
 
 void ME_ShowCaret(ME_TextEditor *ed)
 {
   ME_MoveCaret(ed);
-  ShowCaret(ed->hWnd);
+  if(ed->bHaveFocus)
+    ShowCaret(ed->hWnd);
 }
 
 void ME_HideCaret(ME_TextEditor *ed)
 {
-  HideCaret(ed->hWnd);
-  DestroyCaret();
+  if(ed->bHaveFocus)
+  {
+    HideCaret(ed->hWnd);
+    DestroyCaret();
+  }
 }
 
 void ME_InternalDeleteText(ME_TextEditor *editor, int nOfs, 
diff --git a/dlls/riched20/editor.c b/dlls/riched20/editor.c
index 24febcf..480b5d3 100644
--- a/dlls/riched20/editor.c
+++ b/dlls/riched20/editor.c
@@ -1153,6 +1153,7 @@ ME_TextEditor *ME_MakeEditor(HWND hWnd) {
   ed->lpOleCallback = NULL;
   ed->mode = TM_RICHTEXT | TM_MULTILEVELUNDO | TM_MULTICODEPAGE;
   ed->AutoURLDetect_bEnable = FALSE;
+  ed->bHaveFocus = FALSE;
   GetClientRect(hWnd, &ed->rcFormat);
   for (i=0; i<HFONT_CACHE_SIZE; i++)
   {
@@ -2335,11 +2336,13 @@ static LRESULT RichEditWndProc_common(HWND hWnd, UINT msg, WPARAM wParam,
     }
     break;
   case WM_SETFOCUS:
+    editor->bHaveFocus = TRUE;
     ME_ShowCaret(editor);
     ME_SendOldNotify(editor, EN_SETFOCUS);
     return 0;
   case WM_KILLFOCUS:
     ME_HideCaret(editor);
+    editor->bHaveFocus = FALSE;
     ME_SendOldNotify(editor, EN_KILLFOCUS);
     return 0;
   case WM_ERASEBKGND:
diff --git a/dlls/riched20/editstr.h b/dlls/riched20/editstr.h
index 9859fe7..ee5dfe3 100644
--- a/dlls/riched20/editstr.h
+++ b/dlls/riched20/editstr.h
@@ -321,6 +321,7 @@ typedef struct tagME_TextEditor
   BOOL bHideSelection;
   BOOL AutoURLDetect_bEnable;
   WCHAR cPasswordMask;
+  BOOL bHaveFocus;
 } ME_TextEditor;
 
 typedef struct tagME_Context




More information about the wine-cvs mailing list