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 tagPreservedKey
63 TF_PRESERVEDKEY prekey;
68 typedef struct tagDocumentMgrs
71 ITfDocumentMgr *docmgr;
74 typedef struct tagAssociatedWindow
78 ITfDocumentMgr *docmgr;
81 typedef struct tagACLMulti {
82 const ITfThreadMgrVtbl *ThreadMgrVtbl;
83 const ITfSourceVtbl *SourceVtbl;
84 const ITfKeystrokeMgrVtbl *KeystrokeMgrVtbl;
85 const ITfMessagePumpVtbl *MessagePumpVtbl;
86 const ITfClientIdVtbl *ClientIdVtbl;
87 /* const ITfThreadMgrExVtbl *ThreadMgrExVtbl; */
88 /* const ITfConfigureSystemKeystrokeFeedVtbl *ConfigureSystemKeystrokeFeedVtbl; */
89 /* const ITfLangBarItemMgrVtbl *LangBarItemMgrVtbl; */
90 /* const ITfUIElementMgrVtbl *UIElementMgrVtbl; */
91 const ITfSourceSingleVtbl *SourceSingleVtbl;
95 ITfCompartmentMgr *CompartmentMgr;
97 const ITfThreadMgrEventSinkVtbl *ThreadMgrEventSinkVtbl; /* internal */
99 ITfDocumentMgr *focus;
100 LONG activationCount;
102 ITfKeyEventSink *forgroundKeyEventSink;
103 CLSID forgroundTextService;
105 struct list CurrentPreservedKeys;
106 struct list CreatedDocumentMgrs;
108 struct list AssociatedFocusWindows;
111 /* kept as separate lists to reduce unnecessary iterations */
112 struct list ActiveLanguageProfileNotifySink;
113 struct list DisplayAttributeNotifySink;
114 struct list KeyTraceEventSink;
115 struct list PreservedKeyNotifySink;
116 struct list ThreadFocusSink;
117 struct list ThreadMgrEventSink;
120 typedef struct tagEnumTfDocumentMgr {
121 const IEnumTfDocumentMgrsVtbl *Vtbl;
128 static HRESULT EnumTfDocumentMgr_Constructor(struct list* head, IEnumTfDocumentMgrs **ppOut);
130 static inline ThreadMgr *impl_from_ITfSourceVtbl(ITfSource *iface)
132 return (ThreadMgr *)((char *)iface - FIELD_OFFSET(ThreadMgr,SourceVtbl));
135 static inline ThreadMgr *impl_from_ITfKeystrokeMgrVtbl(ITfKeystrokeMgr *iface)
137 return (ThreadMgr *)((char *)iface - FIELD_OFFSET(ThreadMgr,KeystrokeMgrVtbl));
140 static inline ThreadMgr *impl_from_ITfMessagePumpVtbl(ITfMessagePump *iface)
142 return (ThreadMgr *)((char *)iface - FIELD_OFFSET(ThreadMgr,MessagePumpVtbl));
145 static inline ThreadMgr *impl_from_ITfClientIdVtbl(ITfClientId *iface)
147 return (ThreadMgr *)((char *)iface - FIELD_OFFSET(ThreadMgr,ClientIdVtbl));
150 static inline ThreadMgr *impl_from_ITfThreadMgrEventSink(ITfThreadMgrEventSink *iface)
152 return (ThreadMgr *)((char *)iface - FIELD_OFFSET(ThreadMgr,ThreadMgrEventSinkVtbl));
155 static inline ThreadMgr *impl_from_ITfSourceSingleVtbl(ITfSourceSingle* iface)
158 return (ThreadMgr *)((char *)iface - FIELD_OFFSET(ThreadMgr,SourceSingleVtbl));
161 static void free_sink(ThreadMgrSink *sink)
163 IUnknown_Release(sink->interfaces.pIUnknown);
164 HeapFree(GetProcessHeap(),0,sink);
167 static void ThreadMgr_Destructor(ThreadMgr *This)
169 struct list *cursor, *cursor2;
171 /* unhook right away */
173 UnhookWindowsHookEx(This->focusHook);
175 TlsSetValue(tlsIndex,NULL);
176 TRACE("destroying %p\n", This);
178 ITfDocumentMgr_Release(This->focus);
181 LIST_FOR_EACH_SAFE(cursor, cursor2, &This->ActiveLanguageProfileNotifySink)
183 ThreadMgrSink* sink = LIST_ENTRY(cursor,ThreadMgrSink,entry);
187 LIST_FOR_EACH_SAFE(cursor, cursor2, &This->DisplayAttributeNotifySink)
189 ThreadMgrSink* sink = LIST_ENTRY(cursor,ThreadMgrSink,entry);
193 LIST_FOR_EACH_SAFE(cursor, cursor2, &This->KeyTraceEventSink)
195 ThreadMgrSink* sink = LIST_ENTRY(cursor,ThreadMgrSink,entry);
199 LIST_FOR_EACH_SAFE(cursor, cursor2, &This->PreservedKeyNotifySink)
201 ThreadMgrSink* sink = LIST_ENTRY(cursor,ThreadMgrSink,entry);
205 LIST_FOR_EACH_SAFE(cursor, cursor2, &This->ThreadFocusSink)
207 ThreadMgrSink* sink = LIST_ENTRY(cursor,ThreadMgrSink,entry);
211 LIST_FOR_EACH_SAFE(cursor, cursor2, &This->ThreadMgrEventSink)
213 ThreadMgrSink* sink = LIST_ENTRY(cursor,ThreadMgrSink,entry);
218 LIST_FOR_EACH_SAFE(cursor, cursor2, &This->CurrentPreservedKeys)
220 PreservedKey* key = LIST_ENTRY(cursor,PreservedKey,entry);
222 HeapFree(GetProcessHeap(),0,key->description);
223 HeapFree(GetProcessHeap(),0,key);
226 LIST_FOR_EACH_SAFE(cursor, cursor2, &This->CreatedDocumentMgrs)
228 DocumentMgrEntry *mgr = LIST_ENTRY(cursor,DocumentMgrEntry,entry);
230 FIXME("Left Over ITfDocumentMgr. Should we do something with it?\n");
231 HeapFree(GetProcessHeap(),0,mgr);
234 LIST_FOR_EACH_SAFE(cursor, cursor2, &This->AssociatedFocusWindows)
236 AssociatedWindow *wnd = LIST_ENTRY(cursor,AssociatedWindow,entry);
238 HeapFree(GetProcessHeap(),0,wnd);
241 CompartmentMgr_Destructor(This->CompartmentMgr);
243 HeapFree(GetProcessHeap(),0,This);
246 static HRESULT WINAPI ThreadMgr_QueryInterface(ITfThreadMgr *iface, REFIID iid, LPVOID *ppvOut)
248 ThreadMgr *This = (ThreadMgr *)iface;
251 if (IsEqualIID(iid, &IID_IUnknown) || IsEqualIID(iid, &IID_ITfThreadMgr))
255 else if (IsEqualIID(iid, &IID_ITfSource))
257 *ppvOut = &This->SourceVtbl;
259 else if (IsEqualIID(iid, &IID_ITfKeystrokeMgr))
261 *ppvOut = &This->KeystrokeMgrVtbl;
263 else if (IsEqualIID(iid, &IID_ITfMessagePump))
265 *ppvOut = &This->MessagePumpVtbl;
267 else if (IsEqualIID(iid, &IID_ITfClientId))
269 *ppvOut = &This->ClientIdVtbl;
271 else if (IsEqualIID(iid, &IID_ITfCompartmentMgr))
273 *ppvOut = This->CompartmentMgr;
275 else if (IsEqualIID(iid, &IID_ITfSourceSingle))
277 *ppvOut = &This->SourceSingleVtbl;
282 IUnknown_AddRef(iface);
286 WARN("unsupported interface: %s\n", debugstr_guid(iid));
287 return E_NOINTERFACE;
290 static ULONG WINAPI ThreadMgr_AddRef(ITfThreadMgr *iface)
292 ThreadMgr *This = (ThreadMgr *)iface;
293 return InterlockedIncrement(&This->refCount);
296 static ULONG WINAPI ThreadMgr_Release(ITfThreadMgr *iface)
298 ThreadMgr *This = (ThreadMgr *)iface;
301 ret = InterlockedDecrement(&This->refCount);
303 ThreadMgr_Destructor(This);
307 /*****************************************************
308 * ITfThreadMgr functions
309 *****************************************************/
311 static HRESULT WINAPI ThreadMgr_fnActivate( ITfThreadMgr* iface, TfClientId *ptid)
313 ThreadMgr *This = (ThreadMgr *)iface;
315 TRACE("(%p) %p\n",This, ptid);
324 ITfClientId_GetClientId((ITfClientId*)&This->ClientIdVtbl,&guid,&processId);
327 activate_textservices(iface);
328 This->activationCount++;
333 static HRESULT WINAPI ThreadMgr_fnDeactivate( ITfThreadMgr* iface)
335 ThreadMgr *This = (ThreadMgr *)iface;
336 TRACE("(%p)\n",This);
338 if (This->activationCount == 0)
341 This->activationCount --;
343 if (This->activationCount == 0)
347 ITfThreadMgrEventSink_OnSetFocus((ITfThreadMgrEventSink*)&This->ThreadMgrEventSinkVtbl, 0, This->focus);
348 ITfDocumentMgr_Release(This->focus);
353 deactivate_textservices();
358 static HRESULT WINAPI ThreadMgr_CreateDocumentMgr( ITfThreadMgr* iface, ITfDocumentMgr
361 ThreadMgr *This = (ThreadMgr *)iface;
362 DocumentMgrEntry *mgrentry;
365 TRACE("(%p)\n",iface);
366 mgrentry = HeapAlloc(GetProcessHeap(),0,sizeof(DocumentMgrEntry));
367 if (mgrentry == NULL)
368 return E_OUTOFMEMORY;
370 hr = DocumentMgr_Constructor((ITfThreadMgrEventSink*)&This->ThreadMgrEventSinkVtbl, ppdim);
374 mgrentry->docmgr = *ppdim;
375 list_add_head(&This->CreatedDocumentMgrs,&mgrentry->entry);
378 HeapFree(GetProcessHeap(),0,mgrentry);
383 static HRESULT WINAPI ThreadMgr_EnumDocumentMgrs( ITfThreadMgr* iface, IEnumTfDocumentMgrs
386 ThreadMgr *This = (ThreadMgr *)iface;
387 TRACE("(%p) %p\n",This,ppEnum);
392 return EnumTfDocumentMgr_Constructor(&This->CreatedDocumentMgrs, ppEnum);
395 static HRESULT WINAPI ThreadMgr_GetFocus( ITfThreadMgr* iface, ITfDocumentMgr
398 ThreadMgr *This = (ThreadMgr *)iface;
399 TRACE("(%p)\n",This);
404 *ppdimFocus = This->focus;
406 TRACE("->%p\n",This->focus);
408 if (This->focus == NULL)
411 ITfDocumentMgr_AddRef(This->focus);
416 static HRESULT WINAPI ThreadMgr_SetFocus( ITfThreadMgr* iface, ITfDocumentMgr *pdimFocus)
418 ITfDocumentMgr *check;
419 ThreadMgr *This = (ThreadMgr *)iface;
421 TRACE("(%p) %p\n",This,pdimFocus);
425 else if (FAILED(IUnknown_QueryInterface(pdimFocus,&IID_ITfDocumentMgr,(LPVOID*) &check)))
428 ITfThreadMgrEventSink_OnSetFocus((ITfThreadMgrEventSink*)&This->ThreadMgrEventSinkVtbl, check, This->focus);
431 ITfDocumentMgr_Release(This->focus);
437 static LRESULT CALLBACK ThreadFocusHookProc(int nCode, WPARAM wParam, LPARAM lParam)
441 This = TlsGetValue(tlsIndex);
444 ERR("Hook proc but no ThreadMgr for this thread. Serious Error\n");
447 if (!This->focusHook)
449 ERR("Hook proc but no ThreadMgr focus Hook. Serious Error\n");
453 if (nCode == HCBT_SETFOCUS) /* focus change within our thread */
457 LIST_FOR_EACH(cursor, &This->AssociatedFocusWindows)
459 AssociatedWindow *wnd = LIST_ENTRY(cursor,AssociatedWindow,entry);
460 if (wnd->hwnd == (HWND)wParam)
462 TRACE("Triggering Associated window focus\n");
463 if (This->focus != wnd->docmgr)
464 ThreadMgr_SetFocus((ITfThreadMgr*)This, wnd->docmgr);
470 return CallNextHookEx(This->focusHook, nCode, wParam, lParam);
473 static HRESULT SetupWindowsHook(ThreadMgr *This)
475 if (!This->focusHook)
477 This->focusHook = SetWindowsHookExW(WH_CBT, ThreadFocusHookProc, 0,
478 GetCurrentThreadId());
479 if (!This->focusHook)
481 ERR("Unable to set focus hook\n");
489 static HRESULT WINAPI ThreadMgr_AssociateFocus( ITfThreadMgr* iface, HWND hwnd,
490 ITfDocumentMgr *pdimNew, ITfDocumentMgr **ppdimPrev)
492 struct list *cursor, *cursor2;
493 ThreadMgr *This = (ThreadMgr *)iface;
494 AssociatedWindow *wnd;
496 TRACE("(%p) %p %p %p\n",This,hwnd,pdimNew,ppdimPrev);
503 LIST_FOR_EACH_SAFE(cursor, cursor2, &This->AssociatedFocusWindows)
505 wnd = LIST_ENTRY(cursor,AssociatedWindow,entry);
506 if (wnd->hwnd == hwnd)
509 ITfDocumentMgr_AddRef(wnd->docmgr);
510 *ppdimPrev = wnd->docmgr;
511 wnd->docmgr = pdimNew;
512 if (GetFocus() == hwnd)
513 ThreadMgr_SetFocus(iface,pdimNew);
518 wnd = HeapAlloc(GetProcessHeap(),0,sizeof(AssociatedWindow));
520 wnd->docmgr = pdimNew;
521 list_add_head(&This->AssociatedFocusWindows,&wnd->entry);
523 if (GetFocus() == hwnd)
524 ThreadMgr_SetFocus(iface,pdimNew);
526 SetupWindowsHook(This);
531 static HRESULT WINAPI ThreadMgr_IsThreadFocus( ITfThreadMgr* iface, BOOL *pfThreadFocus)
534 ThreadMgr *This = (ThreadMgr *)iface;
535 TRACE("(%p) %p\n",This,pfThreadFocus);
537 *pfThreadFocus = (focus == NULL);
541 static HRESULT WINAPI ThreadMgr_GetFunctionProvider( ITfThreadMgr* iface, REFCLSID clsid,
542 ITfFunctionProvider **ppFuncProv)
544 ThreadMgr *This = (ThreadMgr *)iface;
545 FIXME("STUB:(%p)\n",This);
549 static HRESULT WINAPI ThreadMgr_EnumFunctionProviders( ITfThreadMgr* iface,
550 IEnumTfFunctionProviders **ppEnum)
552 ThreadMgr *This = (ThreadMgr *)iface;
553 FIXME("STUB:(%p)\n",This);
557 static HRESULT WINAPI ThreadMgr_GetGlobalCompartment( ITfThreadMgr* iface,
558 ITfCompartmentMgr **ppCompMgr)
560 ThreadMgr *This = (ThreadMgr *)iface;
562 TRACE("(%p) %p\n",This, ppCompMgr);
567 if (!globalCompartmentMgr)
569 hr = CompartmentMgr_Constructor(NULL,&IID_ITfCompartmentMgr,(IUnknown**)&globalCompartmentMgr);
574 ITfCompartmentMgr_AddRef(globalCompartmentMgr);
575 *ppCompMgr = globalCompartmentMgr;
579 static const ITfThreadMgrVtbl ThreadMgr_ThreadMgrVtbl =
581 ThreadMgr_QueryInterface,
585 ThreadMgr_fnActivate,
586 ThreadMgr_fnDeactivate,
587 ThreadMgr_CreateDocumentMgr,
588 ThreadMgr_EnumDocumentMgrs,
591 ThreadMgr_AssociateFocus,
592 ThreadMgr_IsThreadFocus,
593 ThreadMgr_GetFunctionProvider,
594 ThreadMgr_EnumFunctionProviders,
595 ThreadMgr_GetGlobalCompartment
599 static HRESULT WINAPI Source_QueryInterface(ITfSource *iface, REFIID iid, LPVOID *ppvOut)
601 ThreadMgr *This = impl_from_ITfSourceVtbl(iface);
602 return ThreadMgr_QueryInterface((ITfThreadMgr *)This, iid, *ppvOut);
605 static ULONG WINAPI Source_AddRef(ITfSource *iface)
607 ThreadMgr *This = impl_from_ITfSourceVtbl(iface);
608 return ThreadMgr_AddRef((ITfThreadMgr*)This);
611 static ULONG WINAPI Source_Release(ITfSource *iface)
613 ThreadMgr *This = impl_from_ITfSourceVtbl(iface);
614 return ThreadMgr_Release((ITfThreadMgr *)This);
617 /*****************************************************
618 * ITfSource functions
619 *****************************************************/
620 static WINAPI HRESULT ThreadMgrSource_AdviseSink(ITfSource *iface,
621 REFIID riid, IUnknown *punk, DWORD *pdwCookie)
624 ThreadMgr *This = impl_from_ITfSourceVtbl(iface);
626 TRACE("(%p) %s %p %p\n",This,debugstr_guid(riid),punk,pdwCookie);
628 if (!riid || !punk || !pdwCookie)
631 if (IsEqualIID(riid, &IID_ITfThreadMgrEventSink))
633 tms = HeapAlloc(GetProcessHeap(),0,sizeof(ThreadMgrSink));
635 return E_OUTOFMEMORY;
636 if (FAILED(IUnknown_QueryInterface(punk, riid, (LPVOID *)&tms->interfaces.pITfThreadMgrEventSink)))
638 HeapFree(GetProcessHeap(),0,tms);
639 return CONNECT_E_CANNOTCONNECT;
641 list_add_head(&This->ThreadMgrEventSink,&tms->entry);
642 *pdwCookie = generate_Cookie(COOKIE_MAGIC_TMSINK, tms);
646 FIXME("(%p) Unhandled Sink: %s\n",This,debugstr_guid(riid));
650 TRACE("cookie %x\n",*pdwCookie);
655 static WINAPI HRESULT ThreadMgrSource_UnadviseSink(ITfSource *iface, DWORD pdwCookie)
658 ThreadMgr *This = impl_from_ITfSourceVtbl(iface);
660 TRACE("(%p) %x\n",This,pdwCookie);
662 if (get_Cookie_magic(pdwCookie)!=COOKIE_MAGIC_TMSINK)
665 sink = (ThreadMgrSink*)remove_Cookie(pdwCookie);
667 return CONNECT_E_NOCONNECTION;
669 list_remove(&sink->entry);
675 static const ITfSourceVtbl ThreadMgr_SourceVtbl =
677 Source_QueryInterface,
681 ThreadMgrSource_AdviseSink,
682 ThreadMgrSource_UnadviseSink,
685 /*****************************************************
686 * ITfKeystrokeMgr functions
687 *****************************************************/
689 static HRESULT WINAPI KeystrokeMgr_QueryInterface(ITfKeystrokeMgr *iface, REFIID iid, LPVOID *ppvOut)
691 ThreadMgr *This = impl_from_ITfKeystrokeMgrVtbl(iface);
692 return ThreadMgr_QueryInterface((ITfThreadMgr *)This, iid, *ppvOut);
695 static ULONG WINAPI KeystrokeMgr_AddRef(ITfKeystrokeMgr *iface)
697 ThreadMgr *This = impl_from_ITfKeystrokeMgrVtbl(iface);
698 return ThreadMgr_AddRef((ITfThreadMgr*)This);
701 static ULONG WINAPI KeystrokeMgr_Release(ITfKeystrokeMgr *iface)
703 ThreadMgr *This = impl_from_ITfKeystrokeMgrVtbl(iface);
704 return ThreadMgr_Release((ITfThreadMgr *)This);
707 static HRESULT WINAPI KeystrokeMgr_AdviseKeyEventSink(ITfKeystrokeMgr *iface,
708 TfClientId tid, ITfKeyEventSink *pSink, BOOL fForeground)
710 ThreadMgr *This = impl_from_ITfKeystrokeMgrVtbl(iface);
712 ITfKeyEventSink *check = NULL;
714 TRACE("(%p) %x %p %i\n",This,tid,pSink,fForeground);
719 textservice = get_textservice_clsid(tid);
720 if (IsEqualCLSID(&GUID_NULL,&textservice))
723 get_textservice_sink(tid, &IID_ITfKeyEventSink, (IUnknown**)&check);
725 return CONNECT_E_ADVISELIMIT;
727 if (FAILED(IUnknown_QueryInterface(pSink,&IID_ITfKeyEventSink,(LPVOID*) &check)))
730 set_textservice_sink(tid, &IID_ITfKeyEventSink, (IUnknown*)check);
734 if (This->forgroundKeyEventSink)
736 ITfKeyEventSink_OnSetFocus(This->forgroundKeyEventSink, FALSE);
737 ITfKeyEventSink_Release(This->forgroundKeyEventSink);
739 ITfKeyEventSink_AddRef(check);
740 ITfKeyEventSink_OnSetFocus(check, TRUE);
741 This->forgroundKeyEventSink = check;
742 This->forgroundTextService = textservice;
747 static HRESULT WINAPI KeystrokeMgr_UnadviseKeyEventSink(ITfKeystrokeMgr *iface,
750 ThreadMgr *This = impl_from_ITfKeystrokeMgrVtbl(iface);
752 ITfKeyEventSink *check = NULL;
753 TRACE("(%p) %x\n",This,tid);
758 textservice = get_textservice_clsid(tid);
759 if (IsEqualCLSID(&GUID_NULL,&textservice))
762 get_textservice_sink(tid, &IID_ITfKeyEventSink, (IUnknown**)&check);
765 return CONNECT_E_NOCONNECTION;
767 set_textservice_sink(tid, &IID_ITfKeyEventSink, NULL);
768 ITfKeyEventSink_Release(check);
770 if (This->forgroundKeyEventSink == check)
772 ITfKeyEventSink_Release(This->forgroundKeyEventSink);
773 This->forgroundKeyEventSink = NULL;
774 This->forgroundTextService = GUID_NULL;
779 static HRESULT WINAPI KeystrokeMgr_GetForeground(ITfKeystrokeMgr *iface,
782 ThreadMgr *This = impl_from_ITfKeystrokeMgrVtbl(iface);
783 TRACE("(%p) %p\n",This,pclsid);
787 if (IsEqualCLSID(&This->forgroundTextService,&GUID_NULL))
790 *pclsid = This->forgroundTextService;
794 static HRESULT WINAPI KeystrokeMgr_TestKeyDown(ITfKeystrokeMgr *iface,
795 WPARAM wParam, LPARAM lParam, BOOL *pfEaten)
797 ThreadMgr *This = impl_from_ITfKeystrokeMgrVtbl(iface);
798 FIXME("STUB:(%p)\n",This);
802 static HRESULT WINAPI KeystrokeMgr_TestKeyUp(ITfKeystrokeMgr *iface,
803 WPARAM wParam, LPARAM lParam, BOOL *pfEaten)
805 ThreadMgr *This = impl_from_ITfKeystrokeMgrVtbl(iface);
806 FIXME("STUB:(%p)\n",This);
810 static HRESULT WINAPI KeystrokeMgr_KeyDown(ITfKeystrokeMgr *iface,
811 WPARAM wParam, LPARAM lParam, BOOL *pfEaten)
813 ThreadMgr *This = impl_from_ITfKeystrokeMgrVtbl(iface);
814 FIXME("STUB:(%p)\n",This);
818 static HRESULT WINAPI KeystrokeMgr_KeyUp(ITfKeystrokeMgr *iface,
819 WPARAM wParam, LPARAM lParam, BOOL *pfEaten)
821 ThreadMgr *This = impl_from_ITfKeystrokeMgrVtbl(iface);
822 FIXME("STUB:(%p)\n",This);
826 static HRESULT WINAPI KeystrokeMgr_GetPreservedKey(ITfKeystrokeMgr *iface,
827 ITfContext *pic, const TF_PRESERVEDKEY *pprekey, GUID *pguid)
829 ThreadMgr *This = impl_from_ITfKeystrokeMgrVtbl(iface);
830 FIXME("STUB:(%p)\n",This);
834 static HRESULT WINAPI KeystrokeMgr_IsPreservedKey(ITfKeystrokeMgr *iface,
835 REFGUID rguid, const TF_PRESERVEDKEY *pprekey, BOOL *pfRegistered)
837 ThreadMgr *This = impl_from_ITfKeystrokeMgrVtbl(iface);
840 TRACE("(%p) %s (%x %x) %p\n",This,debugstr_guid(rguid), (pprekey)?pprekey->uVKey:0, (pprekey)?pprekey->uModifiers:0, pfRegistered);
842 if (!rguid || !pprekey || !pfRegistered)
845 LIST_FOR_EACH(cursor, &This->CurrentPreservedKeys)
847 PreservedKey* key = LIST_ENTRY(cursor,PreservedKey,entry);
848 if (IsEqualGUID(rguid,&key->guid) && pprekey->uVKey == key->prekey.uVKey && pprekey->uModifiers == key->prekey.uModifiers)
850 *pfRegistered = TRUE;
855 *pfRegistered = FALSE;
859 static HRESULT WINAPI KeystrokeMgr_PreserveKey(ITfKeystrokeMgr *iface,
860 TfClientId tid, REFGUID rguid, const TF_PRESERVEDKEY *prekey,
861 const WCHAR *pchDesc, ULONG cchDesc)
863 ThreadMgr *This = impl_from_ITfKeystrokeMgrVtbl(iface);
865 PreservedKey *newkey;
867 TRACE("(%p) %x %s (%x,%x) %s\n",This,tid, debugstr_guid(rguid),(prekey)?prekey->uVKey:0,(prekey)?prekey->uModifiers:0,debugstr_wn(pchDesc,cchDesc));
869 if (!tid || ! rguid || !prekey || (cchDesc && !pchDesc))
872 LIST_FOR_EACH(cursor, &This->CurrentPreservedKeys)
874 PreservedKey* key = LIST_ENTRY(cursor,PreservedKey,entry);
875 if (IsEqualGUID(rguid,&key->guid) && prekey->uVKey == key->prekey.uVKey && prekey->uModifiers == key->prekey.uModifiers)
876 return TF_E_ALREADY_EXISTS;
879 newkey = HeapAlloc(GetProcessHeap(),0,sizeof(PreservedKey));
881 return E_OUTOFMEMORY;
883 newkey->guid = *rguid;
884 newkey->prekey = *prekey;
888 newkey->description = HeapAlloc(GetProcessHeap(),0,cchDesc * sizeof(WCHAR));
889 if (!newkey->description)
891 HeapFree(GetProcessHeap(),0,newkey);
892 return E_OUTOFMEMORY;
894 memcpy(newkey->description, pchDesc, cchDesc*sizeof(WCHAR));
897 list_add_head(&This->CurrentPreservedKeys,&newkey->entry);
902 static HRESULT WINAPI KeystrokeMgr_UnpreserveKey(ITfKeystrokeMgr *iface,
903 REFGUID rguid, const TF_PRESERVEDKEY *pprekey)
905 ThreadMgr *This = impl_from_ITfKeystrokeMgrVtbl(iface);
906 PreservedKey* key = NULL;
908 TRACE("(%p) %s (%x %x)\n",This,debugstr_guid(rguid),(pprekey)?pprekey->uVKey:0, (pprekey)?pprekey->uModifiers:0);
910 if (!pprekey || !rguid)
913 LIST_FOR_EACH(cursor, &This->CurrentPreservedKeys)
915 key = LIST_ENTRY(cursor,PreservedKey,entry);
916 if (IsEqualGUID(rguid,&key->guid) && pprekey->uVKey == key->prekey.uVKey && pprekey->uModifiers == key->prekey.uModifiers)
922 return CONNECT_E_NOCONNECTION;
924 list_remove(&key->entry);
925 HeapFree(GetProcessHeap(),0,key->description);
926 HeapFree(GetProcessHeap(),0,key);
931 static HRESULT WINAPI KeystrokeMgr_SetPreservedKeyDescription(ITfKeystrokeMgr *iface,
932 REFGUID rguid, const WCHAR *pchDesc, ULONG cchDesc)
934 ThreadMgr *This = impl_from_ITfKeystrokeMgrVtbl(iface);
935 FIXME("STUB:(%p)\n",This);
939 static HRESULT WINAPI KeystrokeMgr_GetPreservedKeyDescription(ITfKeystrokeMgr *iface,
940 REFGUID rguid, BSTR *pbstrDesc)
942 ThreadMgr *This = impl_from_ITfKeystrokeMgrVtbl(iface);
943 FIXME("STUB:(%p)\n",This);
947 static HRESULT WINAPI KeystrokeMgr_SimulatePreservedKey(ITfKeystrokeMgr *iface,
948 ITfContext *pic, REFGUID rguid, BOOL *pfEaten)
950 ThreadMgr *This = impl_from_ITfKeystrokeMgrVtbl(iface);
951 FIXME("STUB:(%p)\n",This);
955 static const ITfKeystrokeMgrVtbl ThreadMgr_KeystrokeMgrVtbl =
957 KeystrokeMgr_QueryInterface,
959 KeystrokeMgr_Release,
961 KeystrokeMgr_AdviseKeyEventSink,
962 KeystrokeMgr_UnadviseKeyEventSink,
963 KeystrokeMgr_GetForeground,
964 KeystrokeMgr_TestKeyDown,
965 KeystrokeMgr_TestKeyUp,
966 KeystrokeMgr_KeyDown,
968 KeystrokeMgr_GetPreservedKey,
969 KeystrokeMgr_IsPreservedKey,
970 KeystrokeMgr_PreserveKey,
971 KeystrokeMgr_UnpreserveKey,
972 KeystrokeMgr_SetPreservedKeyDescription,
973 KeystrokeMgr_GetPreservedKeyDescription,
974 KeystrokeMgr_SimulatePreservedKey
977 /*****************************************************
978 * ITfMessagePump functions
979 *****************************************************/
981 static HRESULT WINAPI MessagePump_QueryInterface(ITfMessagePump *iface, REFIID iid, LPVOID *ppvOut)
983 ThreadMgr *This = impl_from_ITfMessagePumpVtbl(iface);
984 return ThreadMgr_QueryInterface((ITfThreadMgr *)This, iid, *ppvOut);
987 static ULONG WINAPI MessagePump_AddRef(ITfMessagePump *iface)
989 ThreadMgr *This = impl_from_ITfMessagePumpVtbl(iface);
990 return ThreadMgr_AddRef((ITfThreadMgr*)This);
993 static ULONG WINAPI MessagePump_Release(ITfMessagePump *iface)
995 ThreadMgr *This = impl_from_ITfMessagePumpVtbl(iface);
996 return ThreadMgr_Release((ITfThreadMgr *)This);
999 static HRESULT WINAPI MessagePump_PeekMessageA(ITfMessagePump *iface,
1000 LPMSG pMsg, HWND hwnd, UINT wMsgFilterMin, UINT wMsgFilterMax,
1001 UINT wRemoveMsg, BOOL *pfResult)
1004 return E_INVALIDARG;
1005 *pfResult = PeekMessageA(pMsg, hwnd, wMsgFilterMin, wMsgFilterMax, wRemoveMsg);
1009 static HRESULT WINAPI MessagePump_GetMessageA(ITfMessagePump *iface,
1010 LPMSG pMsg, HWND hwnd, UINT wMsgFilterMin, UINT wMsgFilterMax,
1014 return E_INVALIDARG;
1015 *pfResult = GetMessageA(pMsg, hwnd, wMsgFilterMin, wMsgFilterMax);
1019 static HRESULT WINAPI MessagePump_PeekMessageW(ITfMessagePump *iface,
1020 LPMSG pMsg, HWND hwnd, UINT wMsgFilterMin, UINT wMsgFilterMax,
1021 UINT wRemoveMsg, BOOL *pfResult)
1024 return E_INVALIDARG;
1025 *pfResult = PeekMessageW(pMsg, hwnd, wMsgFilterMin, wMsgFilterMax, wRemoveMsg);
1029 static HRESULT WINAPI MessagePump_GetMessageW(ITfMessagePump *iface,
1030 LPMSG pMsg, HWND hwnd, UINT wMsgFilterMin, UINT wMsgFilterMax,
1034 return E_INVALIDARG;
1035 *pfResult = GetMessageW(pMsg, hwnd, wMsgFilterMin, wMsgFilterMax);
1039 static const ITfMessagePumpVtbl ThreadMgr_MessagePumpVtbl =
1041 MessagePump_QueryInterface,
1043 MessagePump_Release,
1045 MessagePump_PeekMessageA,
1046 MessagePump_GetMessageA,
1047 MessagePump_PeekMessageW,
1048 MessagePump_GetMessageW
1051 /*****************************************************
1052 * ITfClientId functions
1053 *****************************************************/
1055 static HRESULT WINAPI ClientId_QueryInterface(ITfClientId *iface, REFIID iid, LPVOID *ppvOut)
1057 ThreadMgr *This = impl_from_ITfClientIdVtbl(iface);
1058 return ThreadMgr_QueryInterface((ITfThreadMgr *)This, iid, *ppvOut);
1061 static ULONG WINAPI ClientId_AddRef(ITfClientId *iface)
1063 ThreadMgr *This = impl_from_ITfClientIdVtbl(iface);
1064 return ThreadMgr_AddRef((ITfThreadMgr*)This);
1067 static ULONG WINAPI ClientId_Release(ITfClientId *iface)
1069 ThreadMgr *This = impl_from_ITfClientIdVtbl(iface);
1070 return ThreadMgr_Release((ITfThreadMgr *)This);
1073 static HRESULT WINAPI ClientId_GetClientId(ITfClientId *iface,
1074 REFCLSID rclsid, TfClientId *ptid)
1078 ITfCategoryMgr *catmgr;
1079 ThreadMgr *This = impl_from_ITfClientIdVtbl(iface);
1081 TRACE("(%p) %s\n",This,debugstr_guid(rclsid));
1083 CategoryMgr_Constructor(NULL,(IUnknown**)&catmgr);
1084 hr = ITfCategoryMgr_RegisterGUID(catmgr,rclsid,ptid);
1085 ITfCategoryMgr_Release(catmgr);
1090 static const ITfClientIdVtbl ThreadMgr_ClientIdVtbl =
1092 ClientId_QueryInterface,
1096 ClientId_GetClientId
1099 /*****************************************************
1100 * ITfThreadMgrEventSink functions (internal)
1101 *****************************************************/
1102 static HRESULT WINAPI ThreadMgrEventSink_QueryInterface(ITfThreadMgrEventSink *iface, REFIID iid, LPVOID *ppvOut)
1104 ThreadMgr *This = impl_from_ITfThreadMgrEventSink(iface);
1105 return ThreadMgr_QueryInterface((ITfThreadMgr *)This, iid, *ppvOut);
1108 static ULONG WINAPI ThreadMgrEventSink_AddRef(ITfThreadMgrEventSink *iface)
1110 ThreadMgr *This = impl_from_ITfThreadMgrEventSink(iface);
1111 return ThreadMgr_AddRef((ITfThreadMgr*)This);
1114 static ULONG WINAPI ThreadMgrEventSink_Release(ITfThreadMgrEventSink *iface)
1116 ThreadMgr *This = impl_from_ITfThreadMgrEventSink(iface);
1117 return ThreadMgr_Release((ITfThreadMgr *)This);
1121 static WINAPI HRESULT ThreadMgrEventSink_OnInitDocumentMgr(
1122 ITfThreadMgrEventSink *iface,ITfDocumentMgr *pdim)
1124 struct list *cursor;
1125 ThreadMgr *This = impl_from_ITfThreadMgrEventSink(iface);
1127 TRACE("(%p) %p\n",This,pdim);
1129 LIST_FOR_EACH(cursor, &This->ThreadMgrEventSink)
1131 ThreadMgrSink* sink = LIST_ENTRY(cursor,ThreadMgrSink,entry);
1132 ITfThreadMgrEventSink_OnInitDocumentMgr(sink->interfaces.pITfThreadMgrEventSink,pdim);
1138 static WINAPI HRESULT ThreadMgrEventSink_OnUninitDocumentMgr(
1139 ITfThreadMgrEventSink *iface, ITfDocumentMgr *pdim)
1141 struct list *cursor;
1142 ThreadMgr *This = impl_from_ITfThreadMgrEventSink(iface);
1144 TRACE("(%p) %p\n",This,pdim);
1146 LIST_FOR_EACH(cursor, &This->ThreadMgrEventSink)
1148 ThreadMgrSink* sink = LIST_ENTRY(cursor,ThreadMgrSink,entry);
1149 ITfThreadMgrEventSink_OnUninitDocumentMgr(sink->interfaces.pITfThreadMgrEventSink,pdim);
1155 static WINAPI HRESULT ThreadMgrEventSink_OnSetFocus(
1156 ITfThreadMgrEventSink *iface, ITfDocumentMgr *pdimFocus,
1157 ITfDocumentMgr *pdimPrevFocus)
1159 struct list *cursor;
1160 ThreadMgr *This = impl_from_ITfThreadMgrEventSink(iface);
1162 TRACE("(%p) %p %p\n",This,pdimFocus, pdimPrevFocus);
1164 LIST_FOR_EACH(cursor, &This->ThreadMgrEventSink)
1166 ThreadMgrSink* sink = LIST_ENTRY(cursor,ThreadMgrSink,entry);
1167 ITfThreadMgrEventSink_OnSetFocus(sink->interfaces.pITfThreadMgrEventSink, pdimFocus, pdimPrevFocus);
1173 static WINAPI HRESULT ThreadMgrEventSink_OnPushContext(
1174 ITfThreadMgrEventSink *iface, ITfContext *pic)
1176 struct list *cursor;
1177 ThreadMgr *This = impl_from_ITfThreadMgrEventSink(iface);
1179 TRACE("(%p) %p\n",This,pic);
1181 LIST_FOR_EACH(cursor, &This->ThreadMgrEventSink)
1183 ThreadMgrSink* sink = LIST_ENTRY(cursor,ThreadMgrSink,entry);
1184 ITfThreadMgrEventSink_OnPushContext(sink->interfaces.pITfThreadMgrEventSink,pic);
1190 static WINAPI HRESULT ThreadMgrEventSink_OnPopContext(
1191 ITfThreadMgrEventSink *iface, ITfContext *pic)
1193 struct list *cursor;
1194 ThreadMgr *This = impl_from_ITfThreadMgrEventSink(iface);
1196 TRACE("(%p) %p\n",This,pic);
1198 LIST_FOR_EACH(cursor, &This->ThreadMgrEventSink)
1200 ThreadMgrSink* sink = LIST_ENTRY(cursor,ThreadMgrSink,entry);
1201 ITfThreadMgrEventSink_OnPopContext(sink->interfaces.pITfThreadMgrEventSink,pic);
1207 static const ITfThreadMgrEventSinkVtbl ThreadMgr_ThreadMgrEventSinkVtbl =
1209 ThreadMgrEventSink_QueryInterface,
1210 ThreadMgrEventSink_AddRef,
1211 ThreadMgrEventSink_Release,
1213 ThreadMgrEventSink_OnInitDocumentMgr,
1214 ThreadMgrEventSink_OnUninitDocumentMgr,
1215 ThreadMgrEventSink_OnSetFocus,
1216 ThreadMgrEventSink_OnPushContext,
1217 ThreadMgrEventSink_OnPopContext
1220 /*****************************************************
1221 * ITfSourceSingle functions
1222 *****************************************************/
1223 static HRESULT WINAPI ThreadMgrSourceSingle_QueryInterface(ITfSourceSingle *iface, REFIID iid, LPVOID *ppvOut)
1225 ThreadMgr *This = impl_from_ITfSourceSingleVtbl(iface);
1226 return ThreadMgr_QueryInterface((ITfThreadMgr *)This, iid, *ppvOut);
1229 static ULONG WINAPI ThreadMgrSourceSingle_AddRef(ITfSourceSingle *iface)
1231 ThreadMgr *This = impl_from_ITfSourceSingleVtbl(iface);
1232 return ThreadMgr_AddRef((ITfThreadMgr *)This);
1235 static ULONG WINAPI ThreadMgrSourceSingle_Release(ITfSourceSingle *iface)
1237 ThreadMgr *This = impl_from_ITfSourceSingleVtbl(iface);
1238 return ThreadMgr_Release((ITfThreadMgr *)This);
1241 static WINAPI HRESULT ThreadMgrSourceSingle_AdviseSingleSink( ITfSourceSingle *iface,
1242 TfClientId tid, REFIID riid, IUnknown *punk)
1244 ThreadMgr *This = impl_from_ITfSourceSingleVtbl(iface);
1245 FIXME("STUB:(%p) %i %s %p\n",This, tid, debugstr_guid(riid),punk);
1249 static WINAPI HRESULT ThreadMgrSourceSingle_UnadviseSingleSink( ITfSourceSingle *iface,
1250 TfClientId tid, REFIID riid)
1252 ThreadMgr *This = impl_from_ITfSourceSingleVtbl(iface);
1253 FIXME("STUB:(%p) %i %s\n",This, tid, debugstr_guid(riid));
1257 static const ITfSourceSingleVtbl ThreadMgr_SourceSingleVtbl =
1259 ThreadMgrSourceSingle_QueryInterface,
1260 ThreadMgrSourceSingle_AddRef,
1261 ThreadMgrSourceSingle_Release,
1263 ThreadMgrSourceSingle_AdviseSingleSink,
1264 ThreadMgrSourceSingle_UnadviseSingleSink,
1267 HRESULT ThreadMgr_Constructor(IUnknown *pUnkOuter, IUnknown **ppOut)
1271 return CLASS_E_NOAGGREGATION;
1273 /* Only 1 ThreadMgr is created per thread */
1274 This = TlsGetValue(tlsIndex);
1277 ThreadMgr_AddRef((ITfThreadMgr*)This);
1278 *ppOut = (IUnknown*)This;
1282 This = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(ThreadMgr));
1284 return E_OUTOFMEMORY;
1286 This->ThreadMgrVtbl= &ThreadMgr_ThreadMgrVtbl;
1287 This->SourceVtbl = &ThreadMgr_SourceVtbl;
1288 This->KeystrokeMgrVtbl= &ThreadMgr_KeystrokeMgrVtbl;
1289 This->MessagePumpVtbl= &ThreadMgr_MessagePumpVtbl;
1290 This->ClientIdVtbl = &ThreadMgr_ClientIdVtbl;
1291 This->ThreadMgrEventSinkVtbl = &ThreadMgr_ThreadMgrEventSinkVtbl;
1292 This->SourceSingleVtbl = &ThreadMgr_SourceSingleVtbl;
1294 TlsSetValue(tlsIndex,This);
1296 CompartmentMgr_Constructor((IUnknown*)This, &IID_IUnknown, (IUnknown**)&This->CompartmentMgr);
1298 list_init(&This->CurrentPreservedKeys);
1299 list_init(&This->CreatedDocumentMgrs);
1300 list_init(&This->AssociatedFocusWindows);
1302 list_init(&This->ActiveLanguageProfileNotifySink);
1303 list_init(&This->DisplayAttributeNotifySink);
1304 list_init(&This->KeyTraceEventSink);
1305 list_init(&This->PreservedKeyNotifySink);
1306 list_init(&This->ThreadFocusSink);
1307 list_init(&This->ThreadMgrEventSink);
1309 TRACE("returning %p\n", This);
1310 *ppOut = (IUnknown *)This;
1314 /**************************************************
1315 * IEnumTfDocumentMgrs implementaion
1316 **************************************************/
1317 static void EnumTfDocumentMgr_Destructor(EnumTfDocumentMgr *This)
1319 TRACE("destroying %p\n", This);
1320 HeapFree(GetProcessHeap(),0,This);
1323 static HRESULT WINAPI EnumTfDocumentMgr_QueryInterface(IEnumTfDocumentMgrs *iface, REFIID iid, LPVOID *ppvOut)
1325 EnumTfDocumentMgr *This = (EnumTfDocumentMgr *)iface;
1328 if (IsEqualIID(iid, &IID_IUnknown) || IsEqualIID(iid, &IID_IEnumTfDocumentMgrs))
1335 IUnknown_AddRef(iface);
1339 WARN("unsupported interface: %s\n", debugstr_guid(iid));
1340 return E_NOINTERFACE;
1343 static ULONG WINAPI EnumTfDocumentMgr_AddRef(IEnumTfDocumentMgrs *iface)
1345 EnumTfDocumentMgr *This = (EnumTfDocumentMgr*)iface;
1346 return InterlockedIncrement(&This->refCount);
1349 static ULONG WINAPI EnumTfDocumentMgr_Release(IEnumTfDocumentMgrs *iface)
1351 EnumTfDocumentMgr *This = (EnumTfDocumentMgr *)iface;
1354 ret = InterlockedDecrement(&This->refCount);
1356 EnumTfDocumentMgr_Destructor(This);
1360 static HRESULT WINAPI EnumTfDocumentMgr_Next(IEnumTfDocumentMgrs *iface,
1361 ULONG ulCount, ITfDocumentMgr **rgDocumentMgr, ULONG *pcFetched)
1363 EnumTfDocumentMgr *This = (EnumTfDocumentMgr *)iface;
1366 TRACE("(%p)\n",This);
1368 if (rgDocumentMgr == NULL) return E_POINTER;
1370 while (fetched < ulCount)
1372 DocumentMgrEntry *mgrentry;
1373 if (This->index == NULL)
1376 mgrentry = LIST_ENTRY(This->index,DocumentMgrEntry,entry);
1377 if (mgrentry == NULL)
1380 *rgDocumentMgr = mgrentry->docmgr;
1381 ITfDocumentMgr_AddRef(*rgDocumentMgr);
1383 This->index = list_next(This->head, This->index);
1388 if (pcFetched) *pcFetched = fetched;
1389 return fetched == ulCount ? S_OK : S_FALSE;
1392 static HRESULT WINAPI EnumTfDocumentMgr_Skip( IEnumTfDocumentMgrs* iface, ULONG celt)
1395 EnumTfDocumentMgr *This = (EnumTfDocumentMgr *)iface;
1396 TRACE("(%p)\n",This);
1397 for(i = 0; i < celt && This->index != NULL; i++)
1398 This->index = list_next(This->head, This->index);
1402 static HRESULT WINAPI EnumTfDocumentMgr_Reset( IEnumTfDocumentMgrs* iface)
1404 EnumTfDocumentMgr *This = (EnumTfDocumentMgr *)iface;
1405 TRACE("(%p)\n",This);
1406 This->index = list_head(This->head);
1410 static HRESULT WINAPI EnumTfDocumentMgr_Clone( IEnumTfDocumentMgrs *iface,
1411 IEnumTfDocumentMgrs **ppenum)
1413 EnumTfDocumentMgr *This = (EnumTfDocumentMgr *)iface;
1416 TRACE("(%p)\n",This);
1418 if (ppenum == NULL) return E_POINTER;
1420 res = EnumTfDocumentMgr_Constructor(This->head, ppenum);
1423 EnumTfDocumentMgr *new_This = (EnumTfDocumentMgr *)*ppenum;
1424 new_This->index = This->index;
1429 static const IEnumTfDocumentMgrsVtbl IEnumTfDocumentMgrs_Vtbl ={
1430 EnumTfDocumentMgr_QueryInterface,
1431 EnumTfDocumentMgr_AddRef,
1432 EnumTfDocumentMgr_Release,
1434 EnumTfDocumentMgr_Clone,
1435 EnumTfDocumentMgr_Next,
1436 EnumTfDocumentMgr_Reset,
1437 EnumTfDocumentMgr_Skip
1440 static HRESULT EnumTfDocumentMgr_Constructor(struct list* head, IEnumTfDocumentMgrs **ppOut)
1442 EnumTfDocumentMgr *This;
1444 This = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(EnumTfDocumentMgr));
1446 return E_OUTOFMEMORY;
1448 This->Vtbl= &IEnumTfDocumentMgrs_Vtbl;
1451 This->index = list_head(This->head);
1453 TRACE("returning %p\n", This);
1454 *ppOut = (IEnumTfDocumentMgrs*)This;
1458 void ThreadMgr_OnDocumentMgrDestruction(ITfThreadMgr *tm, ITfDocumentMgr *mgr)
1460 ThreadMgr *This = (ThreadMgr *)tm;
1461 struct list *cursor;
1462 LIST_FOR_EACH(cursor, &This->CreatedDocumentMgrs)
1464 DocumentMgrEntry *mgrentry = LIST_ENTRY(cursor,DocumentMgrEntry,entry);
1465 if (mgrentry->docmgr == mgr)
1467 list_remove(cursor);
1468 HeapFree(GetProcessHeap(),0,mgrentry);
1472 FIXME("ITfDocumenMgr %p not found in this thread\n",mgr);