winemac.drv: Improve positioning of IME client window based on caret

Ken Thomases ken at codeweavers.com
Wed Feb 19 09:32:36 CST 2014


On Feb 19, 2014, at 3:08 AM, Aric Stewart wrote:

> diff --git a/dlls/winemac.drv/ime.c b/dlls/winemac.drv/ime.c
> index 2c74f6e..066c77a 100644
> --- a/dlls/winemac.drv/ime.c
> +++ b/dlls/winemac.drv/ime.c
> @@ -1585,14 +1585,20 @@ BOOL query_ime_char_rect(macdrv_query* query)
>          if (focus && (focus == hwnd || IsChild(hwnd, focus)) &&
>              GetClientRect(focus, &charpos.rcDocument))
>          {
> +            HDC hdc = GetDC(focus);
> +            TEXTMETRICA tm;
> +
>              if (!GetCaretPos((POINT*)&charpos.rcDocument))
>                  charpos.rcDocument.left = charpos.rcDocument.top = 0;
>  
> +            GetTextMetricsA(hdc, &tm);
>              charpos.rcDocument.right = charpos.rcDocument.left + 1;
> +            charpos.rcDocument.bottom = charpos.rcDocument.top + tm.tmHeight;
>              MapWindowPoints(focus, 0, (POINT*)&charpos.rcDocument, 2);
>  
>              *rect = cgrect_from_rect(charpos.rcDocument);
>              ret = TRUE;
> +            ReleaseDC(focus, hdc);
>          }
>      }

I don't think this does what you want.  GetDC() typically returns a DC whose parameters were reset.  It doesn't know what font has previously been used in the window.  So, you're basically getting the metrics for the System font.  I suppose that may be better than nothing.

Also, you don't check if GetTextMetricsA() succeeded.


Perhaps using GetGUIThreadInfo() and the rcCaret field of the GUITHREADINFO structure would be better than using GetCaretPos().  In that case, you'd map the coordinates from hwndCaret (which may be different from "focus") to the screen.  Be sure to read the remarks in the MSDN docs for the GetGUIThreadInfo() function about how to use rcCaret, although it's not clear to me if Wine implements this faithfully.

-Ken




More information about the wine-devel mailing list