msctf: TfContext intitalization and uninitialization on Push and Pop.

This commit is contained in:
Aric Stewart 2009-05-15 14:09:58 -05:00 committed by Alexandre Julliard
parent f61855ae22
commit 7d4e133624
3 changed files with 39 additions and 7 deletions

View File

@ -66,6 +66,7 @@ typedef struct tagContext {
/* const ITfQueryEmbeddedVtbl *QueryEmbeddedVtbl; */
/* const ITfSourceSingleVtbl *SourceSingleVtbl; */
LONG refCount;
BOOL connected;
TfClientId tidOwner;
@ -446,16 +447,12 @@ HRESULT Context_Constructor(TfClientId tidOwner, IUnknown *punk, ITfContext **pp
This->SourceVtbl = &Context_SourceVtbl;
This->refCount = 1;
This->tidOwner = tidOwner;
This->connected = FALSE;
if (punk)
{
if (SUCCEEDED(IUnknown_QueryInterface(punk, &IID_ITextStoreACP,
(LPVOID*)&This->pITextStoreACP)))
{
if (SUCCEEDED(TextStoreACPSink_Constructor(&This->pITextStoreACPSink, This)))
ITextStoreACP_AdviseSink(This->pITextStoreACP, &IID_ITextStoreACPSink,
(IUnknown*)This->pITextStoreACPSink, TS_AS_ALL_SINKS);
}
IUnknown_QueryInterface(punk, &IID_ITextStoreACP,
(LPVOID*)&This->pITextStoreACP);
IUnknown_QueryInterface(punk, &IID_ITfContextOwnerCompositionSink,
(LPVOID*)&This->pITfContextOwnerCompositionSink);
@ -478,6 +475,34 @@ HRESULT Context_Constructor(TfClientId tidOwner, IUnknown *punk, ITfContext **pp
return S_OK;
}
HRESULT Context_Initialize(ITfContext *iface)
{
Context *This = (Context *)iface;
if (This->pITextStoreACP)
{
if (SUCCEEDED(TextStoreACPSink_Constructor(&This->pITextStoreACPSink, This)))
ITextStoreACP_AdviseSink(This->pITextStoreACP, &IID_ITextStoreACPSink,
(IUnknown*)This->pITextStoreACPSink, TS_AS_ALL_SINKS);
}
This->connected = TRUE;
return S_OK;
}
HRESULT Context_Uninitialize(ITfContext *iface)
{
Context *This = (Context *)iface;
if (This->pITextStoreACPSink)
{
ITextStoreACP_UnadviseSink(This->pITextStoreACP, (IUnknown*)This->pITextStoreACPSink);
if (ITextStoreACPSink_Release(This->pITextStoreACPSink) == 0)
This->pITextStoreACPSink = NULL;
}
This->connected = FALSE;
return S_OK;
}
/**************************************************************************
* ITextStoreACPSink
**************************************************************************/

View File

@ -138,6 +138,7 @@ static HRESULT WINAPI DocumentMgr_Push(ITfDocumentMgr *iface, ITfContext *pic)
This->contextStack[0] = check;
ITfThreadMgrEventSink_OnPushContext(This->ThreadMgrSink,check);
Context_Initialize(check);
return S_OK;
}
@ -153,11 +154,13 @@ static HRESULT WINAPI DocumentMgr_Pop(ITfDocumentMgr *iface, DWORD dwFlags)
{
ITfThreadMgrEventSink_OnPopContext(This->ThreadMgrSink,This->contextStack[0]);
ITfContext_Release(This->contextStack[0]);
Context_Uninitialize(This->contextStack[0]);
}
if (This->contextStack[1])
{
ITfThreadMgrEventSink_OnPopContext(This->ThreadMgrSink,This->contextStack[1]);
ITfContext_Release(This->contextStack[1]);
Context_Uninitialize(This->contextStack[1]);
}
This->contextStack[0] = This->contextStack[1] = NULL;
ITfThreadMgrEventSink_OnUninitDocumentMgr(This->ThreadMgrSink, iface);
@ -172,6 +175,7 @@ static HRESULT WINAPI DocumentMgr_Pop(ITfDocumentMgr *iface, DWORD dwFlags)
ITfThreadMgrEventSink_OnPopContext(This->ThreadMgrSink,This->contextStack[0]);
ITfContext_Release(This->contextStack[0]);
Context_Uninitialize(This->contextStack[0]);
This->contextStack[0] = This->contextStack[1];
This->contextStack[1] = NULL;

View File

@ -35,6 +35,9 @@ extern HRESULT Context_Constructor(TfClientId tidOwner, IUnknown *punk, ITfConte
extern HRESULT InputProcessorProfiles_Constructor(IUnknown *pUnkOuter, IUnknown **ppOut);
extern HRESULT CategoryMgr_Constructor(IUnknown *pUnkOuter, IUnknown **ppOut);
extern HRESULT Context_Initialize(ITfContext *cxt);
extern HRESULT Context_Uninitialize(ITfContext *cxt);
/* cookie function */
extern DWORD generate_Cookie(DWORD magic, LPVOID data);
extern DWORD get_Cookie_magic(DWORD id);