2 * ITfThreadMgr implementation
4 * Copyright 2008 Aric Stewart, CodeWeavers
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
27 #include "wine/debug.h"
37 #include "wine/unicode.h"
38 #include "wine/list.h"
41 #include "msctf_internal.h"
43 WINE_DEFAULT_DEBUG_CHANNEL(msctf);
45 typedef struct tagThreadMgrSink {
50 /* ITfActiveLanguageProfileNotifySink *pITfActiveLanguageProfileNotifySink; */
51 /* ITfDisplayAttributeNotifySink *pITfDisplayAttributeNotifySink; */
52 /* ITfKeyTraceEventSink *pITfKeyTraceEventSink; */
53 /* ITfPreservedKeyNotifySink *pITfPreservedKeyNotifySink; */
54 /* ITfThreadFocusSink *pITfThreadFocusSink; */
55 ITfThreadMgrEventSink *pITfThreadMgrEventSink;
59 typedef struct tagACLMulti {
60 const ITfThreadMgrVtbl *ThreadMgrVtbl;
61 const ITfSourceVtbl *SourceVtbl;
62 const ITfKeystrokeMgrVtbl *KeystrokeMgrVtbl;
63 const ITfMessagePumpVtbl *MessagePumpVtbl;
66 const ITfThreadMgrEventSinkVtbl *ThreadMgrEventSinkVtbl; /* internal */
68 ITfDocumentMgr *focus;
70 /* kept as separate lists to reduce unnecessary iterations */
71 struct list ActiveLanguageProfileNotifySink;
72 struct list DisplayAttributeNotifySink;
73 struct list KeyTraceEventSink;
74 struct list PreservedKeyNotifySink;
75 struct list ThreadFocusSink;
76 struct list ThreadMgrEventSink;
79 static inline ThreadMgr *impl_from_ITfSourceVtbl(ITfSource *iface)
81 return (ThreadMgr *)((char *)iface - FIELD_OFFSET(ThreadMgr,SourceVtbl));
84 static inline ThreadMgr *impl_from_ITfKeystrokeMgrVtbl(ITfKeystrokeMgr *iface)
86 return (ThreadMgr *)((char *)iface - FIELD_OFFSET(ThreadMgr,KeystrokeMgrVtbl));
89 static inline ThreadMgr *impl_from_ITfMessagePumpVtbl(ITfMessagePump *iface)
91 return (ThreadMgr *)((char *)iface - FIELD_OFFSET(ThreadMgr,MessagePumpVtbl));
94 static inline ThreadMgr *impl_from_ITfThreadMgrEventSink(ITfThreadMgrEventSink *iface)
96 return (ThreadMgr *)((char *)iface - FIELD_OFFSET(ThreadMgr,ThreadMgrEventSinkVtbl));
99 static void free_sink(ThreadMgrSink *sink)
101 IUnknown_Release(sink->interfaces.pIUnknown);
102 HeapFree(GetProcessHeap(),0,sink);
105 static void ThreadMgr_Destructor(ThreadMgr *This)
107 struct list *cursor, *cursor2;
109 TlsSetValue(tlsIndex,NULL);
110 TRACE("destroying %p\n", This);
112 ITfDocumentMgr_Release(This->focus);
115 LIST_FOR_EACH_SAFE(cursor, cursor2, &This->ActiveLanguageProfileNotifySink)
117 ThreadMgrSink* sink = LIST_ENTRY(cursor,ThreadMgrSink,entry);
121 LIST_FOR_EACH_SAFE(cursor, cursor2, &This->DisplayAttributeNotifySink)
123 ThreadMgrSink* sink = LIST_ENTRY(cursor,ThreadMgrSink,entry);
127 LIST_FOR_EACH_SAFE(cursor, cursor2, &This->KeyTraceEventSink)
129 ThreadMgrSink* sink = LIST_ENTRY(cursor,ThreadMgrSink,entry);
133 LIST_FOR_EACH_SAFE(cursor, cursor2, &This->PreservedKeyNotifySink)
135 ThreadMgrSink* sink = LIST_ENTRY(cursor,ThreadMgrSink,entry);
139 LIST_FOR_EACH_SAFE(cursor, cursor2, &This->ThreadFocusSink)
141 ThreadMgrSink* sink = LIST_ENTRY(cursor,ThreadMgrSink,entry);
145 LIST_FOR_EACH_SAFE(cursor, cursor2, &This->ThreadMgrEventSink)
147 ThreadMgrSink* sink = LIST_ENTRY(cursor,ThreadMgrSink,entry);
152 HeapFree(GetProcessHeap(),0,This);
155 static HRESULT WINAPI ThreadMgr_QueryInterface(ITfThreadMgr *iface, REFIID iid, LPVOID *ppvOut)
157 ThreadMgr *This = (ThreadMgr *)iface;
160 if (IsEqualIID(iid, &IID_IUnknown) || IsEqualIID(iid, &IID_ITfThreadMgr))
164 else if (IsEqualIID(iid, &IID_ITfSource))
166 *ppvOut = &This->SourceVtbl;
168 else if (IsEqualIID(iid, &IID_ITfKeystrokeMgr))
170 *ppvOut = &This->KeystrokeMgrVtbl;
172 else if (IsEqualIID(iid, &IID_ITfMessagePump))
174 *ppvOut = &This->MessagePumpVtbl;
179 IUnknown_AddRef(iface);
183 WARN("unsupported interface: %s\n", debugstr_guid(iid));
184 return E_NOINTERFACE;
187 static ULONG WINAPI ThreadMgr_AddRef(ITfThreadMgr *iface)
189 ThreadMgr *This = (ThreadMgr *)iface;
190 return InterlockedIncrement(&This->refCount);
193 static ULONG WINAPI ThreadMgr_Release(ITfThreadMgr *iface)
195 ThreadMgr *This = (ThreadMgr *)iface;
198 ret = InterlockedDecrement(&This->refCount);
200 ThreadMgr_Destructor(This);
204 /*****************************************************
205 * ITfThreadMgr functions
206 *****************************************************/
208 static HRESULT WINAPI ThreadMgr_fnActivate( ITfThreadMgr* iface, TfClientId *ptid)
210 ThreadMgr *This = (ThreadMgr *)iface;
211 FIXME("STUB:(%p)\n",This);
215 static HRESULT WINAPI ThreadMgr_fnDeactivate( ITfThreadMgr* iface)
217 ThreadMgr *This = (ThreadMgr *)iface;
218 FIXME("STUB:(%p)\n",This);
222 ITfThreadMgrEventSink_OnSetFocus((ITfThreadMgrEventSink*)&This->ThreadMgrEventSinkVtbl, 0, This->focus);
223 ITfDocumentMgr_Release(This->focus);
230 static HRESULT WINAPI ThreadMgr_CreateDocumentMgr( ITfThreadMgr* iface, ITfDocumentMgr
233 ThreadMgr *This = (ThreadMgr *)iface;
234 TRACE("(%p)\n",iface);
235 return DocumentMgr_Constructor((ITfThreadMgrEventSink*)&This->ThreadMgrEventSinkVtbl, ppdim);
238 static HRESULT WINAPI ThreadMgr_EnumDocumentMgrs( ITfThreadMgr* iface, IEnumTfDocumentMgrs
241 ThreadMgr *This = (ThreadMgr *)iface;
242 FIXME("STUB:(%p)\n",This);
246 static HRESULT WINAPI ThreadMgr_GetFocus( ITfThreadMgr* iface, ITfDocumentMgr
249 ThreadMgr *This = (ThreadMgr *)iface;
250 TRACE("(%p)\n",This);
255 *ppdimFocus = This->focus;
257 TRACE("->%p\n",This->focus);
259 if (This->focus == NULL)
262 ITfDocumentMgr_AddRef(This->focus);
267 static HRESULT WINAPI ThreadMgr_SetFocus( ITfThreadMgr* iface, ITfDocumentMgr *pdimFocus)
269 ITfDocumentMgr *check;
270 ThreadMgr *This = (ThreadMgr *)iface;
272 TRACE("(%p) %p\n",This,pdimFocus);
274 if (!pdimFocus || FAILED(IUnknown_QueryInterface(pdimFocus,&IID_ITfDocumentMgr,(LPVOID*) &check)))
277 ITfThreadMgrEventSink_OnSetFocus((ITfThreadMgrEventSink*)&This->ThreadMgrEventSinkVtbl, check, This->focus);
280 ITfDocumentMgr_Release(This->focus);
286 static HRESULT WINAPI ThreadMgr_AssociateFocus( ITfThreadMgr* iface, HWND hwnd,
287 ITfDocumentMgr *pdimNew, ITfDocumentMgr **ppdimPrev)
289 ThreadMgr *This = (ThreadMgr *)iface;
290 FIXME("STUB:(%p)\n",This);
294 static HRESULT WINAPI ThreadMgr_IsThreadFocus( ITfThreadMgr* iface, BOOL *pfThreadFocus)
296 ThreadMgr *This = (ThreadMgr *)iface;
297 FIXME("STUB:(%p)\n",This);
301 static HRESULT WINAPI ThreadMgr_GetFunctionProvider( ITfThreadMgr* iface, REFCLSID clsid,
302 ITfFunctionProvider **ppFuncProv)
304 ThreadMgr *This = (ThreadMgr *)iface;
305 FIXME("STUB:(%p)\n",This);
309 static HRESULT WINAPI ThreadMgr_EnumFunctionProviders( ITfThreadMgr* iface,
310 IEnumTfFunctionProviders **ppEnum)
312 ThreadMgr *This = (ThreadMgr *)iface;
313 FIXME("STUB:(%p)\n",This);
317 static HRESULT WINAPI ThreadMgr_GetGlobalCompartment( ITfThreadMgr* iface,
318 ITfCompartmentMgr **ppCompMgr)
320 ThreadMgr *This = (ThreadMgr *)iface;
321 FIXME("STUB:(%p)\n",This);
325 static const ITfThreadMgrVtbl ThreadMgr_ThreadMgrVtbl =
327 ThreadMgr_QueryInterface,
331 ThreadMgr_fnActivate,
332 ThreadMgr_fnDeactivate,
333 ThreadMgr_CreateDocumentMgr,
334 ThreadMgr_EnumDocumentMgrs,
337 ThreadMgr_AssociateFocus,
338 ThreadMgr_IsThreadFocus,
339 ThreadMgr_GetFunctionProvider,
340 ThreadMgr_EnumFunctionProviders,
341 ThreadMgr_GetGlobalCompartment
345 static HRESULT WINAPI Source_QueryInterface(ITfSource *iface, REFIID iid, LPVOID *ppvOut)
347 ThreadMgr *This = impl_from_ITfSourceVtbl(iface);
348 return ThreadMgr_QueryInterface((ITfThreadMgr *)This, iid, *ppvOut);
351 static ULONG WINAPI Source_AddRef(ITfSource *iface)
353 ThreadMgr *This = impl_from_ITfSourceVtbl(iface);
354 return ThreadMgr_AddRef((ITfThreadMgr*)This);
357 static ULONG WINAPI Source_Release(ITfSource *iface)
359 ThreadMgr *This = impl_from_ITfSourceVtbl(iface);
360 return ThreadMgr_Release((ITfThreadMgr *)This);
363 /*****************************************************
364 * ITfSource functions
365 *****************************************************/
366 static WINAPI HRESULT ThreadMgrSource_AdviseSink(ITfSource *iface,
367 REFIID riid, IUnknown *punk, DWORD *pdwCookie)
370 ThreadMgr *This = impl_from_ITfSourceVtbl(iface);
372 TRACE("(%p) %s %p %p\n",This,debugstr_guid(riid),punk,pdwCookie);
374 if (!riid || !punk || !pdwCookie)
377 if (IsEqualIID(riid, &IID_ITfThreadMgrEventSink))
379 tms = HeapAlloc(GetProcessHeap(),0,sizeof(ThreadMgrSink));
381 return E_OUTOFMEMORY;
382 if (!SUCCEEDED(IUnknown_QueryInterface(punk, riid, (LPVOID*)&tms->interfaces.pITfThreadMgrEventSink)))
384 HeapFree(GetProcessHeap(),0,tms);
385 return CONNECT_E_CANNOTCONNECT;
387 list_add_head(&This->ThreadMgrEventSink,&tms->entry);
388 *pdwCookie = generate_Cookie(COOKIE_MAGIC_TMSINK, tms);
392 FIXME("(%p) Unhandled Sink: %s\n",This,debugstr_guid(riid));
396 TRACE("cookie %x\n",*pdwCookie);
401 static WINAPI HRESULT ThreadMgrSource_UnadviseSink(ITfSource *iface, DWORD pdwCookie)
404 ThreadMgr *This = impl_from_ITfSourceVtbl(iface);
406 TRACE("(%p) %x\n",This,pdwCookie);
408 if (get_Cookie_magic(pdwCookie)!=COOKIE_MAGIC_TMSINK)
411 sink = (ThreadMgrSink*)remove_Cookie(pdwCookie);
413 return CONNECT_E_NOCONNECTION;
415 list_remove(&sink->entry);
421 static const ITfSourceVtbl ThreadMgr_SourceVtbl =
423 Source_QueryInterface,
427 ThreadMgrSource_AdviseSink,
428 ThreadMgrSource_UnadviseSink,
431 /*****************************************************
432 * ITfKeystrokeMgr functions
433 *****************************************************/
435 static HRESULT WINAPI KeystrokeMgr_QueryInterface(ITfKeystrokeMgr *iface, REFIID iid, LPVOID *ppvOut)
437 ThreadMgr *This = impl_from_ITfKeystrokeMgrVtbl(iface);
438 return ThreadMgr_QueryInterface((ITfThreadMgr *)This, iid, *ppvOut);
441 static ULONG WINAPI KeystrokeMgr_AddRef(ITfKeystrokeMgr *iface)
443 ThreadMgr *This = impl_from_ITfKeystrokeMgrVtbl(iface);
444 return ThreadMgr_AddRef((ITfThreadMgr*)This);
447 static ULONG WINAPI KeystrokeMgr_Release(ITfKeystrokeMgr *iface)
449 ThreadMgr *This = impl_from_ITfKeystrokeMgrVtbl(iface);
450 return ThreadMgr_Release((ITfThreadMgr *)This);
453 static HRESULT WINAPI KeystrokeMgr_AdviseKeyEventSink(ITfKeystrokeMgr *iface,
454 TfClientId tid, ITfKeyEventSink *pSink, BOOL fForeground)
456 ThreadMgr *This = impl_from_ITfKeystrokeMgrVtbl(iface);
457 FIXME("STUB:(%p)\n",This);
461 static HRESULT WINAPI KeystrokeMgr_UnadviseKeyEventSink(ITfKeystrokeMgr *iface,
464 ThreadMgr *This = impl_from_ITfKeystrokeMgrVtbl(iface);
465 FIXME("STUB:(%p)\n",This);
469 static HRESULT WINAPI KeystrokeMgr_GetForeground(ITfKeystrokeMgr *iface,
472 ThreadMgr *This = impl_from_ITfKeystrokeMgrVtbl(iface);
473 FIXME("STUB:(%p)\n",This);
477 static HRESULT WINAPI KeystrokeMgr_TestKeyDown(ITfKeystrokeMgr *iface,
478 WPARAM wParam, LPARAM lParam, BOOL *pfEaten)
480 ThreadMgr *This = impl_from_ITfKeystrokeMgrVtbl(iface);
481 FIXME("STUB:(%p)\n",This);
485 static HRESULT WINAPI KeystrokeMgr_TestKeyUp(ITfKeystrokeMgr *iface,
486 WPARAM wParam, LPARAM lParam, BOOL *pfEaten)
488 ThreadMgr *This = impl_from_ITfKeystrokeMgrVtbl(iface);
489 FIXME("STUB:(%p)\n",This);
493 static HRESULT WINAPI KeystrokeMgr_KeyDown(ITfKeystrokeMgr *iface,
494 WPARAM wParam, LPARAM lParam, BOOL *pfEaten)
496 ThreadMgr *This = impl_from_ITfKeystrokeMgrVtbl(iface);
497 FIXME("STUB:(%p)\n",This);
501 static HRESULT WINAPI KeystrokeMgr_KeyUp(ITfKeystrokeMgr *iface,
502 WPARAM wParam, LPARAM lParam, BOOL *pfEaten)
504 ThreadMgr *This = impl_from_ITfKeystrokeMgrVtbl(iface);
505 FIXME("STUB:(%p)\n",This);
509 static HRESULT WINAPI KeystrokeMgr_GetPreservedKey(ITfKeystrokeMgr *iface,
510 ITfContext *pic, const TF_PRESERVEDKEY *pprekey, GUID *pguid)
512 ThreadMgr *This = impl_from_ITfKeystrokeMgrVtbl(iface);
513 FIXME("STUB:(%p)\n",This);
517 static HRESULT WINAPI KeystrokeMgr_IsPreservedKey(ITfKeystrokeMgr *iface,
518 REFGUID rguid, const TF_PRESERVEDKEY *pprekey, BOOL *pfRegistered)
520 ThreadMgr *This = impl_from_ITfKeystrokeMgrVtbl(iface);
521 FIXME("STUB:(%p)\n",This);
525 static HRESULT WINAPI KeystrokeMgr_PreserveKey(ITfKeystrokeMgr *iface,
526 TfClientId tid, REFGUID rguid, const TF_PRESERVEDKEY *prekey,
527 const WCHAR *pchDesc, ULONG cchDesc)
529 ThreadMgr *This = impl_from_ITfKeystrokeMgrVtbl(iface);
530 FIXME("STUB:(%p)\n",This);
534 static HRESULT WINAPI KeystrokeMgr_UnpreserveKey(ITfKeystrokeMgr *iface,
535 REFGUID rguid, const TF_PRESERVEDKEY *pprekey)
537 ThreadMgr *This = impl_from_ITfKeystrokeMgrVtbl(iface);
538 FIXME("STUB:(%p)\n",This);
542 static HRESULT WINAPI KeystrokeMgr_SetPreservedKeyDescription(ITfKeystrokeMgr *iface,
543 REFGUID rguid, const WCHAR *pchDesc, ULONG cchDesc)
545 ThreadMgr *This = impl_from_ITfKeystrokeMgrVtbl(iface);
546 FIXME("STUB:(%p)\n",This);
550 static HRESULT WINAPI KeystrokeMgr_GetPreservedKeyDescription(ITfKeystrokeMgr *iface,
551 REFGUID rguid, BSTR *pbstrDesc)
553 ThreadMgr *This = impl_from_ITfKeystrokeMgrVtbl(iface);
554 FIXME("STUB:(%p)\n",This);
558 static HRESULT WINAPI KeystrokeMgr_SimulatePreservedKey(ITfKeystrokeMgr *iface,
559 ITfContext *pic, REFGUID rguid, BOOL *pfEaten)
561 ThreadMgr *This = impl_from_ITfKeystrokeMgrVtbl(iface);
562 FIXME("STUB:(%p)\n",This);
566 static const ITfKeystrokeMgrVtbl ThreadMgr_KeystrokeMgrVtbl =
568 KeystrokeMgr_QueryInterface,
570 KeystrokeMgr_Release,
572 KeystrokeMgr_AdviseKeyEventSink,
573 KeystrokeMgr_UnadviseKeyEventSink,
574 KeystrokeMgr_GetForeground,
575 KeystrokeMgr_TestKeyDown,
576 KeystrokeMgr_TestKeyUp,
577 KeystrokeMgr_KeyDown,
579 KeystrokeMgr_GetPreservedKey,
580 KeystrokeMgr_IsPreservedKey,
581 KeystrokeMgr_PreserveKey,
582 KeystrokeMgr_UnpreserveKey,
583 KeystrokeMgr_SetPreservedKeyDescription,
584 KeystrokeMgr_GetPreservedKeyDescription,
585 KeystrokeMgr_SimulatePreservedKey
588 /*****************************************************
589 * ITfMessagePump functions
590 *****************************************************/
592 static HRESULT WINAPI MessagePump_QueryInterface(ITfMessagePump *iface, REFIID iid, LPVOID *ppvOut)
594 ThreadMgr *This = impl_from_ITfMessagePumpVtbl(iface);
595 return ThreadMgr_QueryInterface((ITfThreadMgr *)This, iid, *ppvOut);
598 static ULONG WINAPI MessagePump_AddRef(ITfMessagePump *iface)
600 ThreadMgr *This = impl_from_ITfMessagePumpVtbl(iface);
601 return ThreadMgr_AddRef((ITfThreadMgr*)This);
604 static ULONG WINAPI MessagePump_Release(ITfMessagePump *iface)
606 ThreadMgr *This = impl_from_ITfMessagePumpVtbl(iface);
607 return ThreadMgr_Release((ITfThreadMgr *)This);
610 static HRESULT WINAPI MessagePump_PeekMessageA(ITfMessagePump *iface,
611 LPMSG pMsg, HWND hwnd, UINT wMsgFilterMin, UINT wMsgFilterMax,
612 UINT wRemoveMsg, BOOL *pfResult)
616 *pfResult = PeekMessageA(pMsg, hwnd, wMsgFilterMin, wMsgFilterMax, wRemoveMsg);
620 static HRESULT WINAPI MessagePump_GetMessageA(ITfMessagePump *iface,
621 LPMSG pMsg, HWND hwnd, UINT wMsgFilterMin, UINT wMsgFilterMax,
626 *pfResult = GetMessageA(pMsg, hwnd, wMsgFilterMin, wMsgFilterMax);
630 static HRESULT WINAPI MessagePump_PeekMessageW(ITfMessagePump *iface,
631 LPMSG pMsg, HWND hwnd, UINT wMsgFilterMin, UINT wMsgFilterMax,
632 UINT wRemoveMsg, BOOL *pfResult)
636 *pfResult = PeekMessageW(pMsg, hwnd, wMsgFilterMin, wMsgFilterMax, wRemoveMsg);
640 static HRESULT WINAPI MessagePump_GetMessageW(ITfMessagePump *iface,
641 LPMSG pMsg, HWND hwnd, UINT wMsgFilterMin, UINT wMsgFilterMax,
646 *pfResult = GetMessageW(pMsg, hwnd, wMsgFilterMin, wMsgFilterMax);
650 static const ITfMessagePumpVtbl ThreadMgr_MessagePumpVtbl =
652 MessagePump_QueryInterface,
656 MessagePump_PeekMessageA,
657 MessagePump_GetMessageA,
658 MessagePump_PeekMessageW,
659 MessagePump_GetMessageW
662 /*****************************************************
663 * ITfThreadMgrEventSink functions (internal)
664 *****************************************************/
665 static HRESULT WINAPI ThreadMgrEventSink_QueryInterface(ITfThreadMgrEventSink *iface, REFIID iid, LPVOID *ppvOut)
667 ThreadMgr *This = impl_from_ITfThreadMgrEventSink(iface);
668 return ThreadMgr_QueryInterface((ITfThreadMgr *)This, iid, *ppvOut);
671 static ULONG WINAPI ThreadMgrEventSink_AddRef(ITfThreadMgrEventSink *iface)
673 ThreadMgr *This = impl_from_ITfThreadMgrEventSink(iface);
674 return ThreadMgr_AddRef((ITfThreadMgr*)This);
677 static ULONG WINAPI ThreadMgrEventSink_Release(ITfThreadMgrEventSink *iface)
679 ThreadMgr *This = impl_from_ITfThreadMgrEventSink(iface);
680 return ThreadMgr_Release((ITfThreadMgr *)This);
684 static WINAPI HRESULT ThreadMgrEventSink_OnInitDocumentMgr(
685 ITfThreadMgrEventSink *iface,ITfDocumentMgr *pdim)
688 ThreadMgr *This = impl_from_ITfThreadMgrEventSink(iface);
690 TRACE("(%p) %p\n",This,pdim);
692 LIST_FOR_EACH(cursor, &This->ThreadMgrEventSink)
694 ThreadMgrSink* sink = LIST_ENTRY(cursor,ThreadMgrSink,entry);
695 ITfThreadMgrEventSink_OnInitDocumentMgr(sink->interfaces.pITfThreadMgrEventSink,pdim);
701 static WINAPI HRESULT ThreadMgrEventSink_OnUninitDocumentMgr(
702 ITfThreadMgrEventSink *iface, ITfDocumentMgr *pdim)
705 ThreadMgr *This = impl_from_ITfThreadMgrEventSink(iface);
707 TRACE("(%p) %p\n",This,pdim);
709 LIST_FOR_EACH(cursor, &This->ThreadMgrEventSink)
711 ThreadMgrSink* sink = LIST_ENTRY(cursor,ThreadMgrSink,entry);
712 ITfThreadMgrEventSink_OnUninitDocumentMgr(sink->interfaces.pITfThreadMgrEventSink,pdim);
718 static WINAPI HRESULT ThreadMgrEventSink_OnSetFocus(
719 ITfThreadMgrEventSink *iface, ITfDocumentMgr *pdimFocus,
720 ITfDocumentMgr *pdimPrevFocus)
723 ThreadMgr *This = impl_from_ITfThreadMgrEventSink(iface);
725 TRACE("(%p) %p %p\n",This,pdimFocus, pdimPrevFocus);
727 LIST_FOR_EACH(cursor, &This->ThreadMgrEventSink)
729 ThreadMgrSink* sink = LIST_ENTRY(cursor,ThreadMgrSink,entry);
730 ITfThreadMgrEventSink_OnSetFocus(sink->interfaces.pITfThreadMgrEventSink, pdimFocus, pdimPrevFocus);
736 static WINAPI HRESULT ThreadMgrEventSink_OnPushContext(
737 ITfThreadMgrEventSink *iface, ITfContext *pic)
740 ThreadMgr *This = impl_from_ITfThreadMgrEventSink(iface);
742 TRACE("(%p) %p\n",This,pic);
744 LIST_FOR_EACH(cursor, &This->ThreadMgrEventSink)
746 ThreadMgrSink* sink = LIST_ENTRY(cursor,ThreadMgrSink,entry);
747 ITfThreadMgrEventSink_OnPushContext(sink->interfaces.pITfThreadMgrEventSink,pic);
753 static WINAPI HRESULT ThreadMgrEventSink_OnPopContext(
754 ITfThreadMgrEventSink *iface, ITfContext *pic)
757 ThreadMgr *This = impl_from_ITfThreadMgrEventSink(iface);
759 TRACE("(%p) %p\n",This,pic);
761 LIST_FOR_EACH(cursor, &This->ThreadMgrEventSink)
763 ThreadMgrSink* sink = LIST_ENTRY(cursor,ThreadMgrSink,entry);
764 ITfThreadMgrEventSink_OnPopContext(sink->interfaces.pITfThreadMgrEventSink,pic);
770 static const ITfThreadMgrEventSinkVtbl ThreadMgr_ThreadMgrEventSinkVtbl =
772 ThreadMgrEventSink_QueryInterface,
773 ThreadMgrEventSink_AddRef,
774 ThreadMgrEventSink_Release,
776 ThreadMgrEventSink_OnInitDocumentMgr,
777 ThreadMgrEventSink_OnUninitDocumentMgr,
778 ThreadMgrEventSink_OnSetFocus,
779 ThreadMgrEventSink_OnPushContext,
780 ThreadMgrEventSink_OnPopContext
783 HRESULT ThreadMgr_Constructor(IUnknown *pUnkOuter, IUnknown **ppOut)
787 return CLASS_E_NOAGGREGATION;
789 /* Only 1 ThreadMgr is created per thread */
790 This = TlsGetValue(tlsIndex);
793 ThreadMgr_AddRef((ITfThreadMgr*)This);
794 *ppOut = (IUnknown*)This;
798 This = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(ThreadMgr));
800 return E_OUTOFMEMORY;
802 This->ThreadMgrVtbl= &ThreadMgr_ThreadMgrVtbl;
803 This->SourceVtbl = &ThreadMgr_SourceVtbl;
804 This->KeystrokeMgrVtbl= &ThreadMgr_KeystrokeMgrVtbl;
805 This->MessagePumpVtbl= &ThreadMgr_MessagePumpVtbl;
806 This->ThreadMgrEventSinkVtbl = &ThreadMgr_ThreadMgrEventSinkVtbl;
808 TlsSetValue(tlsIndex,This);
810 list_init(&This->ActiveLanguageProfileNotifySink);
811 list_init(&This->DisplayAttributeNotifySink);
812 list_init(&This->KeyTraceEventSink);
813 list_init(&This->PreservedKeyNotifySink);
814 list_init(&This->ThreadFocusSink);
815 list_init(&This->ThreadMgrEventSink);
817 TRACE("returning %p\n", This);
818 *ppOut = (IUnknown *)This;