Piotr Caban : imm32: Only call ImmSetActiveContext for active window in ImmAssociateContext.
Alexandre Julliard
julliard at winehq.org
Fri Oct 15 15:40:06 CDT 2021
Module: wine
Branch: master
Commit: 01e072bb68166c235bfda20874b0fc0065a25e62
URL: https://source.winehq.org/git/wine.git/?a=commit;h=01e072bb68166c235bfda20874b0fc0065a25e62
Author: Piotr Caban <piotr at codeweavers.com>
Date: Fri Oct 15 15:27:10 2021 +0200
imm32: Only call ImmSetActiveContext for active window in ImmAssociateContext.
Signed-off-by: Piotr Caban <piotr at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/imm32/imm.c | 14 ++++++--------
dlls/imm32/tests/imm32.c | 13 +++++++++++--
2 files changed, 17 insertions(+), 10 deletions(-)
diff --git a/dlls/imm32/imm.c b/dlls/imm32/imm.c
index 790afc34adc..eea8cdb055e 100644
--- a/dlls/imm32/imm.c
+++ b/dlls/imm32/imm.c
@@ -592,12 +592,6 @@ HIMC WINAPI ImmAssociateContext(HWND hWnd, HIMC hIMC)
if (!IsWindow(hWnd) || (hIMC && !data))
return NULL;
- /*
- * If already associated just return
- */
- if (hIMC && data->IMC.hWnd == hWnd)
- return hIMC;
-
if (hIMC && IMM_IsCrossThreadAccess(hWnd, hIMC))
return NULL;
@@ -608,6 +602,7 @@ HIMC WINAPI ImmAssociateContext(HWND hWnd, HIMC hIMC)
else if (old == (HIMC)-1)
old = NULL;
+ /* If already associated just return */
if (old == hIMC)
return hIMC;
@@ -618,8 +613,11 @@ HIMC WINAPI ImmAssociateContext(HWND hWnd, HIMC hIMC)
else
SetPropW(hWnd, szwWineIMCProperty, hIMC);
- ImmSetActiveContext(hWnd, old, FALSE);
- ImmSetActiveContext(hWnd, hIMC, TRUE);
+ if (GetActiveWindow() == hWnd)
+ {
+ ImmSetActiveContext(hWnd, old, FALSE);
+ ImmSetActiveContext(hWnd, hIMC, TRUE);
+ }
return old;
}
diff --git a/dlls/imm32/tests/imm32.c b/dlls/imm32/tests/imm32.c
index 77df36b8e38..f837e3da61b 100644
--- a/dlls/imm32/tests/imm32.c
+++ b/dlls/imm32/tests/imm32.c
@@ -662,6 +662,7 @@ static void test_ImmAssociateContextEx(void)
if (imc)
{
HIMC retimc, newimc;
+ HWND focus;
SET_ENABLE(WM_IME_SETCONTEXT_ACTIVATE, TRUE);
SET_ENABLE(WM_IME_SETCONTEXT_DEACTIVATE, TRUE);
@@ -703,11 +704,19 @@ static void test_ImmAssociateContextEx(void)
ok(retimc == newimc, "handles should be the same\n");
ImmReleaseContext(hwnd,retimc);
+ focus = CreateWindowA("button", "button", 0, 0, 0, 0, 0, 0, 0, 0, 0);
+ ok(focus != NULL, "CreateWindow failed\n");
SET_EXPECT(WM_IME_SETCONTEXT_DEACTIVATE);
+ SetFocus(focus);
+ todo_wine CHECK_CALLED(WM_IME_SETCONTEXT_DEACTIVATE);
+ rc = pImmAssociateContextEx(hwnd, imc, 0);
+ ok(rc, "ImmAssociateContextEx failed\n");
SET_EXPECT(WM_IME_SETCONTEXT_ACTIVATE);
+ DestroyWindow(focus);
+ todo_wine CHECK_CALLED(WM_IME_SETCONTEXT_ACTIVATE);
+ SetFocus(hwnd);
+
rc = pImmAssociateContextEx(hwnd, NULL, IACE_DEFAULT);
- CHECK_CALLED(WM_IME_SETCONTEXT_DEACTIVATE);
- CHECK_CALLED(WM_IME_SETCONTEXT_ACTIVATE);
ok(rc, "ImmAssociateContextEx failed\n");
SET_ENABLE(WM_IME_SETCONTEXT_ACTIVATE, FALSE);
More information about the wine-cvs
mailing list