[PATCH] Added implementation for ImmReleaseContext

Daniel Rammelt drammelt at orcon.net.nz
Fri Dec 15 21:20:15 CST 2006


---
 dlls/imm32/imm.c |   84
++++++++++++++++++++++++++++++++++++++++++++++++++----
 1 files changed, 77 insertions(+), 7 deletions(-)

diff --git a/dlls/imm32/imm.c b/dlls/imm32/imm.c
index bee6472..b9c322e 100644
--- a/dlls/imm32/imm.c
+++ b/dlls/imm32/imm.c
@@ -56,6 +56,16 @@ typedef struct tagInputContextData
         COMPOSITIONFORM CompForm;
 } InputContextData;
 
+typedef struct trackContextList
+{
+    HWND            hwnd;
+    HIMC            *himc;
+    struct trackContextList    *next;
+    struct trackContextList    *prev;
+} ContextList;
+
+static ContextList *first_context = NULL;
+static ContextList *last_context = NULL;
 static InputContextData *root_context = NULL;
 static HWND hwndDefault = NULL;
 static HANDLE hImeInst;
@@ -79,6 +89,58 @@ static void UpdateDataInDefaultIMEWindow
 static void ImmInternalPostIMEMessage(UINT, WPARAM, LPARAM);
 static void ImmInternalSetOpenStatus(BOOL fOpen);
 
+HIMC WINAPI LookUpContext (HWND hWND, ContextList *fContext)
+{
+    static ContextList *current_context = NULL;
+    current_context = fContext;
+    while (current_context) {
+        if (current_context->hwnd == hWND)
+            return current_context->himc;    
+        current_context = current_context->next;
+    }
+    return NULL;
+}
+
+
+static void AddContextLookUp(HWND hWND, HIMC hIMC)
+{
+    ContextList *new;
+    new = (ContextList *)malloc(sizeof(ContextList));
+    new->hwnd = hWND;
+    *new->himc = hIMC;
+    new->next = NULL;
+    if (!first_context)
+        first_context = new;
+    new->prev = last_context;
+    last_context->next = new;
+    last_context = new;
+}
+
+
+static void DestroyAssociations(HWND hWND)
+{
+    ContextList *current_context = first_context;
+    ContextList *temp_context = NULL;
+    InputContextData *data = NULL;
+    while (current_context) {        
+    current_context = LookUpContext (hWND, current_context);
+     data = (InputContextData*)current_context->himc;
+    data->hwnd=NULL;
+    data=NULL;
+    current_context->prev->next=current_context->next;
+    current_context->next->prev=current_context->prev;
+    temp_context=current_context;
+    current_context=current_context->next;
+    ImmDestroyContext(temp_context->himc);
+    temp_context->next=NULL;
+    temp_context->prev=NULL;
+    temp_context->hwnd=NULL;
+    temp_context->himc=NULL;
+    temp_context=NULL;
+    }   
+}
+
+
 static VOID IMM_PostResult(InputContextData *data)
 {
     unsigned int i;
@@ -207,12 +269,14 @@ static void ImmInternalSetOpenStatus(BOO
  */
 HIMC WINAPI ImmAssociateContext(HWND hWnd, HIMC hIMC)
 {
-    InputContextData *data = (InputContextData*)hIMC;
+    InputContextData *data = (InputContextData*)hIMC;
 
     WARN("(%p, %p): semi-stub\n", hWnd, hIMC);
 
-    if (!hIMC)
-        return NULL;
+    if (!hIMC) {
+    DestroyAssociations (hWnd);
+      return NULL;
+    }
 
     /*
      * WINE SPECIFIC! MAY CONFLICT
@@ -244,6 +308,7 @@ HIMC WINAPI ImmAssociateContext(HWND hWn
         /*
          * Post a message that your context is switching
          */
+    AddContextLookUp(hWnd, hIMC);
         SendMessageW(data->hwnd, WM_IME_SETCONTEXT, TRUE, ISC_SHOWUIALL);
     }
 
@@ -251,7 +316,7 @@ HIMC WINAPI ImmAssociateContext(HWND hWn
      * 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 LookUpContext(hWnd, first_context);
 }
 
 /***********************************************************************
@@ -1178,9 +1243,14 @@ BOOL WINAPI ImmRegisterWordW(
  */
 BOOL WINAPI ImmReleaseContext(HWND hWnd, HIMC hIMC)
 {
-  FIXME("(%p, %p): stub\n", hWnd, hIMC);
-
-    return TRUE;
+  if (hIMC) {
+    ImmAssociateContext (hWnd, NULL);      
+      return TRUE;
+  }
+  else
+  {
+    return FALSE;
+  }
 }
 
 /***********************************************************************
-- 
1.4.2.4




More information about the wine-patches mailing list