Aric Stewart : msctf: Beginning of TfEditCookie definition and usage.

Alexandre Julliard julliard at winehq.org
Thu May 21 09:35:51 CDT 2009


Module: wine
Branch: master
Commit: a5006e7eb4def547c24ab17c129605bc72b53e8f
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=a5006e7eb4def547c24ab17c129605bc72b53e8f

Author: Aric Stewart <aric at codeweavers.com>
Date:   Wed May 20 14:46:44 2009 -0500

msctf: Beginning of TfEditCookie definition and usage.

---

 dlls/msctf/context.c        |   33 +++++++++++++++++++++++++++++----
 dlls/msctf/msctf_internal.h |    1 +
 2 files changed, 30 insertions(+), 4 deletions(-)

diff --git a/dlls/msctf/context.c b/dlls/msctf/context.c
index 6f35def..297f611 100644
--- a/dlls/msctf/context.c
+++ b/dlls/msctf/context.c
@@ -69,6 +69,7 @@ typedef struct tagContext {
     BOOL connected;
 
     TfClientId tidOwner;
+    TfEditCookie defaultCookie;
 
     ITextStoreACP   *pITextStoreACP;
     ITfContextOwnerCompositionSink *pITfContextOwnerCompositionSink;
@@ -85,6 +86,10 @@ typedef struct tagContext {
 
 } Context;
 
+typedef struct tagEditCookie {
+    DWORD lockType;
+    Context *pOwningContext;
+} EditCookie;
 
 typedef struct tagTextStoreACPSink {
     const ITextStoreACPSinkVtbl *TextStoreACPSinkVtbl;
@@ -111,6 +116,7 @@ static void free_sink(ContextSink *sink)
 static void Context_Destructor(Context *This)
 {
     struct list *cursor, *cursor2;
+    EditCookie *cookie;
     TRACE("destroying %p\n", This);
 
     if (This->pITextStoreACPSink)
@@ -125,6 +131,13 @@ static void Context_Destructor(Context *This)
     if (This->pITfContextOwnerCompositionSink)
         ITextStoreACPSink_Release(This->pITfContextOwnerCompositionSink);
 
+    if (This->defaultCookie)
+    {
+        cookie = remove_Cookie(This->defaultCookie);
+        HeapFree(GetProcessHeap(),0,cookie);
+        This->defaultCookie = 0;
+    }
+
     LIST_FOR_EACH_SAFE(cursor, cursor2, &This->pContextKeyEventSink)
     {
         ContextSink* sink = LIST_ENTRY(cursor,ContextSink,entry);
@@ -481,11 +494,19 @@ static const ITfSourceVtbl Context_SourceVtbl =
 HRESULT Context_Constructor(TfClientId tidOwner, IUnknown *punk, ITfContext **ppOut, TfEditCookie *pecTextStore)
 {
     Context *This;
+    EditCookie *cookie;
 
     This = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(Context));
     if (This == NULL)
         return E_OUTOFMEMORY;
 
+    cookie = HeapAlloc(GetProcessHeap(),0,sizeof(EditCookie));
+    if (cookie == NULL)
+    {
+        HeapFree(GetProcessHeap(),0,This);
+        return E_OUTOFMEMORY;
+    }
+
     TRACE("(%p) %x %p %p %p\n",This, tidOwner, punk, ppOut, pecTextStore);
 
     This->ContextVtbl= &Context_ContextVtbl;
@@ -494,6 +515,9 @@ HRESULT Context_Constructor(TfClientId tidOwner, IUnknown *punk, ITfContext **pp
     This->tidOwner = tidOwner;
     This->connected = FALSE;
 
+    cookie->lockType = TF_ES_READ;
+    cookie->pOwningContext = This;
+
     if (punk)
     {
         IUnknown_QueryInterface(punk, &IID_ITextStoreACP,
@@ -506,10 +530,8 @@ HRESULT Context_Constructor(TfClientId tidOwner, IUnknown *punk, ITfContext **pp
             FIXME("Unhandled pUnk\n");
     }
 
-    TRACE("returning %p\n", This);
-    *ppOut = (ITfContext*)This;
-    /* FIXME */
-    *pecTextStore = 0xdeaddead;
+    This->defaultCookie = generate_Cookie(COOKIE_MAGIC_EDITCOOKIE,cookie);
+    *pecTextStore = This->defaultCookie;
 
     list_init(&This->pContextKeyEventSink);
     list_init(&This->pEditTransactionSink);
@@ -517,6 +539,9 @@ HRESULT Context_Constructor(TfClientId tidOwner, IUnknown *punk, ITfContext **pp
     list_init(&This->pTextEditSink);
     list_init(&This->pTextLayoutSink);
 
+    *ppOut = (ITfContext*)This;
+    TRACE("returning %p\n", This);
+
     return S_OK;
 }
 
diff --git a/dlls/msctf/msctf_internal.h b/dlls/msctf/msctf_internal.h
index 7e0fd1e..9181b8c 100644
--- a/dlls/msctf/msctf_internal.h
+++ b/dlls/msctf/msctf_internal.h
@@ -25,6 +25,7 @@
 #define COOKIE_MAGIC_CONTEXTSINK 0x0020
 #define COOKIE_MAGIC_GUIDATOM 0x0030
 #define COOKIE_MAGIC_IPPSINK 0x0040
+#define COOKIE_MAGIC_EDITCOOKIE 0x0050
 
 extern DWORD tlsIndex;
 extern TfClientId processId;




More information about the wine-cvs mailing list