Aric Stewart : imm32: Keep track of context associations between HWND and HIMC.
Alexandre Julliard
julliard at winehq.org
Wed Apr 2 16:36:20 CDT 2008
Module: wine
Branch: master
Commit: dd0c9300f99a9cc4a2ce1178a6fa7e40afe2dc8f
URL: http://source.winehq.org/git/wine.git/?a=commit;h=dd0c9300f99a9cc4a2ce1178a6fa7e40afe2dc8f
Author: Aric Stewart <aric at codeweavers.com>
Date: Wed Apr 2 08:48:22 2008 -0500
imm32: Keep track of context associations between HWND and HIMC.
---
dlls/imm32/imm.c | 55 ++++++++++++++++++++++++++++++++++++++++-------------
1 files changed, 41 insertions(+), 14 deletions(-)
diff --git a/dlls/imm32/imm.c b/dlls/imm32/imm.c
index ab57bce..4ba1d63 100644
--- a/dlls/imm32/imm.c
+++ b/dlls/imm32/imm.c
@@ -110,6 +110,7 @@ static UINT WM_MSIME_RECONVERT;
static UINT WM_MSIME_QUERYPOSITION;
static UINT WM_MSIME_DOCUMENTFEED;
+static const WCHAR szwWineIMCProperty[] = {'W','i','n','e','I','m','m','H','I','M','C','P','r','o','p','e','r','t','y',0};
/*
* prototypes
*/
@@ -623,12 +624,10 @@ static HIMCC updateResultStr(HIMCC old, LPWSTR resultstr, DWORD len)
*/
HIMC WINAPI ImmAssociateContext(HWND hWnd, HIMC hIMC)
{
+ HIMC old = NULL;
InputContextData *data = (InputContextData*)hIMC;
- WARN("(%p, %p): semi-stub\n", hWnd, hIMC);
-
- if (!hIMC)
- return NULL;
+ TRACE("(%p, %p):\n", hWnd, hIMC);
/*
* WINE SPECIFIC! MAY CONFLICT
@@ -642,9 +641,30 @@ HIMC WINAPI ImmAssociateContext(HWND hWnd, HIMC hIMC)
/*
* If already associated just return
*/
- if (data->IMC.hWnd == hWnd)
+ if (hIMC && data->IMC.hWnd == hWnd)
return hIMC;
+ if (hWnd)
+ {
+ old = (HIMC)RemovePropW(hWnd,szwWineIMCProperty);
+
+ if (old == NULL)
+ old = (HIMC)root_context;
+ else if (old == (HIMC)-1)
+ old = NULL;
+
+ if (hIMC != (HIMC)root_context)
+ {
+ if (hIMC == NULL) /* Meaning disable imm for that window*/
+ SetPropW(hWnd,szwWineIMCProperty,(HANDLE)-1);
+ else
+ SetPropW(hWnd,szwWineIMCProperty,(HANDLE)hIMC);
+ }
+ }
+
+ if (!hIMC)
+ return old;
+
if (IsWindow(data->IMC.hWnd))
{
/*
@@ -663,11 +683,7 @@ HIMC WINAPI ImmAssociateContext(HWND hWnd, HIMC hIMC)
SendMessageW(data->IMC.hWnd, WM_IME_SETCONTEXT, TRUE, ISC_SHOWUIALL);
}
- /*
- * TODO: We need to keep track of the old context associated
- * with a window and return it for now we will return NULL;
- */
- return NULL;
+ return old;
}
/***********************************************************************
@@ -1176,13 +1192,24 @@ BOOL WINAPI ImmGetCompositionWindow(HIMC hIMC, LPCOMPOSITIONFORM lpCompForm)
*/
HIMC WINAPI ImmGetContext(HWND hWnd)
{
+ HIMC rc = NULL;
+
TRACE("%p\n", hWnd);
- if (!root_context)
- return NULL;
+ rc = (HIMC)GetPropW(hWnd,szwWineIMCProperty);
+ if (rc == (HIMC)-1)
+ rc = NULL;
+ else if (rc == NULL)
+ rc = (HIMC)root_context;
+
+ if (rc)
+ {
+ InputContextData *data = (InputContextData*)rc;
+ data->IMC.hWnd = hWnd;
+ }
+ TRACE("returning %p\n", rc);
- root_context->IMC.hWnd = hWnd;
- return (HIMC)root_context;
+ return rc;
}
/***********************************************************************
More information about the wine-cvs
mailing list