From d293b3fc98b105122366cdf956fd1278dc2bca17 Mon Sep 17 00:00:00 2001 From: Dylan Smith Date: Wed, 9 Jul 2008 09:36:00 -0400 Subject: [PATCH] richedit: Prevented cursor flicker while moving over selection bar. When the cursor is moved over the selection bar, without holding any mouse buttons down, the cursor would be repeatably set between the normal cursor, set by DefWindowProc for the WM_SETCURSOR message, and the reversed cursor, set by ME_MouseMove. --- dlls/riched20/editor.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/dlls/riched20/editor.c b/dlls/riched20/editor.c index 35e4be1f828..b9883727b69 100644 --- a/dlls/riched20/editor.c +++ b/dlls/riched20/editor.c @@ -1666,10 +1666,15 @@ static int ME_CalculateClickCount(HWND hWnd, UINT msg, WPARAM wParam, return clickNum; } -static BOOL ME_SetCursor(ME_TextEditor *editor, int x) +static BOOL ME_SetCursor(ME_TextEditor *editor) { + POINT pt; + DWORD messagePos = GetMessagePos(); + pt.x = (short)LOWORD(messagePos); + pt.y = (short)HIWORD(messagePos); + ScreenToClient(editor->hWnd, &pt); if ((GetWindowLongW(editor->hWnd, GWL_STYLE) & ES_SELECTIONBAR) && - (x < editor->selofs || + (pt.x < editor->selofs || (editor->nSelectionType == stLine && GetCapture() == editor->hWnd))) { SetCursor(hLeft); @@ -3033,6 +3038,11 @@ static LRESULT RichEditWndProc_common(HWND hWnd, UINT msg, WPARAM wParam, ME_DestroyEditor(editor); SetWindowLongPtrW(hWnd, 0, 0); return 0; + case WM_SETCURSOR: + { + if (!ME_SetCursor(editor)) goto do_default; + return TRUE; + } case WM_LBUTTONDBLCLK: case WM_LBUTTONDOWN: { @@ -3045,7 +3055,6 @@ static LRESULT RichEditWndProc_common(HWND hWnd, UINT msg, WPARAM wParam, ME_CalculateClickCount(hWnd, msg, wParam, lParam)); SetCapture(hWnd); ME_LinkNotify(editor,msg,wParam,lParam); - if (!ME_SetCursor(editor, LOWORD(lParam))) goto do_default; break; } case WM_MOUSEMOVE: @@ -3055,7 +3064,6 @@ static LRESULT RichEditWndProc_common(HWND hWnd, UINT msg, WPARAM wParam, if (GetCapture() == hWnd) ME_MouseMove(editor, (short)LOWORD(lParam), (short)HIWORD(lParam)); ME_LinkNotify(editor,msg,wParam,lParam); - if (!ME_SetCursor(editor, LOWORD(lParam))) goto do_default; break; case WM_LBUTTONUP: if (GetCapture() == hWnd) @@ -3068,7 +3076,7 @@ static LRESULT RichEditWndProc_common(HWND hWnd, UINT msg, WPARAM wParam, else { BOOL ret; - ret = ME_SetCursor(editor, LOWORD(lParam)); + ret = ME_SetCursor(editor); ME_LinkNotify(editor,msg,wParam,lParam); if (!ret) goto do_default; }