2009-01-27 21:15:30 +01:00
|
|
|
/*
|
|
|
|
* ITfThreadMgr implementation
|
|
|
|
*
|
|
|
|
* Copyright 2008 Aric Stewart, CodeWeavers
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include <stdarg.h>
|
|
|
|
|
|
|
|
#define COBJMACROS
|
|
|
|
|
|
|
|
#include "wine/debug.h"
|
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
#include "winreg.h"
|
|
|
|
#include "winuser.h"
|
|
|
|
#include "shlwapi.h"
|
|
|
|
#include "winerror.h"
|
|
|
|
#include "objbase.h"
|
2009-03-24 14:21:39 +01:00
|
|
|
#include "olectl.h"
|
2009-01-27 21:15:30 +01:00
|
|
|
|
|
|
|
#include "wine/unicode.h"
|
2009-03-24 14:21:28 +01:00
|
|
|
#include "wine/list.h"
|
2009-01-27 21:15:30 +01:00
|
|
|
|
|
|
|
#include "msctf.h"
|
|
|
|
#include "msctf_internal.h"
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(msctf);
|
|
|
|
|
2009-03-24 14:21:28 +01:00
|
|
|
typedef struct tagThreadMgrSink {
|
|
|
|
struct list entry;
|
|
|
|
union {
|
|
|
|
/* ThreadMgr Sinks */
|
|
|
|
IUnknown *pIUnknown;
|
|
|
|
/* ITfActiveLanguageProfileNotifySink *pITfActiveLanguageProfileNotifySink; */
|
|
|
|
/* ITfDisplayAttributeNotifySink *pITfDisplayAttributeNotifySink; */
|
|
|
|
/* ITfKeyTraceEventSink *pITfKeyTraceEventSink; */
|
|
|
|
/* ITfPreservedKeyNotifySink *pITfPreservedKeyNotifySink; */
|
|
|
|
/* ITfThreadFocusSink *pITfThreadFocusSink; */
|
2009-03-24 14:21:39 +01:00
|
|
|
ITfThreadMgrEventSink *pITfThreadMgrEventSink;
|
2009-03-24 14:21:28 +01:00
|
|
|
} interfaces;
|
|
|
|
} ThreadMgrSink;
|
|
|
|
|
2009-01-27 21:15:30 +01:00
|
|
|
typedef struct tagACLMulti {
|
|
|
|
const ITfThreadMgrVtbl *ThreadMgrVtbl;
|
2009-02-02 17:25:49 +01:00
|
|
|
const ITfSourceVtbl *SourceVtbl;
|
2009-01-27 21:15:30 +01:00
|
|
|
LONG refCount;
|
2009-02-02 17:24:41 +01:00
|
|
|
|
2009-03-24 14:21:47 +01:00
|
|
|
const ITfThreadMgrEventSinkVtbl *ThreadMgrEventSinkVtbl; /* internal */
|
|
|
|
|
2009-02-02 17:24:41 +01:00
|
|
|
ITfDocumentMgr *focus;
|
2009-03-24 14:21:28 +01:00
|
|
|
|
|
|
|
/* kept as separate lists to reduce unnecessary iterations */
|
|
|
|
struct list ActiveLanguageProfileNotifySink;
|
|
|
|
struct list DisplayAttributeNotifySink;
|
|
|
|
struct list KeyTraceEventSink;
|
|
|
|
struct list PreservedKeyNotifySink;
|
|
|
|
struct list ThreadFocusSink;
|
|
|
|
struct list ThreadMgrEventSink;
|
2009-01-27 21:15:30 +01:00
|
|
|
} ThreadMgr;
|
|
|
|
|
2009-02-02 17:25:49 +01:00
|
|
|
static inline ThreadMgr *impl_from_ITfSourceVtbl(ITfSource *iface)
|
|
|
|
{
|
|
|
|
return (ThreadMgr *)((char *)iface - FIELD_OFFSET(ThreadMgr,SourceVtbl));
|
|
|
|
}
|
|
|
|
|
2009-03-24 14:21:47 +01:00
|
|
|
static inline ThreadMgr *impl_from_ITfThreadMgrEventSink(ITfThreadMgrEventSink *iface)
|
|
|
|
{
|
|
|
|
return (ThreadMgr *)((char *)iface - FIELD_OFFSET(ThreadMgr,ThreadMgrEventSinkVtbl));
|
|
|
|
}
|
|
|
|
|
2009-03-24 14:21:28 +01:00
|
|
|
static void free_sink(ThreadMgrSink *sink)
|
|
|
|
{
|
|
|
|
IUnknown_Release(sink->interfaces.pIUnknown);
|
|
|
|
HeapFree(GetProcessHeap(),0,sink);
|
|
|
|
}
|
|
|
|
|
2009-01-27 21:15:30 +01:00
|
|
|
static void ThreadMgr_Destructor(ThreadMgr *This)
|
|
|
|
{
|
2009-03-24 14:21:28 +01:00
|
|
|
struct list *cursor, *cursor2;
|
|
|
|
|
2009-02-02 17:24:47 +01:00
|
|
|
TlsSetValue(tlsIndex,NULL);
|
2009-01-27 21:15:30 +01:00
|
|
|
TRACE("destroying %p\n", This);
|
2009-02-02 17:24:41 +01:00
|
|
|
if (This->focus)
|
|
|
|
ITfDocumentMgr_Release(This->focus);
|
2009-03-24 14:21:28 +01:00
|
|
|
|
|
|
|
/* free sinks */
|
|
|
|
LIST_FOR_EACH_SAFE(cursor, cursor2, &This->ActiveLanguageProfileNotifySink)
|
|
|
|
{
|
|
|
|
ThreadMgrSink* sink = LIST_ENTRY(cursor,ThreadMgrSink,entry);
|
|
|
|
list_remove(cursor);
|
|
|
|
free_sink(sink);
|
|
|
|
}
|
|
|
|
LIST_FOR_EACH_SAFE(cursor, cursor2, &This->DisplayAttributeNotifySink)
|
|
|
|
{
|
|
|
|
ThreadMgrSink* sink = LIST_ENTRY(cursor,ThreadMgrSink,entry);
|
|
|
|
list_remove(cursor);
|
|
|
|
free_sink(sink);
|
|
|
|
}
|
|
|
|
LIST_FOR_EACH_SAFE(cursor, cursor2, &This->KeyTraceEventSink)
|
|
|
|
{
|
|
|
|
ThreadMgrSink* sink = LIST_ENTRY(cursor,ThreadMgrSink,entry);
|
|
|
|
list_remove(cursor);
|
|
|
|
free_sink(sink);
|
|
|
|
}
|
|
|
|
LIST_FOR_EACH_SAFE(cursor, cursor2, &This->PreservedKeyNotifySink)
|
|
|
|
{
|
|
|
|
ThreadMgrSink* sink = LIST_ENTRY(cursor,ThreadMgrSink,entry);
|
|
|
|
list_remove(cursor);
|
|
|
|
free_sink(sink);
|
|
|
|
}
|
|
|
|
LIST_FOR_EACH_SAFE(cursor, cursor2, &This->ThreadFocusSink)
|
|
|
|
{
|
|
|
|
ThreadMgrSink* sink = LIST_ENTRY(cursor,ThreadMgrSink,entry);
|
|
|
|
list_remove(cursor);
|
|
|
|
free_sink(sink);
|
|
|
|
}
|
|
|
|
LIST_FOR_EACH_SAFE(cursor, cursor2, &This->ThreadMgrEventSink)
|
|
|
|
{
|
|
|
|
ThreadMgrSink* sink = LIST_ENTRY(cursor,ThreadMgrSink,entry);
|
|
|
|
list_remove(cursor);
|
|
|
|
free_sink(sink);
|
|
|
|
}
|
|
|
|
|
2009-01-27 21:15:30 +01:00
|
|
|
HeapFree(GetProcessHeap(),0,This);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ThreadMgr_QueryInterface(ITfThreadMgr *iface, REFIID iid, LPVOID *ppvOut)
|
|
|
|
{
|
|
|
|
ThreadMgr *This = (ThreadMgr *)iface;
|
|
|
|
*ppvOut = NULL;
|
|
|
|
|
|
|
|
if (IsEqualIID(iid, &IID_IUnknown) || IsEqualIID(iid, &IID_ITfThreadMgr))
|
|
|
|
{
|
|
|
|
*ppvOut = This;
|
|
|
|
}
|
2009-02-02 17:25:49 +01:00
|
|
|
else if (IsEqualIID(iid, &IID_ITfSource))
|
|
|
|
{
|
|
|
|
*ppvOut = &This->SourceVtbl;
|
|
|
|
}
|
2009-01-27 21:15:30 +01:00
|
|
|
|
|
|
|
if (*ppvOut)
|
|
|
|
{
|
|
|
|
IUnknown_AddRef(iface);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
WARN("unsupported interface: %s\n", debugstr_guid(iid));
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI ThreadMgr_AddRef(ITfThreadMgr *iface)
|
|
|
|
{
|
|
|
|
ThreadMgr *This = (ThreadMgr *)iface;
|
|
|
|
return InterlockedIncrement(&This->refCount);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI ThreadMgr_Release(ITfThreadMgr *iface)
|
|
|
|
{
|
|
|
|
ThreadMgr *This = (ThreadMgr *)iface;
|
|
|
|
ULONG ret;
|
|
|
|
|
|
|
|
ret = InterlockedDecrement(&This->refCount);
|
|
|
|
if (ret == 0)
|
|
|
|
ThreadMgr_Destructor(This);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************
|
|
|
|
* ITfThreadMgr functions
|
|
|
|
*****************************************************/
|
|
|
|
|
|
|
|
static HRESULT WINAPI ThreadMgr_fnActivate( ITfThreadMgr* iface, TfClientId *ptid)
|
|
|
|
{
|
|
|
|
ThreadMgr *This = (ThreadMgr *)iface;
|
|
|
|
FIXME("STUB:(%p)\n",This);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ThreadMgr_fnDeactivate( ITfThreadMgr* iface)
|
|
|
|
{
|
|
|
|
ThreadMgr *This = (ThreadMgr *)iface;
|
|
|
|
FIXME("STUB:(%p)\n",This);
|
2009-04-10 18:26:51 +02:00
|
|
|
|
|
|
|
if (This->focus)
|
|
|
|
{
|
|
|
|
ITfThreadMgrEventSink_OnSetFocus((ITfThreadMgrEventSink*)&This->ThreadMgrEventSinkVtbl, 0, This->focus);
|
|
|
|
ITfDocumentMgr_Release(This->focus);
|
|
|
|
This->focus = 0;
|
|
|
|
}
|
|
|
|
|
2009-01-27 21:15:30 +01:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ThreadMgr_CreateDocumentMgr( ITfThreadMgr* iface, ITfDocumentMgr
|
|
|
|
**ppdim)
|
|
|
|
{
|
2009-03-24 14:21:47 +01:00
|
|
|
ThreadMgr *This = (ThreadMgr *)iface;
|
2009-01-30 21:27:06 +01:00
|
|
|
TRACE("(%p)\n",iface);
|
2009-03-24 14:21:47 +01:00
|
|
|
return DocumentMgr_Constructor((ITfThreadMgrEventSink*)&This->ThreadMgrEventSinkVtbl, ppdim);
|
2009-01-27 21:15:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ThreadMgr_EnumDocumentMgrs( ITfThreadMgr* iface, IEnumTfDocumentMgrs
|
|
|
|
**ppEnum)
|
|
|
|
{
|
|
|
|
ThreadMgr *This = (ThreadMgr *)iface;
|
|
|
|
FIXME("STUB:(%p)\n",This);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ThreadMgr_GetFocus( ITfThreadMgr* iface, ITfDocumentMgr
|
|
|
|
**ppdimFocus)
|
|
|
|
{
|
|
|
|
ThreadMgr *This = (ThreadMgr *)iface;
|
2009-02-02 17:24:41 +01:00
|
|
|
TRACE("(%p)\n",This);
|
|
|
|
|
|
|
|
if (!ppdimFocus)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
*ppdimFocus = This->focus;
|
|
|
|
|
|
|
|
TRACE("->%p\n",This->focus);
|
|
|
|
|
|
|
|
if (This->focus == NULL)
|
|
|
|
return S_FALSE;
|
|
|
|
|
|
|
|
ITfDocumentMgr_AddRef(This->focus);
|
|
|
|
|
|
|
|
return S_OK;
|
2009-01-27 21:15:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ThreadMgr_SetFocus( ITfThreadMgr* iface, ITfDocumentMgr *pdimFocus)
|
|
|
|
{
|
2009-02-02 17:24:41 +01:00
|
|
|
ITfDocumentMgr *check;
|
2009-01-27 21:15:30 +01:00
|
|
|
ThreadMgr *This = (ThreadMgr *)iface;
|
2009-02-02 17:24:41 +01:00
|
|
|
|
|
|
|
TRACE("(%p) %p\n",This,pdimFocus);
|
|
|
|
|
|
|
|
if (!pdimFocus || FAILED(IUnknown_QueryInterface(pdimFocus,&IID_ITfDocumentMgr,(LPVOID*) &check)))
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
2009-04-10 18:26:45 +02:00
|
|
|
ITfThreadMgrEventSink_OnSetFocus((ITfThreadMgrEventSink*)&This->ThreadMgrEventSinkVtbl, check, This->focus);
|
2009-03-24 14:21:47 +01:00
|
|
|
|
2009-02-02 17:24:41 +01:00
|
|
|
if (This->focus)
|
|
|
|
ITfDocumentMgr_Release(This->focus);
|
|
|
|
|
|
|
|
This->focus = check;
|
|
|
|
return S_OK;
|
2009-01-27 21:15:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ThreadMgr_AssociateFocus( ITfThreadMgr* iface, HWND hwnd,
|
|
|
|
ITfDocumentMgr *pdimNew, ITfDocumentMgr **ppdimPrev)
|
|
|
|
{
|
|
|
|
ThreadMgr *This = (ThreadMgr *)iface;
|
|
|
|
FIXME("STUB:(%p)\n",This);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ThreadMgr_IsThreadFocus( ITfThreadMgr* iface, BOOL *pfThreadFocus)
|
|
|
|
{
|
|
|
|
ThreadMgr *This = (ThreadMgr *)iface;
|
|
|
|
FIXME("STUB:(%p)\n",This);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ThreadMgr_GetFunctionProvider( ITfThreadMgr* iface, REFCLSID clsid,
|
|
|
|
ITfFunctionProvider **ppFuncProv)
|
|
|
|
{
|
|
|
|
ThreadMgr *This = (ThreadMgr *)iface;
|
|
|
|
FIXME("STUB:(%p)\n",This);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ThreadMgr_EnumFunctionProviders( ITfThreadMgr* iface,
|
|
|
|
IEnumTfFunctionProviders **ppEnum)
|
|
|
|
{
|
|
|
|
ThreadMgr *This = (ThreadMgr *)iface;
|
|
|
|
FIXME("STUB:(%p)\n",This);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ThreadMgr_GetGlobalCompartment( ITfThreadMgr* iface,
|
|
|
|
ITfCompartmentMgr **ppCompMgr)
|
|
|
|
{
|
|
|
|
ThreadMgr *This = (ThreadMgr *)iface;
|
|
|
|
FIXME("STUB:(%p)\n",This);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const ITfThreadMgrVtbl ThreadMgr_ThreadMgrVtbl =
|
|
|
|
{
|
|
|
|
ThreadMgr_QueryInterface,
|
|
|
|
ThreadMgr_AddRef,
|
|
|
|
ThreadMgr_Release,
|
|
|
|
|
|
|
|
ThreadMgr_fnActivate,
|
|
|
|
ThreadMgr_fnDeactivate,
|
|
|
|
ThreadMgr_CreateDocumentMgr,
|
|
|
|
ThreadMgr_EnumDocumentMgrs,
|
|
|
|
ThreadMgr_GetFocus,
|
|
|
|
ThreadMgr_SetFocus,
|
|
|
|
ThreadMgr_AssociateFocus,
|
|
|
|
ThreadMgr_IsThreadFocus,
|
|
|
|
ThreadMgr_GetFunctionProvider,
|
|
|
|
ThreadMgr_EnumFunctionProviders,
|
|
|
|
ThreadMgr_GetGlobalCompartment
|
|
|
|
};
|
|
|
|
|
2009-02-02 17:25:49 +01:00
|
|
|
|
|
|
|
static HRESULT WINAPI Source_QueryInterface(ITfSource *iface, REFIID iid, LPVOID *ppvOut)
|
|
|
|
{
|
|
|
|
ThreadMgr *This = impl_from_ITfSourceVtbl(iface);
|
|
|
|
return ThreadMgr_QueryInterface((ITfThreadMgr *)This, iid, *ppvOut);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI Source_AddRef(ITfSource *iface)
|
|
|
|
{
|
|
|
|
ThreadMgr *This = impl_from_ITfSourceVtbl(iface);
|
|
|
|
return ThreadMgr_AddRef((ITfThreadMgr*)This);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI Source_Release(ITfSource *iface)
|
|
|
|
{
|
|
|
|
ThreadMgr *This = impl_from_ITfSourceVtbl(iface);
|
|
|
|
return ThreadMgr_Release((ITfThreadMgr *)This);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************
|
|
|
|
* ITfSource functions
|
|
|
|
*****************************************************/
|
|
|
|
static WINAPI HRESULT ThreadMgrSource_AdviseSink(ITfSource *iface,
|
|
|
|
REFIID riid, IUnknown *punk, DWORD *pdwCookie)
|
|
|
|
{
|
2009-03-24 14:21:39 +01:00
|
|
|
ThreadMgrSink *tms;
|
2009-02-02 17:25:49 +01:00
|
|
|
ThreadMgr *This = impl_from_ITfSourceVtbl(iface);
|
2009-03-24 14:21:39 +01:00
|
|
|
|
|
|
|
TRACE("(%p) %s %p %p\n",This,debugstr_guid(riid),punk,pdwCookie);
|
|
|
|
|
|
|
|
if (!riid || !punk || !pdwCookie)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
if (IsEqualIID(riid, &IID_ITfThreadMgrEventSink))
|
|
|
|
{
|
|
|
|
tms = HeapAlloc(GetProcessHeap(),0,sizeof(ThreadMgrSink));
|
|
|
|
if (!tms)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
if (!SUCCEEDED(IUnknown_QueryInterface(punk, riid, (LPVOID*)&tms->interfaces.pITfThreadMgrEventSink)))
|
|
|
|
{
|
|
|
|
HeapFree(GetProcessHeap(),0,tms);
|
|
|
|
return CONNECT_E_CANNOTCONNECT;
|
|
|
|
}
|
|
|
|
list_add_head(&This->ThreadMgrEventSink,&tms->entry);
|
|
|
|
*pdwCookie = (DWORD)tms;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
FIXME("(%p) Unhandled Sink: %s\n",This,debugstr_guid(riid));
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
TRACE("cookie %x\n",*pdwCookie);
|
|
|
|
|
|
|
|
return S_OK;
|
2009-02-02 17:25:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static WINAPI HRESULT ThreadMgrSource_UnadviseSink(ITfSource *iface, DWORD pdwCookie)
|
|
|
|
{
|
2009-03-25 20:35:37 +01:00
|
|
|
ThreadMgrSink *sink = (ThreadMgrSink*)pdwCookie;
|
2009-02-02 17:25:49 +01:00
|
|
|
ThreadMgr *This = impl_from_ITfSourceVtbl(iface);
|
2009-03-25 20:35:37 +01:00
|
|
|
TRACE("(%p) %x\n",This,pdwCookie);
|
|
|
|
|
|
|
|
list_remove(&sink->entry);
|
|
|
|
free_sink(sink);
|
|
|
|
|
|
|
|
return S_OK;
|
2009-02-02 17:25:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static const ITfSourceVtbl ThreadMgr_SourceVtbl =
|
|
|
|
{
|
|
|
|
Source_QueryInterface,
|
|
|
|
Source_AddRef,
|
|
|
|
Source_Release,
|
|
|
|
|
|
|
|
ThreadMgrSource_AdviseSink,
|
|
|
|
ThreadMgrSource_UnadviseSink,
|
|
|
|
};
|
|
|
|
|
2009-03-24 14:21:47 +01:00
|
|
|
/*****************************************************
|
|
|
|
* ITfThreadMgrEventSink functions (internal)
|
|
|
|
*****************************************************/
|
|
|
|
static HRESULT WINAPI ThreadMgrEventSink_QueryInterface(ITfThreadMgrEventSink *iface, REFIID iid, LPVOID *ppvOut)
|
|
|
|
{
|
|
|
|
ThreadMgr *This = impl_from_ITfThreadMgrEventSink(iface);
|
|
|
|
return ThreadMgr_QueryInterface((ITfThreadMgr *)This, iid, *ppvOut);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI ThreadMgrEventSink_AddRef(ITfThreadMgrEventSink *iface)
|
|
|
|
{
|
|
|
|
ThreadMgr *This = impl_from_ITfThreadMgrEventSink(iface);
|
|
|
|
return ThreadMgr_AddRef((ITfThreadMgr*)This);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI ThreadMgrEventSink_Release(ITfThreadMgrEventSink *iface)
|
|
|
|
{
|
|
|
|
ThreadMgr *This = impl_from_ITfThreadMgrEventSink(iface);
|
|
|
|
return ThreadMgr_Release((ITfThreadMgr *)This);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static WINAPI HRESULT ThreadMgrEventSink_OnInitDocumentMgr(
|
|
|
|
ITfThreadMgrEventSink *iface,ITfDocumentMgr *pdim)
|
|
|
|
{
|
|
|
|
struct list *cursor;
|
|
|
|
ThreadMgr *This = impl_from_ITfThreadMgrEventSink(iface);
|
|
|
|
|
|
|
|
TRACE("(%p) %p\n",This,pdim);
|
|
|
|
|
|
|
|
LIST_FOR_EACH(cursor, &This->ThreadMgrEventSink)
|
|
|
|
{
|
|
|
|
ThreadMgrSink* sink = LIST_ENTRY(cursor,ThreadMgrSink,entry);
|
|
|
|
ITfThreadMgrEventSink_OnInitDocumentMgr(sink->interfaces.pITfThreadMgrEventSink,pdim);
|
|
|
|
}
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static WINAPI HRESULT ThreadMgrEventSink_OnUninitDocumentMgr(
|
|
|
|
ITfThreadMgrEventSink *iface, ITfDocumentMgr *pdim)
|
|
|
|
{
|
|
|
|
struct list *cursor;
|
|
|
|
ThreadMgr *This = impl_from_ITfThreadMgrEventSink(iface);
|
|
|
|
|
|
|
|
TRACE("(%p) %p\n",This,pdim);
|
|
|
|
|
|
|
|
LIST_FOR_EACH(cursor, &This->ThreadMgrEventSink)
|
|
|
|
{
|
|
|
|
ThreadMgrSink* sink = LIST_ENTRY(cursor,ThreadMgrSink,entry);
|
|
|
|
ITfThreadMgrEventSink_OnUninitDocumentMgr(sink->interfaces.pITfThreadMgrEventSink,pdim);
|
|
|
|
}
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static WINAPI HRESULT ThreadMgrEventSink_OnSetFocus(
|
|
|
|
ITfThreadMgrEventSink *iface, ITfDocumentMgr *pdimFocus,
|
|
|
|
ITfDocumentMgr *pdimPrevFocus)
|
|
|
|
{
|
|
|
|
struct list *cursor;
|
|
|
|
ThreadMgr *This = impl_from_ITfThreadMgrEventSink(iface);
|
|
|
|
|
|
|
|
TRACE("(%p) %p %p\n",This,pdimFocus, pdimPrevFocus);
|
|
|
|
|
|
|
|
LIST_FOR_EACH(cursor, &This->ThreadMgrEventSink)
|
|
|
|
{
|
|
|
|
ThreadMgrSink* sink = LIST_ENTRY(cursor,ThreadMgrSink,entry);
|
|
|
|
ITfThreadMgrEventSink_OnSetFocus(sink->interfaces.pITfThreadMgrEventSink, pdimFocus, pdimPrevFocus);
|
|
|
|
}
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static WINAPI HRESULT ThreadMgrEventSink_OnPushContext(
|
|
|
|
ITfThreadMgrEventSink *iface, ITfContext *pic)
|
|
|
|
{
|
|
|
|
struct list *cursor;
|
|
|
|
ThreadMgr *This = impl_from_ITfThreadMgrEventSink(iface);
|
|
|
|
|
|
|
|
TRACE("(%p) %p\n",This,pic);
|
|
|
|
|
|
|
|
LIST_FOR_EACH(cursor, &This->ThreadMgrEventSink)
|
|
|
|
{
|
|
|
|
ThreadMgrSink* sink = LIST_ENTRY(cursor,ThreadMgrSink,entry);
|
|
|
|
ITfThreadMgrEventSink_OnPushContext(sink->interfaces.pITfThreadMgrEventSink,pic);
|
|
|
|
}
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static WINAPI HRESULT ThreadMgrEventSink_OnPopContext(
|
|
|
|
ITfThreadMgrEventSink *iface, ITfContext *pic)
|
|
|
|
{
|
|
|
|
struct list *cursor;
|
|
|
|
ThreadMgr *This = impl_from_ITfThreadMgrEventSink(iface);
|
|
|
|
|
|
|
|
TRACE("(%p) %p\n",This,pic);
|
|
|
|
|
|
|
|
LIST_FOR_EACH(cursor, &This->ThreadMgrEventSink)
|
|
|
|
{
|
|
|
|
ThreadMgrSink* sink = LIST_ENTRY(cursor,ThreadMgrSink,entry);
|
|
|
|
ITfThreadMgrEventSink_OnPopContext(sink->interfaces.pITfThreadMgrEventSink,pic);
|
|
|
|
}
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const ITfThreadMgrEventSinkVtbl ThreadMgr_ThreadMgrEventSinkVtbl =
|
|
|
|
{
|
|
|
|
ThreadMgrEventSink_QueryInterface,
|
|
|
|
ThreadMgrEventSink_AddRef,
|
|
|
|
ThreadMgrEventSink_Release,
|
|
|
|
|
|
|
|
ThreadMgrEventSink_OnInitDocumentMgr,
|
|
|
|
ThreadMgrEventSink_OnUninitDocumentMgr,
|
|
|
|
ThreadMgrEventSink_OnSetFocus,
|
|
|
|
ThreadMgrEventSink_OnPushContext,
|
|
|
|
ThreadMgrEventSink_OnPopContext
|
|
|
|
};
|
|
|
|
|
2009-01-27 21:15:30 +01:00
|
|
|
HRESULT ThreadMgr_Constructor(IUnknown *pUnkOuter, IUnknown **ppOut)
|
|
|
|
{
|
|
|
|
ThreadMgr *This;
|
|
|
|
if (pUnkOuter)
|
|
|
|
return CLASS_E_NOAGGREGATION;
|
|
|
|
|
2009-02-02 17:24:47 +01:00
|
|
|
/* Only 1 ThreadMgr is created per thread */
|
|
|
|
This = TlsGetValue(tlsIndex);
|
|
|
|
if (This)
|
|
|
|
{
|
|
|
|
ThreadMgr_AddRef((ITfThreadMgr*)This);
|
|
|
|
*ppOut = (IUnknown*)This;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2009-01-27 21:15:30 +01:00
|
|
|
This = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(ThreadMgr));
|
|
|
|
if (This == NULL)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
This->ThreadMgrVtbl= &ThreadMgr_ThreadMgrVtbl;
|
2009-02-02 17:25:49 +01:00
|
|
|
This->SourceVtbl = &ThreadMgr_SourceVtbl;
|
2009-03-24 14:21:47 +01:00
|
|
|
This->ThreadMgrEventSinkVtbl = &ThreadMgr_ThreadMgrEventSinkVtbl;
|
2009-01-27 21:15:30 +01:00
|
|
|
This->refCount = 1;
|
2009-02-02 17:24:47 +01:00
|
|
|
TlsSetValue(tlsIndex,This);
|
2009-01-27 21:15:30 +01:00
|
|
|
|
2009-03-24 14:21:28 +01:00
|
|
|
list_init(&This->ActiveLanguageProfileNotifySink);
|
|
|
|
list_init(&This->DisplayAttributeNotifySink);
|
|
|
|
list_init(&This->KeyTraceEventSink);
|
|
|
|
list_init(&This->PreservedKeyNotifySink);
|
|
|
|
list_init(&This->ThreadFocusSink);
|
|
|
|
list_init(&This->ThreadMgrEventSink);
|
|
|
|
|
2009-01-27 21:15:30 +01:00
|
|
|
TRACE("returning %p\n", This);
|
|
|
|
*ppOut = (IUnknown *)This;
|
|
|
|
return S_OK;
|
|
|
|
}
|