 
            Overwriting ctx->hWnd with the current focus window breaks the relationship between the HIMC handle and its associated window. This direct assignment does not update the corresponding state in the wine server, leading to inconsistencies between client and server.
Signed-off-by: chenzhengyong chenzhengyong@uniontech.com
-- v7: imm32: Do not overwrite input context window with GetFocus() in ime_ui_update_window.
 
            From: chenzhengyong chenzhengyong@uniontech.com
Overwriting ctx->hWnd with the current focus window breaks the relationship between the HIMC handle and its associated window. This direct assignment does not update the corresponding state in the wine server, leading to inconsistencies between client and server.
Signed-off-by: chenzhengyong chenzhengyong@uniontech.com --- dlls/imm32/ime.c | 2 -- 1 file changed, 2 deletions(-)
diff --git a/dlls/imm32/ime.c b/dlls/imm32/ime.c index 1487c847e00..65f46f20550 100644 --- a/dlls/imm32/ime.c +++ b/dlls/imm32/ime.c @@ -327,8 +327,6 @@ static void ime_ui_update_window( INPUTCONTEXT *ctx, HWND hwnd ) RedrawWindow( hwnd, NULL, NULL, RDW_ERASENOW | RDW_INVALIDATE ); } free( str ); - - ctx->hWnd = GetFocus(); }
static void ime_ui_composition( HIMC himc, HWND hwnd, LPARAM lparam )
 
            In Wine’s **IMM32** implementation, `ctx->hWnd` should be properly set in the `ImmSetActiveContext` function to maintain the correct association between the **input method context (IMC)** and the specific window. (refer dlls/imm32/imm.c:831
When `ime_ui_update_window` directly modifies `ctx->hWnd` to the handle returned by `GetFocus()`, the following issues occur:
1. If the current focus window differs from the originally associated window, the IMC–window mapping becomes invalid. 2. Querying the IMC using the window handle will return an incorrect **INPUTCONTEXT**.
### suggest:
**Simply remove the line `ctx->hWnd = GetFocus();` from the `ime_ui_update_window` function.**
Removing this line is safe because the `ime_ui_paint` function already includes proper fallback logic: dlls/imm32/ime.c:257-258
This fallback logic uses `GetFocus()` only when `ctx->hWnd` is `NULL`, ensuring correct handling when the window handle is missing, without breaking the IMC–window mapping.
The core of this issue lies in the fact that the `hWnd` field of **INPUTCONTEXT** should retain the value set by `ImmSetActiveContext` to maintain the correct relationship between the IMC and its associated window.\ Any direct modification of this field elsewhere may corrupt that relationship.
 
            This merge request was approved by Rémi Bernon.


