(resend) imm32: there is only 1 default Hwnd per thread

Alexandre Julliard julliard at winehq.org
Wed Sep 26 07:27:14 CDT 2012


Aric Stewart <aric at codeweavers.com> writes:

> This corrects issues with applications that create and manage multiple IMCs
> try 2:
> avoid premature destruction of the window
> ---
>  dlls/imm32/imm.c         |   22 ++++++++++++----------
>  dlls/imm32/tests/imm32.c |   28 ++++++++++++++++++++++++++++
>  2 files changed, 40 insertions(+), 10 deletions(-)
>
>
>
> diff --git a/dlls/imm32/imm.c b/dlls/imm32/imm.c
> index 7394101..a18aa26 100644
> --- a/dlls/imm32/imm.c
> +++ b/dlls/imm32/imm.c
> @@ -678,10 +678,6 @@ static BOOL IMM_DestroyContext(HIMC hIMC)
>          data->immKbd->pImeSelect(hIMC, FALSE);
>          SendMessageW(data->IMC.hWnd, WM_IME_SELECT, FALSE, (LPARAM)GetKeyboardLayout(0));
>  
> -        if (IMM_GetThreadData()->hwndDefault == data->imeWnd)
> -            IMM_GetThreadData()->hwndDefault = NULL;
> -        DestroyWindow(data->imeWnd);
> -
>          ImmDestroyIMCC(data->IMC.hCompStr);
>          ImmDestroyIMCC(data->IMC.hCandInfo);
>          ImmDestroyIMCC(data->IMC.hGuideLine);
> @@ -2323,12 +2319,18 @@ BOOL WINAPI ImmSetOpenStatus(HIMC hIMC, BOOL fOpen)
>  
>      if (data->imeWnd == NULL)
>      {
> -        /* create the ime window */
> -        data->imeWnd = CreateWindowExW( WS_EX_TOOLWINDOW,
> -                    data->immKbd->imeClassName, NULL, WS_POPUP, 0, 0, 1, 1, 0,
> -                    0, data->immKbd->hIME, 0);
> -        SetWindowLongPtrW(data->imeWnd, IMMGWL_IMC, (LONG_PTR)data);
> -        IMM_GetThreadData()->hwndDefault = data->imeWnd;
> +        HWND def = IMM_GetThreadData()->hwndDefault;
> +        if (def == NULL)
> +        {
> +            /* create the ime window */
> +            data->imeWnd = CreateWindowExW( WS_EX_TOOLWINDOW,
> +                        data->immKbd->imeClassName, NULL, WS_POPUP, 0, 0, 1, 1, 0,
> +                        0, data->immKbd->hIME, 0);
> +            SetWindowLongPtrW(data->imeWnd, IMMGWL_IMC, (LONG_PTR)data);
> +            IMM_GetThreadData()->hwndDefault = data->imeWnd;
> +        }
> +        else
> +            data->imeWnd = def;

So why is there a window in the IMC at all, if it's not used for
anything?

-- 
Alexandre Julliard
julliard at winehq.org



More information about the wine-devel mailing list