Commit e6d53d63 authored by Piotr Caban's avatar Piotr Caban Committed by Alexandre Julliard

imm32: Use ImmSetActiveContext in ImmAssociateContext.

parent 266c1101
...@@ -601,35 +601,25 @@ HIMC WINAPI ImmAssociateContext(HWND hWnd, HIMC hIMC) ...@@ -601,35 +601,25 @@ HIMC WINAPI ImmAssociateContext(HWND hWnd, HIMC hIMC)
if (hIMC && IMM_IsCrossThreadAccess(hWnd, hIMC)) if (hIMC && IMM_IsCrossThreadAccess(hWnd, hIMC))
return NULL; return NULL;
old = GetPropW(hWnd, szwWineIMCProperty);
defaultContext = get_default_context( hWnd ); defaultContext = get_default_context( hWnd );
old = RemovePropW(hWnd, szwWineIMCProperty); if (!old)
if (old == NULL)
old = defaultContext; old = defaultContext;
else if (old == (HIMC)-1) else if (old == (HIMC)-1)
old = NULL; old = NULL;
if (hIMC != defaultContext) if (old == hIMC)
{ return hIMC;
if (hIMC == NULL) /* Meaning disable imm for that window*/
SetPropW(hWnd, szwWineIMCProperty, (HANDLE)-1);
else
SetPropW(hWnd, szwWineIMCProperty, hIMC);
}
if (old)
{
InputContextData *old_data = old;
if (old_data->IMC.hWnd == hWnd)
old_data->IMC.hWnd = NULL;
}
if (!hIMC)
return old;
SendMessageW(data->IMC.hWnd, WM_IME_SETCONTEXT, FALSE, ISC_SHOWUIALL); if (!hIMC) /* Meaning disable imm for that window*/
data->IMC.hWnd = hWnd; SetPropW(hWnd, szwWineIMCProperty, (HANDLE)-1);
SendMessageW(data->IMC.hWnd, WM_IME_SETCONTEXT, TRUE, ISC_SHOWUIALL); else if (hIMC == defaultContext)
RemovePropW(hWnd, szwWineIMCProperty);
else
SetPropW(hWnd, szwWineIMCProperty, hIMC);
ImmSetActiveContext(hWnd, old, FALSE);
ImmSetActiveContext(hWnd, hIMC, TRUE);
return old; return old;
} }
......
...@@ -663,29 +663,55 @@ static void test_ImmAssociateContextEx(void) ...@@ -663,29 +663,55 @@ static void test_ImmAssociateContextEx(void)
{ {
HIMC retimc, newimc; HIMC retimc, newimc;
SET_ENABLE(WM_IME_SETCONTEXT_ACTIVATE, TRUE);
SET_ENABLE(WM_IME_SETCONTEXT_DEACTIVATE, TRUE);
ok(GetActiveWindow() == hwnd, "hwnd is not active\n");
newimc = ImmCreateContext(); newimc = ImmCreateContext();
ok(newimc != imc, "handles should not be the same\n"); ok(newimc != imc, "handles should not be the same\n");
rc = pImmAssociateContextEx(NULL, NULL, 0); rc = pImmAssociateContextEx(NULL, NULL, 0);
ok(!rc, "ImmAssociateContextEx succeeded\n"); ok(!rc, "ImmAssociateContextEx succeeded\n");
SET_EXPECT(WM_IME_SETCONTEXT_DEACTIVATE);
SET_EXPECT(WM_IME_SETCONTEXT_ACTIVATE);
rc = pImmAssociateContextEx(hwnd, NULL, 0); rc = pImmAssociateContextEx(hwnd, NULL, 0);
CHECK_CALLED(WM_IME_SETCONTEXT_DEACTIVATE);
CHECK_CALLED(WM_IME_SETCONTEXT_ACTIVATE);
ok(rc, "ImmAssociateContextEx failed\n"); ok(rc, "ImmAssociateContextEx failed\n");
rc = pImmAssociateContextEx(NULL, imc, 0); rc = pImmAssociateContextEx(NULL, imc, 0);
ok(!rc, "ImmAssociateContextEx succeeded\n"); ok(!rc, "ImmAssociateContextEx succeeded\n");
SET_EXPECT(WM_IME_SETCONTEXT_DEACTIVATE);
SET_EXPECT(WM_IME_SETCONTEXT_ACTIVATE);
rc = pImmAssociateContextEx(hwnd, imc, 0); rc = pImmAssociateContextEx(hwnd, imc, 0);
CHECK_CALLED(WM_IME_SETCONTEXT_DEACTIVATE);
CHECK_CALLED(WM_IME_SETCONTEXT_ACTIVATE);
ok(rc, "ImmAssociateContextEx failed\n"); ok(rc, "ImmAssociateContextEx failed\n");
retimc = ImmGetContext(hwnd); retimc = ImmGetContext(hwnd);
ok(retimc == imc, "handles should be the same\n"); ok(retimc == imc, "handles should be the same\n");
ImmReleaseContext(hwnd,retimc); ImmReleaseContext(hwnd,retimc);
rc = pImmAssociateContextEx(hwnd, imc, 0);
ok(rc, "ImmAssociateContextEx failed\n");
SET_EXPECT(WM_IME_SETCONTEXT_DEACTIVATE);
SET_EXPECT(WM_IME_SETCONTEXT_ACTIVATE);
rc = pImmAssociateContextEx(hwnd, newimc, 0); rc = pImmAssociateContextEx(hwnd, newimc, 0);
CHECK_CALLED(WM_IME_SETCONTEXT_DEACTIVATE);
CHECK_CALLED(WM_IME_SETCONTEXT_ACTIVATE);
ok(rc, "ImmAssociateContextEx failed\n"); ok(rc, "ImmAssociateContextEx failed\n");
retimc = ImmGetContext(hwnd); retimc = ImmGetContext(hwnd);
ok(retimc == newimc, "handles should be the same\n"); ok(retimc == newimc, "handles should be the same\n");
ImmReleaseContext(hwnd,retimc); ImmReleaseContext(hwnd,retimc);
SET_EXPECT(WM_IME_SETCONTEXT_DEACTIVATE);
SET_EXPECT(WM_IME_SETCONTEXT_ACTIVATE);
rc = pImmAssociateContextEx(hwnd, NULL, IACE_DEFAULT); rc = pImmAssociateContextEx(hwnd, NULL, IACE_DEFAULT);
CHECK_CALLED(WM_IME_SETCONTEXT_DEACTIVATE);
CHECK_CALLED(WM_IME_SETCONTEXT_ACTIVATE);
ok(rc, "ImmAssociateContextEx failed\n"); ok(rc, "ImmAssociateContextEx failed\n");
SET_ENABLE(WM_IME_SETCONTEXT_ACTIVATE, FALSE);
SET_ENABLE(WM_IME_SETCONTEXT_DEACTIVATE, FALSE);
} }
ImmReleaseContext(hwnd,imc); ImmReleaseContext(hwnd,imc);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment