[PATCH] comctl32: Dont set caret position if we dont have focus

Nikolay Sivov nsivov at codeweavers.com
Tue Dec 4 23:14:11 CST 2018


On 12/5/18 5:08 AM, Alistair Leslie-Hughes wrote:

> When SetFont is called on an Edit Control which doesn't have
> focus, it causes the current control to draw the caret in
> the incorrect location until a key is pressed.
>
> EDIT_SetCaretPos (es=0x204439c0, pos=0, after_wrap=0)
> 0x7eace3be in EDIT_AdjustFormatRect (es=0x204439c0)
> 0x7eace465 in EDIT_SetRectNP (es=0x204439c0, rc=<optimized out>)
> 0x7ead180c in EDIT_WM_SetFont (es=0x204439c0, font=<optimized out>, redraw=1)
>
> Signed-off-by: Alistair Leslie-Hughes <leslie_alistair at hotmail.com>
> ---
>   dlls/comctl32/edit.c | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/dlls/comctl32/edit.c b/dlls/comctl32/edit.c
> index 06e1f498dc9..3ffc2e5c16a 100644
> --- a/dlls/comctl32/edit.c
> +++ b/dlls/comctl32/edit.c
> @@ -2238,7 +2238,8 @@ static void EDIT_AdjustFormatRect(EDITSTATE *es)
>   	if ((es->style & ES_MULTILINE) && !(es->style & ES_AUTOHSCROLL))
>   		EDIT_BuildLineDefs_ML(es, 0, get_text_length(es), 0, NULL);
>   
> -	EDIT_SetCaretPos(es, es->selection_end, es->flags & EF_AFTER_WRAP);
> +    if (es->flags & EF_FOCUSED)
> +        EDIT_SetCaretPos(es, es->selection_end, es->flags & EF_AFTER_WRAP);
>   }
>   
>   

Does that mean EF_FOCUSED is inconsistent with actual window focus at 
this point?

Or instead:

- caret created by one Edit control;
- WM_SETFONT called for another;
- caret is moved unexpectedly, for first control?

In that case I think we should move flag check to EDIT_SetCaretPos().




More information about the wine-devel mailing list