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 <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 "msctf.h"
|
|
|
|
#include "msctf_internal.h"
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(msctf);
|
|
|
|
|
2009-05-07 15:31:32 +02:00
|
|
|
typedef struct tagPreservedKey
|
|
|
|
{
|
|
|
|
struct list entry;
|
|
|
|
GUID guid;
|
|
|
|
TF_PRESERVEDKEY prekey;
|
|
|
|
LPWSTR description;
|
|
|
|
TfClientId tid;
|
|
|
|
} PreservedKey;
|
|
|
|
|
2009-07-10 14:36:56 +02:00
|
|
|
typedef struct tagDocumentMgrs
|
|
|
|
{
|
|
|
|
struct list entry;
|
|
|
|
ITfDocumentMgr *docmgr;
|
|
|
|
} DocumentMgrEntry;
|
|
|
|
|
2009-09-01 14:07:57 +02:00
|
|
|
typedef struct tagAssociatedWindow
|
|
|
|
{
|
|
|
|
struct list entry;
|
|
|
|
HWND hwnd;
|
|
|
|
ITfDocumentMgr *docmgr;
|
|
|
|
} AssociatedWindow;
|
|
|
|
|
2009-01-27 21:15:30 +01:00
|
|
|
typedef struct tagACLMulti {
|
2015-10-28 22:27:25 +01:00
|
|
|
ITfThreadMgrEx ITfThreadMgrEx_iface;
|
2013-11-17 09:21:51 +01:00
|
|
|
ITfSource ITfSource_iface;
|
|
|
|
ITfKeystrokeMgr ITfKeystrokeMgr_iface;
|
|
|
|
ITfMessagePump ITfMessagePump_iface;
|
|
|
|
ITfClientId ITfClientId_iface;
|
2009-05-13 21:45:44 +02:00
|
|
|
/* const ITfThreadMgrExVtbl *ThreadMgrExVtbl; */
|
|
|
|
/* const ITfConfigureSystemKeystrokeFeedVtbl *ConfigureSystemKeystrokeFeedVtbl; */
|
|
|
|
/* const ITfLangBarItemMgrVtbl *LangBarItemMgrVtbl; */
|
2015-10-28 22:27:26 +01:00
|
|
|
ITfUIElementMgr ITfUIElementMgr_iface;
|
2013-11-17 09:21:51 +01:00
|
|
|
ITfSourceSingle ITfSourceSingle_iface;
|
2009-01-27 21:15:30 +01:00
|
|
|
LONG refCount;
|
2009-02-02 17:24:41 +01:00
|
|
|
|
2009-06-11 20:33:07 +02:00
|
|
|
/* Aggregation */
|
|
|
|
ITfCompartmentMgr *CompartmentMgr;
|
|
|
|
|
2013-11-17 09:21:51 +01:00
|
|
|
ITfThreadMgrEventSink ITfThreadMgrEventSink_iface; /* internal */
|
2009-03-24 14:21:47 +01:00
|
|
|
|
2009-02-02 17:24:41 +01:00
|
|
|
ITfDocumentMgr *focus;
|
2009-05-07 21:28:00 +02:00
|
|
|
LONG activationCount;
|
2009-03-24 14:21:28 +01:00
|
|
|
|
2016-04-13 11:30:37 +02:00
|
|
|
ITfKeyEventSink *foregroundKeyEventSink;
|
|
|
|
CLSID foregroundTextService;
|
2009-05-08 15:50:59 +02:00
|
|
|
|
2009-05-07 15:31:32 +02:00
|
|
|
struct list CurrentPreservedKeys;
|
2009-07-10 14:36:56 +02:00
|
|
|
struct list CreatedDocumentMgrs;
|
2009-05-07 15:31:32 +02:00
|
|
|
|
2009-09-01 14:07:57 +02:00
|
|
|
struct list AssociatedFocusWindows;
|
|
|
|
HHOOK focusHook;
|
|
|
|
|
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;
|
2019-07-22 18:39:06 +02:00
|
|
|
struct list UIElementSink;
|
2019-07-25 20:35:05 +02:00
|
|
|
struct list InputProcessorProfileActivationSink;
|
2009-01-27 21:15:30 +01:00
|
|
|
} ThreadMgr;
|
|
|
|
|
2009-07-10 14:38:20 +02:00
|
|
|
typedef struct tagEnumTfDocumentMgr {
|
2013-11-17 09:21:51 +01:00
|
|
|
IEnumTfDocumentMgrs IEnumTfDocumentMgrs_iface;
|
2009-07-10 14:38:20 +02:00
|
|
|
LONG refCount;
|
|
|
|
|
|
|
|
struct list *index;
|
|
|
|
struct list *head;
|
|
|
|
} EnumTfDocumentMgr;
|
|
|
|
|
|
|
|
static HRESULT EnumTfDocumentMgr_Constructor(struct list* head, IEnumTfDocumentMgrs **ppOut);
|
|
|
|
|
2015-10-28 22:27:25 +01:00
|
|
|
static inline ThreadMgr *impl_from_ITfThreadMgrEx(ITfThreadMgrEx *iface)
|
2009-02-02 17:25:49 +01:00
|
|
|
{
|
2015-10-28 22:27:25 +01:00
|
|
|
return CONTAINING_RECORD(iface, ThreadMgr, ITfThreadMgrEx_iface);
|
2009-02-02 17:25:49 +01:00
|
|
|
}
|
|
|
|
|
2013-11-17 09:21:51 +01:00
|
|
|
static inline ThreadMgr *impl_from_ITfSource(ITfSource *iface)
|
2009-04-22 19:37:43 +02:00
|
|
|
{
|
2013-11-17 09:21:51 +01:00
|
|
|
return CONTAINING_RECORD(iface, ThreadMgr, ITfSource_iface);
|
2009-04-22 19:37:43 +02:00
|
|
|
}
|
|
|
|
|
2013-11-17 09:21:51 +01:00
|
|
|
static inline ThreadMgr *impl_from_ITfKeystrokeMgr(ITfKeystrokeMgr *iface)
|
2009-05-05 17:52:00 +02:00
|
|
|
{
|
2013-11-17 09:21:51 +01:00
|
|
|
return CONTAINING_RECORD(iface, ThreadMgr, ITfKeystrokeMgr_iface);
|
2009-05-05 17:52:00 +02:00
|
|
|
}
|
|
|
|
|
2013-11-17 09:21:51 +01:00
|
|
|
static inline ThreadMgr *impl_from_ITfMessagePump(ITfMessagePump *iface)
|
2009-05-06 17:35:52 +02:00
|
|
|
{
|
2013-11-17 09:21:51 +01:00
|
|
|
return CONTAINING_RECORD(iface, ThreadMgr, ITfMessagePump_iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline ThreadMgr *impl_from_ITfClientId(ITfClientId *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, ThreadMgr, ITfClientId_iface);
|
2009-05-06 17:35:52 +02:00
|
|
|
}
|
|
|
|
|
2009-03-24 14:21:47 +01:00
|
|
|
static inline ThreadMgr *impl_from_ITfThreadMgrEventSink(ITfThreadMgrEventSink *iface)
|
|
|
|
{
|
2013-11-17 09:21:51 +01:00
|
|
|
return CONTAINING_RECORD(iface, ThreadMgr, ITfThreadMgrEventSink_iface);
|
2009-03-24 14:21:47 +01:00
|
|
|
}
|
|
|
|
|
2015-10-28 22:27:26 +01:00
|
|
|
static inline ThreadMgr *impl_from_ITfUIElementMgr(ITfUIElementMgr *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, ThreadMgr, ITfUIElementMgr_iface);
|
|
|
|
}
|
|
|
|
|
2013-11-17 09:21:51 +01:00
|
|
|
static inline ThreadMgr *impl_from_ITfSourceSingle(ITfSourceSingle *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, ThreadMgr, ITfSourceSingle_iface);
|
|
|
|
}
|
2009-09-08 17:30:10 +02:00
|
|
|
|
2013-11-17 09:21:51 +01:00
|
|
|
static inline EnumTfDocumentMgr *impl_from_IEnumTfDocumentMgrs(IEnumTfDocumentMgrs *iface)
|
2009-09-08 17:30:10 +02:00
|
|
|
{
|
2013-11-17 09:21:51 +01:00
|
|
|
return CONTAINING_RECORD(iface, EnumTfDocumentMgr, IEnumTfDocumentMgrs_iface);
|
2009-09-08 17:30:10 +02:00
|
|
|
}
|
|
|
|
|
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-09-01 14:07:57 +02:00
|
|
|
/* unhook right away */
|
|
|
|
if (This->focusHook)
|
|
|
|
UnhookWindowsHookEx(This->focusHook);
|
|
|
|
|
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
|
|
|
|
2016-05-04 19:41:13 +02:00
|
|
|
free_sinks(&This->ActiveLanguageProfileNotifySink);
|
|
|
|
free_sinks(&This->DisplayAttributeNotifySink);
|
|
|
|
free_sinks(&This->KeyTraceEventSink);
|
|
|
|
free_sinks(&This->PreservedKeyNotifySink);
|
|
|
|
free_sinks(&This->ThreadFocusSink);
|
|
|
|
free_sinks(&This->ThreadMgrEventSink);
|
2019-07-22 18:39:06 +02:00
|
|
|
free_sinks(&This->UIElementSink);
|
2019-07-25 20:35:05 +02:00
|
|
|
free_sinks(&This->InputProcessorProfileActivationSink);
|
2009-03-24 14:21:28 +01:00
|
|
|
|
2009-05-07 15:31:32 +02:00
|
|
|
LIST_FOR_EACH_SAFE(cursor, cursor2, &This->CurrentPreservedKeys)
|
|
|
|
{
|
|
|
|
PreservedKey* key = LIST_ENTRY(cursor,PreservedKey,entry);
|
|
|
|
list_remove(cursor);
|
|
|
|
HeapFree(GetProcessHeap(),0,key->description);
|
|
|
|
HeapFree(GetProcessHeap(),0,key);
|
|
|
|
}
|
|
|
|
|
2009-07-10 14:36:56 +02:00
|
|
|
LIST_FOR_EACH_SAFE(cursor, cursor2, &This->CreatedDocumentMgrs)
|
|
|
|
{
|
|
|
|
DocumentMgrEntry *mgr = LIST_ENTRY(cursor,DocumentMgrEntry,entry);
|
|
|
|
list_remove(cursor);
|
|
|
|
FIXME("Left Over ITfDocumentMgr. Should we do something with it?\n");
|
|
|
|
HeapFree(GetProcessHeap(),0,mgr);
|
|
|
|
}
|
|
|
|
|
2009-09-01 14:07:57 +02:00
|
|
|
LIST_FOR_EACH_SAFE(cursor, cursor2, &This->AssociatedFocusWindows)
|
|
|
|
{
|
|
|
|
AssociatedWindow *wnd = LIST_ENTRY(cursor,AssociatedWindow,entry);
|
|
|
|
list_remove(cursor);
|
|
|
|
HeapFree(GetProcessHeap(),0,wnd);
|
|
|
|
}
|
|
|
|
|
2009-06-11 20:33:07 +02:00
|
|
|
CompartmentMgr_Destructor(This->CompartmentMgr);
|
|
|
|
|
2009-01-27 21:15:30 +01:00
|
|
|
HeapFree(GetProcessHeap(),0,This);
|
|
|
|
}
|
|
|
|
|
2015-10-28 22:27:25 +01:00
|
|
|
static HRESULT WINAPI ThreadMgr_QueryInterface(ITfThreadMgrEx *iface, REFIID iid, LPVOID *ppvOut)
|
2009-01-27 21:15:30 +01:00
|
|
|
{
|
2015-10-28 22:27:25 +01:00
|
|
|
ThreadMgr *This = impl_from_ITfThreadMgrEx(iface);
|
2009-01-27 21:15:30 +01:00
|
|
|
*ppvOut = NULL;
|
|
|
|
|
2015-10-28 22:27:25 +01:00
|
|
|
if (IsEqualIID(iid, &IID_IUnknown) || IsEqualIID(iid, &IID_ITfThreadMgr)
|
|
|
|
|| IsEqualIID(iid, &IID_ITfThreadMgrEx))
|
2009-01-27 21:15:30 +01:00
|
|
|
{
|
2015-10-28 22:27:25 +01:00
|
|
|
*ppvOut = &This->ITfThreadMgrEx_iface;
|
2009-01-27 21:15:30 +01:00
|
|
|
}
|
2009-02-02 17:25:49 +01:00
|
|
|
else if (IsEqualIID(iid, &IID_ITfSource))
|
|
|
|
{
|
2013-11-17 09:21:51 +01:00
|
|
|
*ppvOut = &This->ITfSource_iface;
|
2009-02-02 17:25:49 +01:00
|
|
|
}
|
2009-04-22 19:37:43 +02:00
|
|
|
else if (IsEqualIID(iid, &IID_ITfKeystrokeMgr))
|
|
|
|
{
|
2013-11-17 09:21:51 +01:00
|
|
|
*ppvOut = &This->ITfKeystrokeMgr_iface;
|
2009-04-22 19:37:43 +02:00
|
|
|
}
|
2009-05-05 17:52:00 +02:00
|
|
|
else if (IsEqualIID(iid, &IID_ITfMessagePump))
|
|
|
|
{
|
2013-11-17 09:21:51 +01:00
|
|
|
*ppvOut = &This->ITfMessagePump_iface;
|
2009-05-05 17:52:00 +02:00
|
|
|
}
|
2009-05-06 17:35:52 +02:00
|
|
|
else if (IsEqualIID(iid, &IID_ITfClientId))
|
|
|
|
{
|
2013-11-17 09:21:51 +01:00
|
|
|
*ppvOut = &This->ITfClientId_iface;
|
2009-05-06 17:35:52 +02:00
|
|
|
}
|
2009-06-11 20:33:07 +02:00
|
|
|
else if (IsEqualIID(iid, &IID_ITfCompartmentMgr))
|
|
|
|
{
|
|
|
|
*ppvOut = This->CompartmentMgr;
|
|
|
|
}
|
2015-10-28 22:27:26 +01:00
|
|
|
else if (IsEqualIID(iid, &IID_ITfUIElementMgr))
|
|
|
|
{
|
|
|
|
*ppvOut = &This->ITfUIElementMgr_iface;
|
|
|
|
}
|
2009-09-08 17:30:10 +02:00
|
|
|
else if (IsEqualIID(iid, &IID_ITfSourceSingle))
|
|
|
|
{
|
2013-11-17 09:21:51 +01:00
|
|
|
*ppvOut = &This->ITfSourceSingle_iface;
|
2009-09-08 17:30:10 +02:00
|
|
|
}
|
2009-01-27 21:15:30 +01:00
|
|
|
|
|
|
|
if (*ppvOut)
|
|
|
|
{
|
2015-10-28 22:27:25 +01:00
|
|
|
ITfThreadMgrEx_AddRef(iface);
|
2009-01-27 21:15:30 +01:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
WARN("unsupported interface: %s\n", debugstr_guid(iid));
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
2015-10-28 22:27:25 +01:00
|
|
|
static ULONG WINAPI ThreadMgr_AddRef(ITfThreadMgrEx *iface)
|
2009-01-27 21:15:30 +01:00
|
|
|
{
|
2015-10-28 22:27:25 +01:00
|
|
|
ThreadMgr *This = impl_from_ITfThreadMgrEx(iface);
|
2009-01-27 21:15:30 +01:00
|
|
|
return InterlockedIncrement(&This->refCount);
|
|
|
|
}
|
|
|
|
|
2015-10-28 22:27:25 +01:00
|
|
|
static ULONG WINAPI ThreadMgr_Release(ITfThreadMgrEx *iface)
|
2009-01-27 21:15:30 +01:00
|
|
|
{
|
2015-10-28 22:27:25 +01:00
|
|
|
ThreadMgr *This = impl_from_ITfThreadMgrEx(iface);
|
2009-01-27 21:15:30 +01:00
|
|
|
ULONG ret;
|
|
|
|
|
|
|
|
ret = InterlockedDecrement(&This->refCount);
|
|
|
|
if (ret == 0)
|
|
|
|
ThreadMgr_Destructor(This);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************
|
|
|
|
* ITfThreadMgr functions
|
|
|
|
*****************************************************/
|
|
|
|
|
2015-11-27 20:39:30 +01:00
|
|
|
static HRESULT WINAPI ThreadMgr_Activate(ITfThreadMgrEx *iface, TfClientId *id)
|
2009-01-27 21:15:30 +01:00
|
|
|
{
|
2015-10-28 22:27:25 +01:00
|
|
|
ThreadMgr *This = impl_from_ITfThreadMgrEx(iface);
|
2009-05-07 21:28:00 +02:00
|
|
|
|
2015-11-27 20:39:30 +01:00
|
|
|
TRACE("(%p) %p\n", This, id);
|
|
|
|
return ITfThreadMgrEx_ActivateEx(iface, id, 0);
|
2009-01-27 21:15:30 +01:00
|
|
|
}
|
|
|
|
|
2015-11-27 20:39:30 +01:00
|
|
|
static HRESULT WINAPI ThreadMgr_Deactivate(ITfThreadMgrEx *iface)
|
2009-01-27 21:15:30 +01:00
|
|
|
{
|
2015-10-28 22:27:25 +01:00
|
|
|
ThreadMgr *This = impl_from_ITfThreadMgrEx(iface);
|
2009-05-07 21:28:00 +02:00
|
|
|
TRACE("(%p)\n",This);
|
2009-04-10 18:26:51 +02:00
|
|
|
|
2009-05-07 21:28:00 +02:00
|
|
|
if (This->activationCount == 0)
|
|
|
|
return E_UNEXPECTED;
|
|
|
|
|
|
|
|
This->activationCount --;
|
|
|
|
|
|
|
|
if (This->activationCount == 0)
|
2009-04-10 18:26:51 +02:00
|
|
|
{
|
2009-05-07 21:28:00 +02:00
|
|
|
if (This->focus)
|
|
|
|
{
|
2013-11-17 09:21:51 +01:00
|
|
|
ITfThreadMgrEventSink_OnSetFocus(&This->ITfThreadMgrEventSink_iface, 0, This->focus);
|
2009-05-07 21:28:00 +02:00
|
|
|
ITfDocumentMgr_Release(This->focus);
|
|
|
|
This->focus = 0;
|
|
|
|
}
|
2009-04-10 18:26:51 +02:00
|
|
|
}
|
|
|
|
|
2009-05-07 21:28:00 +02:00
|
|
|
deactivate_textservices();
|
|
|
|
|
|
|
|
return S_OK;
|
2009-01-27 21:15:30 +01:00
|
|
|
}
|
|
|
|
|
2015-10-28 22:27:25 +01:00
|
|
|
static HRESULT WINAPI ThreadMgr_CreateDocumentMgr(ITfThreadMgrEx *iface, ITfDocumentMgr **ppdim)
|
2009-01-27 21:15:30 +01:00
|
|
|
{
|
2015-10-28 22:27:25 +01:00
|
|
|
ThreadMgr *This = impl_from_ITfThreadMgrEx(iface);
|
2009-07-10 14:36:56 +02:00
|
|
|
DocumentMgrEntry *mgrentry;
|
|
|
|
HRESULT hr;
|
|
|
|
|
2009-01-30 21:27:06 +01:00
|
|
|
TRACE("(%p)\n",iface);
|
2009-07-10 14:36:56 +02:00
|
|
|
mgrentry = HeapAlloc(GetProcessHeap(),0,sizeof(DocumentMgrEntry));
|
|
|
|
if (mgrentry == NULL)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
2013-11-17 09:21:51 +01:00
|
|
|
hr = DocumentMgr_Constructor(&This->ITfThreadMgrEventSink_iface, ppdim);
|
2009-07-10 14:36:56 +02:00
|
|
|
|
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
{
|
|
|
|
mgrentry->docmgr = *ppdim;
|
|
|
|
list_add_head(&This->CreatedDocumentMgrs,&mgrentry->entry);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
HeapFree(GetProcessHeap(),0,mgrentry);
|
|
|
|
|
|
|
|
return hr;
|
2009-01-27 21:15:30 +01:00
|
|
|
}
|
|
|
|
|
2015-10-28 22:27:25 +01:00
|
|
|
static HRESULT WINAPI ThreadMgr_EnumDocumentMgrs(ITfThreadMgrEx *iface, IEnumTfDocumentMgrs **ppEnum)
|
2009-01-27 21:15:30 +01:00
|
|
|
{
|
2015-10-28 22:27:25 +01:00
|
|
|
ThreadMgr *This = impl_from_ITfThreadMgrEx(iface);
|
2009-07-10 14:38:20 +02:00
|
|
|
TRACE("(%p) %p\n",This,ppEnum);
|
|
|
|
|
|
|
|
if (!ppEnum)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
return EnumTfDocumentMgr_Constructor(&This->CreatedDocumentMgrs, ppEnum);
|
2009-01-27 21:15:30 +01:00
|
|
|
}
|
|
|
|
|
2015-10-28 22:27:25 +01:00
|
|
|
static HRESULT WINAPI ThreadMgr_GetFocus(ITfThreadMgrEx *iface, ITfDocumentMgr **ppdimFocus)
|
2009-01-27 21:15:30 +01:00
|
|
|
{
|
2015-10-28 22:27:25 +01:00
|
|
|
ThreadMgr *This = impl_from_ITfThreadMgrEx(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
|
|
|
}
|
|
|
|
|
2015-10-28 22:27:25 +01:00
|
|
|
static HRESULT WINAPI ThreadMgr_SetFocus(ITfThreadMgrEx *iface, ITfDocumentMgr *pdimFocus)
|
2009-01-27 21:15:30 +01:00
|
|
|
{
|
2015-10-28 22:27:25 +01:00
|
|
|
ThreadMgr *This = impl_from_ITfThreadMgrEx(iface);
|
2009-02-02 17:24:41 +01:00
|
|
|
ITfDocumentMgr *check;
|
|
|
|
|
|
|
|
TRACE("(%p) %p\n",This,pdimFocus);
|
|
|
|
|
2009-08-31 21:48:40 +02:00
|
|
|
if (!pdimFocus)
|
|
|
|
check = NULL;
|
2012-08-19 20:01:36 +02:00
|
|
|
else if (FAILED(ITfDocumentMgr_QueryInterface(pdimFocus,&IID_ITfDocumentMgr,(LPVOID*) &check)))
|
2009-02-02 17:24:41 +01:00
|
|
|
return E_INVALIDARG;
|
|
|
|
|
2013-11-17 09:21:51 +01:00
|
|
|
ITfThreadMgrEventSink_OnSetFocus(&This->ITfThreadMgrEventSink_iface, 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
|
|
|
}
|
|
|
|
|
2009-09-10 17:58:54 +02:00
|
|
|
static LRESULT CALLBACK ThreadFocusHookProc(int nCode, WPARAM wParam, LPARAM lParam)
|
2009-09-10 17:58:44 +02:00
|
|
|
{
|
|
|
|
ThreadMgr *This;
|
|
|
|
|
|
|
|
This = TlsGetValue(tlsIndex);
|
|
|
|
if (!This)
|
|
|
|
{
|
|
|
|
ERR("Hook proc but no ThreadMgr for this thread. Serious Error\n");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
if (!This->focusHook)
|
|
|
|
{
|
|
|
|
ERR("Hook proc but no ThreadMgr focus Hook. Serious Error\n");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (nCode == HCBT_SETFOCUS) /* focus change within our thread */
|
|
|
|
{
|
|
|
|
struct list *cursor;
|
|
|
|
|
|
|
|
LIST_FOR_EACH(cursor, &This->AssociatedFocusWindows)
|
|
|
|
{
|
|
|
|
AssociatedWindow *wnd = LIST_ENTRY(cursor,AssociatedWindow,entry);
|
|
|
|
if (wnd->hwnd == (HWND)wParam)
|
|
|
|
{
|
|
|
|
TRACE("Triggering Associated window focus\n");
|
|
|
|
if (This->focus != wnd->docmgr)
|
2015-10-28 22:27:25 +01:00
|
|
|
ThreadMgr_SetFocus(&This->ITfThreadMgrEx_iface, wnd->docmgr);
|
2009-09-10 17:58:44 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return CallNextHookEx(This->focusHook, nCode, wParam, lParam);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT SetupWindowsHook(ThreadMgr *This)
|
|
|
|
{
|
|
|
|
if (!This->focusHook)
|
|
|
|
{
|
|
|
|
This->focusHook = SetWindowsHookExW(WH_CBT, ThreadFocusHookProc, 0,
|
|
|
|
GetCurrentThreadId());
|
|
|
|
if (!This->focusHook)
|
|
|
|
{
|
|
|
|
ERR("Unable to set focus hook\n");
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
return S_FALSE;
|
|
|
|
}
|
|
|
|
|
2015-10-28 22:27:25 +01:00
|
|
|
static HRESULT WINAPI ThreadMgr_AssociateFocus(ITfThreadMgrEx *iface, HWND hwnd,
|
2009-01-27 21:15:30 +01:00
|
|
|
ITfDocumentMgr *pdimNew, ITfDocumentMgr **ppdimPrev)
|
|
|
|
{
|
2015-10-28 22:27:25 +01:00
|
|
|
ThreadMgr *This = impl_from_ITfThreadMgrEx(iface);
|
2009-09-01 14:07:57 +02:00
|
|
|
struct list *cursor, *cursor2;
|
|
|
|
AssociatedWindow *wnd;
|
|
|
|
|
|
|
|
TRACE("(%p) %p %p %p\n",This,hwnd,pdimNew,ppdimPrev);
|
|
|
|
|
|
|
|
if (!ppdimPrev)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
*ppdimPrev = NULL;
|
|
|
|
|
|
|
|
LIST_FOR_EACH_SAFE(cursor, cursor2, &This->AssociatedFocusWindows)
|
|
|
|
{
|
|
|
|
wnd = LIST_ENTRY(cursor,AssociatedWindow,entry);
|
|
|
|
if (wnd->hwnd == hwnd)
|
|
|
|
{
|
|
|
|
if (wnd->docmgr)
|
|
|
|
ITfDocumentMgr_AddRef(wnd->docmgr);
|
|
|
|
*ppdimPrev = wnd->docmgr;
|
|
|
|
wnd->docmgr = pdimNew;
|
|
|
|
if (GetFocus() == hwnd)
|
|
|
|
ThreadMgr_SetFocus(iface,pdimNew);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
wnd = HeapAlloc(GetProcessHeap(),0,sizeof(AssociatedWindow));
|
|
|
|
wnd->hwnd = hwnd;
|
|
|
|
wnd->docmgr = pdimNew;
|
|
|
|
list_add_head(&This->AssociatedFocusWindows,&wnd->entry);
|
|
|
|
|
|
|
|
if (GetFocus() == hwnd)
|
|
|
|
ThreadMgr_SetFocus(iface,pdimNew);
|
|
|
|
|
|
|
|
SetupWindowsHook(This);
|
|
|
|
|
|
|
|
return S_OK;
|
2009-01-27 21:15:30 +01:00
|
|
|
}
|
|
|
|
|
2015-10-28 22:27:25 +01:00
|
|
|
static HRESULT WINAPI ThreadMgr_IsThreadFocus(ITfThreadMgrEx *iface, BOOL *pfThreadFocus)
|
2009-01-27 21:15:30 +01:00
|
|
|
{
|
2015-10-28 22:27:25 +01:00
|
|
|
ThreadMgr *This = impl_from_ITfThreadMgrEx(iface);
|
2009-06-17 09:59:35 +02:00
|
|
|
HWND focus;
|
2013-11-17 09:21:51 +01:00
|
|
|
|
2009-06-17 09:59:35 +02:00
|
|
|
TRACE("(%p) %p\n",This,pfThreadFocus);
|
|
|
|
focus = GetFocus();
|
|
|
|
*pfThreadFocus = (focus == NULL);
|
|
|
|
return S_OK;
|
2009-01-27 21:15:30 +01:00
|
|
|
}
|
|
|
|
|
2015-10-28 22:27:25 +01:00
|
|
|
static HRESULT WINAPI ThreadMgr_GetFunctionProvider(ITfThreadMgrEx *iface, REFCLSID clsid,
|
2009-01-27 21:15:30 +01:00
|
|
|
ITfFunctionProvider **ppFuncProv)
|
|
|
|
{
|
2015-10-28 22:27:25 +01:00
|
|
|
ThreadMgr *This = impl_from_ITfThreadMgrEx(iface);
|
2009-01-27 21:15:30 +01:00
|
|
|
FIXME("STUB:(%p)\n",This);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2015-10-28 22:27:25 +01:00
|
|
|
static HRESULT WINAPI ThreadMgr_EnumFunctionProviders(ITfThreadMgrEx *iface,
|
2009-01-27 21:15:30 +01:00
|
|
|
IEnumTfFunctionProviders **ppEnum)
|
|
|
|
{
|
2015-10-28 22:27:25 +01:00
|
|
|
ThreadMgr *This = impl_from_ITfThreadMgrEx(iface);
|
2009-01-27 21:15:30 +01:00
|
|
|
FIXME("STUB:(%p)\n",This);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2015-10-28 22:27:25 +01:00
|
|
|
static HRESULT WINAPI ThreadMgr_GetGlobalCompartment(ITfThreadMgrEx *iface,
|
2009-01-27 21:15:30 +01:00
|
|
|
ITfCompartmentMgr **ppCompMgr)
|
|
|
|
{
|
2015-10-28 22:27:25 +01:00
|
|
|
ThreadMgr *This = impl_from_ITfThreadMgrEx(iface);
|
2009-06-15 23:25:36 +02:00
|
|
|
HRESULT hr;
|
|
|
|
TRACE("(%p) %p\n",This, ppCompMgr);
|
|
|
|
|
|
|
|
if (!ppCompMgr)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
if (!globalCompartmentMgr)
|
|
|
|
{
|
|
|
|
hr = CompartmentMgr_Constructor(NULL,&IID_ITfCompartmentMgr,(IUnknown**)&globalCompartmentMgr);
|
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
ITfCompartmentMgr_AddRef(globalCompartmentMgr);
|
|
|
|
*ppCompMgr = globalCompartmentMgr;
|
|
|
|
return S_OK;
|
2009-01-27 21:15:30 +01:00
|
|
|
}
|
|
|
|
|
2015-10-28 22:27:25 +01:00
|
|
|
static HRESULT WINAPI ThreadMgr_ActivateEx(ITfThreadMgrEx *iface, TfClientId *id, DWORD flags)
|
|
|
|
{
|
|
|
|
ThreadMgr *This = impl_from_ITfThreadMgrEx(iface);
|
|
|
|
|
2015-11-27 20:39:30 +01:00
|
|
|
TRACE("(%p) %p, %#x\n", This, id, flags);
|
|
|
|
|
|
|
|
if (!id)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
if (flags)
|
|
|
|
FIXME("Unimplemented flags %#x\n", flags);
|
|
|
|
|
|
|
|
if (!processId)
|
|
|
|
{
|
|
|
|
GUID guid;
|
|
|
|
CoCreateGuid(&guid);
|
|
|
|
ITfClientId_GetClientId(&This->ITfClientId_iface, &guid, &processId);
|
|
|
|
}
|
|
|
|
|
|
|
|
activate_textservices(iface);
|
|
|
|
This->activationCount++;
|
|
|
|
*id = processId;
|
|
|
|
return S_OK;
|
2015-10-28 22:27:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ThreadMgr_GetActiveFlags(ITfThreadMgrEx *iface, DWORD *flags)
|
|
|
|
{
|
|
|
|
ThreadMgr *This = impl_from_ITfThreadMgrEx(iface);
|
|
|
|
|
|
|
|
FIXME("STUB:(%p)\n", This);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const ITfThreadMgrExVtbl ThreadMgrExVtbl =
|
2009-01-27 21:15:30 +01:00
|
|
|
{
|
|
|
|
ThreadMgr_QueryInterface,
|
|
|
|
ThreadMgr_AddRef,
|
|
|
|
ThreadMgr_Release,
|
2015-11-27 20:39:30 +01:00
|
|
|
ThreadMgr_Activate,
|
|
|
|
ThreadMgr_Deactivate,
|
2009-01-27 21:15:30 +01:00
|
|
|
ThreadMgr_CreateDocumentMgr,
|
|
|
|
ThreadMgr_EnumDocumentMgrs,
|
|
|
|
ThreadMgr_GetFocus,
|
|
|
|
ThreadMgr_SetFocus,
|
|
|
|
ThreadMgr_AssociateFocus,
|
|
|
|
ThreadMgr_IsThreadFocus,
|
|
|
|
ThreadMgr_GetFunctionProvider,
|
|
|
|
ThreadMgr_EnumFunctionProviders,
|
2015-10-28 22:27:25 +01:00
|
|
|
ThreadMgr_GetGlobalCompartment,
|
|
|
|
|
|
|
|
ThreadMgr_ActivateEx,
|
|
|
|
ThreadMgr_GetActiveFlags
|
2009-01-27 21:15:30 +01:00
|
|
|
};
|
|
|
|
|
2009-02-02 17:25:49 +01:00
|
|
|
static HRESULT WINAPI Source_QueryInterface(ITfSource *iface, REFIID iid, LPVOID *ppvOut)
|
|
|
|
{
|
2013-11-17 09:21:51 +01:00
|
|
|
ThreadMgr *This = impl_from_ITfSource(iface);
|
2015-10-28 22:27:25 +01:00
|
|
|
return ITfThreadMgrEx_QueryInterface(&This->ITfThreadMgrEx_iface, iid, ppvOut);
|
2009-02-02 17:25:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI Source_AddRef(ITfSource *iface)
|
|
|
|
{
|
2013-11-17 09:21:51 +01:00
|
|
|
ThreadMgr *This = impl_from_ITfSource(iface);
|
2015-10-28 22:27:25 +01:00
|
|
|
return ITfThreadMgrEx_AddRef(&This->ITfThreadMgrEx_iface);
|
2009-02-02 17:25:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI Source_Release(ITfSource *iface)
|
|
|
|
{
|
2013-11-17 09:21:51 +01:00
|
|
|
ThreadMgr *This = impl_from_ITfSource(iface);
|
2015-10-28 22:27:25 +01:00
|
|
|
return ITfThreadMgrEx_Release(&This->ITfThreadMgrEx_iface);
|
2009-02-02 17:25:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************
|
|
|
|
* ITfSource functions
|
|
|
|
*****************************************************/
|
2009-09-19 23:33:29 +02:00
|
|
|
static HRESULT WINAPI ThreadMgrSource_AdviseSink(ITfSource *iface,
|
2009-02-02 17:25:49 +01:00
|
|
|
REFIID riid, IUnknown *punk, DWORD *pdwCookie)
|
|
|
|
{
|
2013-11-17 09:21:51 +01:00
|
|
|
ThreadMgr *This = impl_from_ITfSource(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))
|
2016-05-04 19:40:47 +02:00
|
|
|
return advise_sink(&This->ThreadMgrEventSink, &IID_ITfThreadMgrEventSink, COOKIE_MAGIC_TMSINK, punk, pdwCookie);
|
2009-03-24 14:21:39 +01:00
|
|
|
|
2016-09-05 13:57:54 +02:00
|
|
|
if (IsEqualIID(riid, &IID_ITfThreadFocusSink))
|
|
|
|
{
|
|
|
|
WARN("semi-stub for ITfThreadFocusSink: sink won't be used.\n");
|
2017-01-31 14:34:32 +01:00
|
|
|
return advise_sink(&This->ThreadFocusSink, &IID_ITfThreadFocusSink, COOKIE_MAGIC_THREADFOCUSSINK, punk, pdwCookie);
|
2016-09-05 13:57:54 +02:00
|
|
|
}
|
|
|
|
|
2018-03-13 22:51:23 +01:00
|
|
|
if (IsEqualIID(riid, &IID_ITfKeyTraceEventSink))
|
|
|
|
{
|
|
|
|
WARN("semi-stub for ITfKeyTraceEventSink: sink won't be used.\n");
|
|
|
|
return advise_sink(&This->KeyTraceEventSink, &IID_ITfKeyTraceEventSink,
|
|
|
|
COOKIE_MAGIC_KEYTRACESINK, punk, pdwCookie);
|
|
|
|
}
|
|
|
|
|
2019-07-22 18:39:06 +02:00
|
|
|
if (IsEqualIID(riid, &IID_ITfUIElementSink))
|
|
|
|
{
|
|
|
|
WARN("semi-stub for ITfUIElementSink: sink won't be used.\n");
|
|
|
|
return advise_sink(&This->UIElementSink, &IID_ITfUIElementSink,
|
|
|
|
COOKIE_MAGIC_UIELEMENTSINK, punk, pdwCookie);
|
|
|
|
}
|
|
|
|
|
2019-07-25 20:35:05 +02:00
|
|
|
if (IsEqualIID(riid, &IID_ITfInputProcessorProfileActivationSink))
|
|
|
|
{
|
|
|
|
WARN("semi-stub for ITfInputProcessorProfileActivationSink: sink won't be used.\n");
|
|
|
|
return advise_sink(&This->InputProcessorProfileActivationSink, &IID_ITfInputProcessorProfileActivationSink,
|
|
|
|
COOKIE_MAGIC_INPUTPROCESSORPROFILEACTIVATIONSINK, punk, pdwCookie);
|
|
|
|
}
|
|
|
|
|
2016-05-04 19:40:47 +02:00
|
|
|
FIXME("(%p) Unhandled Sink: %s\n",This,debugstr_guid(riid));
|
|
|
|
return E_NOTIMPL;
|
2009-02-02 17:25:49 +01:00
|
|
|
}
|
|
|
|
|
2009-09-19 23:33:29 +02:00
|
|
|
static HRESULT WINAPI ThreadMgrSource_UnadviseSink(ITfSource *iface, DWORD pdwCookie)
|
2009-02-02 17:25:49 +01:00
|
|
|
{
|
2013-11-17 09:21:51 +01:00
|
|
|
ThreadMgr *This = impl_from_ITfSource(iface);
|
2018-03-13 22:51:23 +01:00
|
|
|
DWORD magic;
|
2009-04-22 18:14:19 +02:00
|
|
|
|
2009-03-25 20:35:37 +01:00
|
|
|
TRACE("(%p) %x\n",This,pdwCookie);
|
|
|
|
|
2018-03-13 22:51:23 +01:00
|
|
|
magic = get_Cookie_magic(pdwCookie);
|
|
|
|
if (magic != COOKIE_MAGIC_TMSINK && magic != COOKIE_MAGIC_THREADFOCUSSINK
|
2019-07-25 20:35:05 +02:00
|
|
|
&& magic != COOKIE_MAGIC_KEYTRACESINK && magic != COOKIE_MAGIC_UIELEMENTSINK
|
|
|
|
&& magic != COOKIE_MAGIC_INPUTPROCESSORPROFILEACTIVATIONSINK)
|
2009-04-22 18:14:19 +02:00
|
|
|
return E_INVALIDARG;
|
|
|
|
|
2016-05-04 19:40:59 +02:00
|
|
|
return unadvise_sink(pdwCookie);
|
2009-02-02 17:25:49 +01:00
|
|
|
}
|
|
|
|
|
2013-11-17 09:21:51 +01:00
|
|
|
static const ITfSourceVtbl ThreadMgrSourceVtbl =
|
2009-02-02 17:25:49 +01:00
|
|
|
{
|
|
|
|
Source_QueryInterface,
|
|
|
|
Source_AddRef,
|
|
|
|
Source_Release,
|
|
|
|
ThreadMgrSource_AdviseSink,
|
|
|
|
ThreadMgrSource_UnadviseSink,
|
|
|
|
};
|
|
|
|
|
2009-04-22 19:37:43 +02:00
|
|
|
/*****************************************************
|
|
|
|
* ITfKeystrokeMgr functions
|
|
|
|
*****************************************************/
|
|
|
|
|
|
|
|
static HRESULT WINAPI KeystrokeMgr_QueryInterface(ITfKeystrokeMgr *iface, REFIID iid, LPVOID *ppvOut)
|
|
|
|
{
|
2013-11-17 09:21:51 +01:00
|
|
|
ThreadMgr *This = impl_from_ITfKeystrokeMgr(iface);
|
2015-10-28 22:27:25 +01:00
|
|
|
return ITfThreadMgrEx_QueryInterface(&This->ITfThreadMgrEx_iface, iid, ppvOut);
|
2009-04-22 19:37:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI KeystrokeMgr_AddRef(ITfKeystrokeMgr *iface)
|
|
|
|
{
|
2013-11-17 09:21:51 +01:00
|
|
|
ThreadMgr *This = impl_from_ITfKeystrokeMgr(iface);
|
2015-10-28 22:27:25 +01:00
|
|
|
return ITfThreadMgrEx_AddRef(&This->ITfThreadMgrEx_iface);
|
2009-04-22 19:37:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI KeystrokeMgr_Release(ITfKeystrokeMgr *iface)
|
|
|
|
{
|
2013-11-17 09:21:51 +01:00
|
|
|
ThreadMgr *This = impl_from_ITfKeystrokeMgr(iface);
|
2015-10-28 22:27:25 +01:00
|
|
|
return ITfThreadMgrEx_Release(&This->ITfThreadMgrEx_iface);
|
2009-04-22 19:37:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI KeystrokeMgr_AdviseKeyEventSink(ITfKeystrokeMgr *iface,
|
|
|
|
TfClientId tid, ITfKeyEventSink *pSink, BOOL fForeground)
|
|
|
|
{
|
2013-11-17 09:21:51 +01:00
|
|
|
ThreadMgr *This = impl_from_ITfKeystrokeMgr(iface);
|
2009-05-08 15:50:59 +02:00
|
|
|
CLSID textservice;
|
|
|
|
ITfKeyEventSink *check = NULL;
|
|
|
|
|
|
|
|
TRACE("(%p) %x %p %i\n",This,tid,pSink,fForeground);
|
|
|
|
|
|
|
|
if (!tid || !pSink)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
textservice = get_textservice_clsid(tid);
|
|
|
|
if (IsEqualCLSID(&GUID_NULL,&textservice))
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
get_textservice_sink(tid, &IID_ITfKeyEventSink, (IUnknown**)&check);
|
|
|
|
if (check != NULL)
|
|
|
|
return CONNECT_E_ADVISELIMIT;
|
|
|
|
|
2012-08-19 20:01:36 +02:00
|
|
|
if (FAILED(ITfKeyEventSink_QueryInterface(pSink,&IID_ITfKeyEventSink,(LPVOID*) &check)))
|
2009-05-08 15:50:59 +02:00
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
set_textservice_sink(tid, &IID_ITfKeyEventSink, (IUnknown*)check);
|
|
|
|
|
|
|
|
if (fForeground)
|
|
|
|
{
|
2016-04-13 11:30:37 +02:00
|
|
|
if (This->foregroundKeyEventSink)
|
2009-05-08 15:51:18 +02:00
|
|
|
{
|
2016-04-13 11:30:37 +02:00
|
|
|
ITfKeyEventSink_OnSetFocus(This->foregroundKeyEventSink, FALSE);
|
|
|
|
ITfKeyEventSink_Release(This->foregroundKeyEventSink);
|
2009-05-08 15:51:18 +02:00
|
|
|
}
|
2009-05-08 15:50:59 +02:00
|
|
|
ITfKeyEventSink_AddRef(check);
|
2009-05-08 15:51:18 +02:00
|
|
|
ITfKeyEventSink_OnSetFocus(check, TRUE);
|
2016-04-13 11:30:37 +02:00
|
|
|
This->foregroundKeyEventSink = check;
|
|
|
|
This->foregroundTextService = textservice;
|
2009-05-08 15:50:59 +02:00
|
|
|
}
|
|
|
|
return S_OK;
|
2009-04-22 19:37:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI KeystrokeMgr_UnadviseKeyEventSink(ITfKeystrokeMgr *iface,
|
|
|
|
TfClientId tid)
|
|
|
|
{
|
2013-11-17 09:21:51 +01:00
|
|
|
ThreadMgr *This = impl_from_ITfKeystrokeMgr(iface);
|
2009-05-08 15:51:07 +02:00
|
|
|
CLSID textservice;
|
|
|
|
ITfKeyEventSink *check = NULL;
|
|
|
|
TRACE("(%p) %x\n",This,tid);
|
|
|
|
|
|
|
|
if (!tid)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
textservice = get_textservice_clsid(tid);
|
|
|
|
if (IsEqualCLSID(&GUID_NULL,&textservice))
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
get_textservice_sink(tid, &IID_ITfKeyEventSink, (IUnknown**)&check);
|
|
|
|
|
|
|
|
if (!check)
|
|
|
|
return CONNECT_E_NOCONNECTION;
|
|
|
|
|
|
|
|
set_textservice_sink(tid, &IID_ITfKeyEventSink, NULL);
|
|
|
|
ITfKeyEventSink_Release(check);
|
|
|
|
|
2016-04-13 11:30:37 +02:00
|
|
|
if (This->foregroundKeyEventSink == check)
|
2009-05-08 15:51:07 +02:00
|
|
|
{
|
2016-04-13 11:30:37 +02:00
|
|
|
ITfKeyEventSink_Release(This->foregroundKeyEventSink);
|
|
|
|
This->foregroundKeyEventSink = NULL;
|
|
|
|
This->foregroundTextService = GUID_NULL;
|
2009-05-08 15:51:07 +02:00
|
|
|
}
|
|
|
|
return S_OK;
|
2009-04-22 19:37:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI KeystrokeMgr_GetForeground(ITfKeystrokeMgr *iface,
|
|
|
|
CLSID *pclsid)
|
|
|
|
{
|
2013-11-17 09:21:51 +01:00
|
|
|
ThreadMgr *This = impl_from_ITfKeystrokeMgr(iface);
|
2009-05-08 15:51:18 +02:00
|
|
|
TRACE("(%p) %p\n",This,pclsid);
|
|
|
|
if (!pclsid)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
2016-04-13 11:30:37 +02:00
|
|
|
if (IsEqualCLSID(&This->foregroundTextService,&GUID_NULL))
|
2009-05-08 15:51:18 +02:00
|
|
|
return S_FALSE;
|
|
|
|
|
2016-04-13 11:30:37 +02:00
|
|
|
*pclsid = This->foregroundTextService;
|
2009-05-08 15:51:18 +02:00
|
|
|
return S_OK;
|
2009-04-22 19:37:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI KeystrokeMgr_TestKeyDown(ITfKeystrokeMgr *iface,
|
|
|
|
WPARAM wParam, LPARAM lParam, BOOL *pfEaten)
|
|
|
|
{
|
2013-11-17 09:21:51 +01:00
|
|
|
ThreadMgr *This = impl_from_ITfKeystrokeMgr(iface);
|
2009-04-22 19:37:43 +02:00
|
|
|
FIXME("STUB:(%p)\n",This);
|
2016-05-04 13:31:48 +02:00
|
|
|
*pfEaten = FALSE;
|
|
|
|
return S_OK;
|
2009-04-22 19:37:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI KeystrokeMgr_TestKeyUp(ITfKeystrokeMgr *iface,
|
|
|
|
WPARAM wParam, LPARAM lParam, BOOL *pfEaten)
|
|
|
|
{
|
2013-11-17 09:21:51 +01:00
|
|
|
ThreadMgr *This = impl_from_ITfKeystrokeMgr(iface);
|
2009-04-22 19:37:43 +02:00
|
|
|
FIXME("STUB:(%p)\n",This);
|
2016-05-04 13:31:48 +02:00
|
|
|
*pfEaten = FALSE;
|
|
|
|
return S_OK;
|
2009-04-22 19:37:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI KeystrokeMgr_KeyDown(ITfKeystrokeMgr *iface,
|
|
|
|
WPARAM wParam, LPARAM lParam, BOOL *pfEaten)
|
|
|
|
{
|
2013-11-17 09:21:51 +01:00
|
|
|
ThreadMgr *This = impl_from_ITfKeystrokeMgr(iface);
|
2009-04-22 19:37:43 +02:00
|
|
|
FIXME("STUB:(%p)\n",This);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI KeystrokeMgr_KeyUp(ITfKeystrokeMgr *iface,
|
|
|
|
WPARAM wParam, LPARAM lParam, BOOL *pfEaten)
|
|
|
|
{
|
2013-11-17 09:21:51 +01:00
|
|
|
ThreadMgr *This = impl_from_ITfKeystrokeMgr(iface);
|
2009-04-22 19:37:43 +02:00
|
|
|
FIXME("STUB:(%p)\n",This);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI KeystrokeMgr_GetPreservedKey(ITfKeystrokeMgr *iface,
|
|
|
|
ITfContext *pic, const TF_PRESERVEDKEY *pprekey, GUID *pguid)
|
|
|
|
{
|
2013-11-17 09:21:51 +01:00
|
|
|
ThreadMgr *This = impl_from_ITfKeystrokeMgr(iface);
|
2009-04-22 19:37:43 +02:00
|
|
|
FIXME("STUB:(%p)\n",This);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI KeystrokeMgr_IsPreservedKey(ITfKeystrokeMgr *iface,
|
|
|
|
REFGUID rguid, const TF_PRESERVEDKEY *pprekey, BOOL *pfRegistered)
|
|
|
|
{
|
2013-11-17 09:21:51 +01:00
|
|
|
ThreadMgr *This = impl_from_ITfKeystrokeMgr(iface);
|
2009-05-07 15:31:45 +02:00
|
|
|
struct list *cursor;
|
|
|
|
|
|
|
|
TRACE("(%p) %s (%x %x) %p\n",This,debugstr_guid(rguid), (pprekey)?pprekey->uVKey:0, (pprekey)?pprekey->uModifiers:0, pfRegistered);
|
|
|
|
|
|
|
|
if (!rguid || !pprekey || !pfRegistered)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
LIST_FOR_EACH(cursor, &This->CurrentPreservedKeys)
|
|
|
|
{
|
|
|
|
PreservedKey* key = LIST_ENTRY(cursor,PreservedKey,entry);
|
|
|
|
if (IsEqualGUID(rguid,&key->guid) && pprekey->uVKey == key->prekey.uVKey && pprekey->uModifiers == key->prekey.uModifiers)
|
|
|
|
{
|
|
|
|
*pfRegistered = TRUE;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
*pfRegistered = FALSE;
|
|
|
|
return S_FALSE;
|
2009-04-22 19:37:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI KeystrokeMgr_PreserveKey(ITfKeystrokeMgr *iface,
|
|
|
|
TfClientId tid, REFGUID rguid, const TF_PRESERVEDKEY *prekey,
|
|
|
|
const WCHAR *pchDesc, ULONG cchDesc)
|
|
|
|
{
|
2013-11-17 09:21:51 +01:00
|
|
|
ThreadMgr *This = impl_from_ITfKeystrokeMgr(iface);
|
2009-05-07 15:31:32 +02:00
|
|
|
struct list *cursor;
|
|
|
|
PreservedKey *newkey;
|
|
|
|
|
|
|
|
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));
|
|
|
|
|
|
|
|
if (!tid || ! rguid || !prekey || (cchDesc && !pchDesc))
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
LIST_FOR_EACH(cursor, &This->CurrentPreservedKeys)
|
|
|
|
{
|
|
|
|
PreservedKey* key = LIST_ENTRY(cursor,PreservedKey,entry);
|
|
|
|
if (IsEqualGUID(rguid,&key->guid) && prekey->uVKey == key->prekey.uVKey && prekey->uModifiers == key->prekey.uModifiers)
|
|
|
|
return TF_E_ALREADY_EXISTS;
|
|
|
|
}
|
|
|
|
|
|
|
|
newkey = HeapAlloc(GetProcessHeap(),0,sizeof(PreservedKey));
|
|
|
|
if (!newkey)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
newkey->guid = *rguid;
|
|
|
|
newkey->prekey = *prekey;
|
|
|
|
newkey->tid = tid;
|
2009-11-12 23:51:10 +01:00
|
|
|
newkey->description = NULL;
|
2009-05-07 15:31:32 +02:00
|
|
|
if (cchDesc)
|
|
|
|
{
|
|
|
|
newkey->description = HeapAlloc(GetProcessHeap(),0,cchDesc * sizeof(WCHAR));
|
|
|
|
if (!newkey->description)
|
|
|
|
{
|
|
|
|
HeapFree(GetProcessHeap(),0,newkey);
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
memcpy(newkey->description, pchDesc, cchDesc*sizeof(WCHAR));
|
|
|
|
}
|
|
|
|
|
|
|
|
list_add_head(&This->CurrentPreservedKeys,&newkey->entry);
|
|
|
|
|
|
|
|
return S_OK;
|
2009-04-22 19:37:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI KeystrokeMgr_UnpreserveKey(ITfKeystrokeMgr *iface,
|
|
|
|
REFGUID rguid, const TF_PRESERVEDKEY *pprekey)
|
|
|
|
{
|
2013-11-17 09:21:51 +01:00
|
|
|
ThreadMgr *This = impl_from_ITfKeystrokeMgr(iface);
|
2009-05-07 15:31:38 +02:00
|
|
|
PreservedKey* key = NULL;
|
|
|
|
struct list *cursor;
|
|
|
|
TRACE("(%p) %s (%x %x)\n",This,debugstr_guid(rguid),(pprekey)?pprekey->uVKey:0, (pprekey)?pprekey->uModifiers:0);
|
|
|
|
|
|
|
|
if (!pprekey || !rguid)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
LIST_FOR_EACH(cursor, &This->CurrentPreservedKeys)
|
|
|
|
{
|
|
|
|
key = LIST_ENTRY(cursor,PreservedKey,entry);
|
|
|
|
if (IsEqualGUID(rguid,&key->guid) && pprekey->uVKey == key->prekey.uVKey && pprekey->uModifiers == key->prekey.uModifiers)
|
|
|
|
break;
|
|
|
|
key = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!key)
|
|
|
|
return CONNECT_E_NOCONNECTION;
|
|
|
|
|
|
|
|
list_remove(&key->entry);
|
|
|
|
HeapFree(GetProcessHeap(),0,key->description);
|
|
|
|
HeapFree(GetProcessHeap(),0,key);
|
|
|
|
|
|
|
|
return S_OK;
|
2009-04-22 19:37:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI KeystrokeMgr_SetPreservedKeyDescription(ITfKeystrokeMgr *iface,
|
|
|
|
REFGUID rguid, const WCHAR *pchDesc, ULONG cchDesc)
|
|
|
|
{
|
2013-11-17 09:21:51 +01:00
|
|
|
ThreadMgr *This = impl_from_ITfKeystrokeMgr(iface);
|
2009-04-22 19:37:43 +02:00
|
|
|
FIXME("STUB:(%p)\n",This);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI KeystrokeMgr_GetPreservedKeyDescription(ITfKeystrokeMgr *iface,
|
|
|
|
REFGUID rguid, BSTR *pbstrDesc)
|
|
|
|
{
|
2013-11-17 09:21:51 +01:00
|
|
|
ThreadMgr *This = impl_from_ITfKeystrokeMgr(iface);
|
2009-04-22 19:37:43 +02:00
|
|
|
FIXME("STUB:(%p)\n",This);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI KeystrokeMgr_SimulatePreservedKey(ITfKeystrokeMgr *iface,
|
|
|
|
ITfContext *pic, REFGUID rguid, BOOL *pfEaten)
|
|
|
|
{
|
2013-11-17 09:21:51 +01:00
|
|
|
ThreadMgr *This = impl_from_ITfKeystrokeMgr(iface);
|
2009-04-22 19:37:43 +02:00
|
|
|
FIXME("STUB:(%p)\n",This);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2013-11-17 09:21:51 +01:00
|
|
|
static const ITfKeystrokeMgrVtbl KeystrokeMgrVtbl =
|
2009-04-22 19:37:43 +02:00
|
|
|
{
|
|
|
|
KeystrokeMgr_QueryInterface,
|
|
|
|
KeystrokeMgr_AddRef,
|
|
|
|
KeystrokeMgr_Release,
|
|
|
|
KeystrokeMgr_AdviseKeyEventSink,
|
|
|
|
KeystrokeMgr_UnadviseKeyEventSink,
|
|
|
|
KeystrokeMgr_GetForeground,
|
|
|
|
KeystrokeMgr_TestKeyDown,
|
|
|
|
KeystrokeMgr_TestKeyUp,
|
|
|
|
KeystrokeMgr_KeyDown,
|
|
|
|
KeystrokeMgr_KeyUp,
|
|
|
|
KeystrokeMgr_GetPreservedKey,
|
|
|
|
KeystrokeMgr_IsPreservedKey,
|
|
|
|
KeystrokeMgr_PreserveKey,
|
|
|
|
KeystrokeMgr_UnpreserveKey,
|
|
|
|
KeystrokeMgr_SetPreservedKeyDescription,
|
|
|
|
KeystrokeMgr_GetPreservedKeyDescription,
|
|
|
|
KeystrokeMgr_SimulatePreservedKey
|
|
|
|
};
|
|
|
|
|
2009-05-05 17:52:00 +02:00
|
|
|
/*****************************************************
|
|
|
|
* ITfMessagePump functions
|
|
|
|
*****************************************************/
|
|
|
|
|
|
|
|
static HRESULT WINAPI MessagePump_QueryInterface(ITfMessagePump *iface, REFIID iid, LPVOID *ppvOut)
|
|
|
|
{
|
2013-11-17 09:21:51 +01:00
|
|
|
ThreadMgr *This = impl_from_ITfMessagePump(iface);
|
2015-10-28 22:27:25 +01:00
|
|
|
return ITfThreadMgrEx_QueryInterface(&This->ITfThreadMgrEx_iface, iid, ppvOut);
|
2009-05-05 17:52:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI MessagePump_AddRef(ITfMessagePump *iface)
|
|
|
|
{
|
2013-11-17 09:21:51 +01:00
|
|
|
ThreadMgr *This = impl_from_ITfMessagePump(iface);
|
2015-10-28 22:27:25 +01:00
|
|
|
return ITfThreadMgrEx_AddRef(&This->ITfThreadMgrEx_iface);
|
2009-05-05 17:52:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI MessagePump_Release(ITfMessagePump *iface)
|
|
|
|
{
|
2013-11-17 09:21:51 +01:00
|
|
|
ThreadMgr *This = impl_from_ITfMessagePump(iface);
|
2015-10-28 22:27:25 +01:00
|
|
|
return ITfThreadMgrEx_Release(&This->ITfThreadMgrEx_iface);
|
2009-05-05 17:52:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI MessagePump_PeekMessageA(ITfMessagePump *iface,
|
|
|
|
LPMSG pMsg, HWND hwnd, UINT wMsgFilterMin, UINT wMsgFilterMax,
|
|
|
|
UINT wRemoveMsg, BOOL *pfResult)
|
|
|
|
{
|
|
|
|
if (!pfResult)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
*pfResult = PeekMessageA(pMsg, hwnd, wMsgFilterMin, wMsgFilterMax, wRemoveMsg);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI MessagePump_GetMessageA(ITfMessagePump *iface,
|
|
|
|
LPMSG pMsg, HWND hwnd, UINT wMsgFilterMin, UINT wMsgFilterMax,
|
|
|
|
BOOL *pfResult)
|
|
|
|
{
|
|
|
|
if (!pfResult)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
*pfResult = GetMessageA(pMsg, hwnd, wMsgFilterMin, wMsgFilterMax);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI MessagePump_PeekMessageW(ITfMessagePump *iface,
|
|
|
|
LPMSG pMsg, HWND hwnd, UINT wMsgFilterMin, UINT wMsgFilterMax,
|
|
|
|
UINT wRemoveMsg, BOOL *pfResult)
|
|
|
|
{
|
|
|
|
if (!pfResult)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
*pfResult = PeekMessageW(pMsg, hwnd, wMsgFilterMin, wMsgFilterMax, wRemoveMsg);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI MessagePump_GetMessageW(ITfMessagePump *iface,
|
|
|
|
LPMSG pMsg, HWND hwnd, UINT wMsgFilterMin, UINT wMsgFilterMax,
|
|
|
|
BOOL *pfResult)
|
|
|
|
{
|
|
|
|
if (!pfResult)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
*pfResult = GetMessageW(pMsg, hwnd, wMsgFilterMin, wMsgFilterMax);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2013-11-17 09:21:51 +01:00
|
|
|
static const ITfMessagePumpVtbl MessagePumpVtbl =
|
2009-05-05 17:52:00 +02:00
|
|
|
{
|
|
|
|
MessagePump_QueryInterface,
|
|
|
|
MessagePump_AddRef,
|
|
|
|
MessagePump_Release,
|
|
|
|
MessagePump_PeekMessageA,
|
|
|
|
MessagePump_GetMessageA,
|
|
|
|
MessagePump_PeekMessageW,
|
|
|
|
MessagePump_GetMessageW
|
|
|
|
};
|
|
|
|
|
2009-05-06 17:35:52 +02:00
|
|
|
/*****************************************************
|
|
|
|
* ITfClientId functions
|
|
|
|
*****************************************************/
|
|
|
|
|
|
|
|
static HRESULT WINAPI ClientId_QueryInterface(ITfClientId *iface, REFIID iid, LPVOID *ppvOut)
|
|
|
|
{
|
2013-11-17 09:21:51 +01:00
|
|
|
ThreadMgr *This = impl_from_ITfClientId(iface);
|
2015-10-28 22:27:25 +01:00
|
|
|
return ITfThreadMgrEx_QueryInterface(&This->ITfThreadMgrEx_iface, iid, ppvOut);
|
2009-05-06 17:35:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI ClientId_AddRef(ITfClientId *iface)
|
|
|
|
{
|
2013-11-17 09:21:51 +01:00
|
|
|
ThreadMgr *This = impl_from_ITfClientId(iface);
|
2015-10-28 22:27:25 +01:00
|
|
|
return ITfThreadMgrEx_AddRef(&This->ITfThreadMgrEx_iface);
|
2009-05-06 17:35:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI ClientId_Release(ITfClientId *iface)
|
|
|
|
{
|
2013-11-17 09:21:51 +01:00
|
|
|
ThreadMgr *This = impl_from_ITfClientId(iface);
|
2015-10-28 22:27:25 +01:00
|
|
|
return ITfThreadMgrEx_Release(&This->ITfThreadMgrEx_iface);
|
2009-05-06 17:35:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ClientId_GetClientId(ITfClientId *iface,
|
|
|
|
REFCLSID rclsid, TfClientId *ptid)
|
|
|
|
|
|
|
|
{
|
2013-11-17 09:21:51 +01:00
|
|
|
ThreadMgr *This = impl_from_ITfClientId(iface);
|
2009-05-06 17:35:52 +02:00
|
|
|
HRESULT hr;
|
|
|
|
ITfCategoryMgr *catmgr;
|
|
|
|
|
|
|
|
TRACE("(%p) %s\n",This,debugstr_guid(rclsid));
|
|
|
|
|
|
|
|
CategoryMgr_Constructor(NULL,(IUnknown**)&catmgr);
|
|
|
|
hr = ITfCategoryMgr_RegisterGUID(catmgr,rclsid,ptid);
|
|
|
|
ITfCategoryMgr_Release(catmgr);
|
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2013-11-17 09:21:51 +01:00
|
|
|
static const ITfClientIdVtbl ClientIdVtbl =
|
2009-05-06 17:35:52 +02:00
|
|
|
{
|
|
|
|
ClientId_QueryInterface,
|
|
|
|
ClientId_AddRef,
|
|
|
|
ClientId_Release,
|
|
|
|
ClientId_GetClientId
|
|
|
|
};
|
|
|
|
|
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);
|
2015-10-28 22:27:25 +01:00
|
|
|
return ITfThreadMgrEx_QueryInterface(&This->ITfThreadMgrEx_iface, iid, ppvOut);
|
2009-03-24 14:21:47 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI ThreadMgrEventSink_AddRef(ITfThreadMgrEventSink *iface)
|
|
|
|
{
|
|
|
|
ThreadMgr *This = impl_from_ITfThreadMgrEventSink(iface);
|
2015-10-28 22:27:25 +01:00
|
|
|
return ITfThreadMgrEx_AddRef(&This->ITfThreadMgrEx_iface);
|
2009-03-24 14:21:47 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI ThreadMgrEventSink_Release(ITfThreadMgrEventSink *iface)
|
|
|
|
{
|
|
|
|
ThreadMgr *This = impl_from_ITfThreadMgrEventSink(iface);
|
2015-10-28 22:27:25 +01:00
|
|
|
return ITfThreadMgrEx_Release(&This->ITfThreadMgrEx_iface);
|
2009-03-24 14:21:47 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-09-19 23:33:29 +02:00
|
|
|
static HRESULT WINAPI ThreadMgrEventSink_OnInitDocumentMgr(
|
2009-03-24 14:21:47 +01:00
|
|
|
ITfThreadMgrEventSink *iface,ITfDocumentMgr *pdim)
|
|
|
|
{
|
|
|
|
ThreadMgr *This = impl_from_ITfThreadMgrEventSink(iface);
|
2016-05-04 19:41:29 +02:00
|
|
|
ITfThreadMgrEventSink *sink;
|
|
|
|
struct list *cursor;
|
2009-03-24 14:21:47 +01:00
|
|
|
|
|
|
|
TRACE("(%p) %p\n",This,pdim);
|
|
|
|
|
2016-05-04 19:41:29 +02:00
|
|
|
SINK_FOR_EACH(cursor, &This->ThreadMgrEventSink, ITfThreadMgrEventSink, sink)
|
2009-03-24 14:21:47 +01:00
|
|
|
{
|
2016-05-04 19:41:29 +02:00
|
|
|
ITfThreadMgrEventSink_OnInitDocumentMgr(sink, pdim);
|
2009-03-24 14:21:47 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2009-09-19 23:33:29 +02:00
|
|
|
static HRESULT WINAPI ThreadMgrEventSink_OnUninitDocumentMgr(
|
2009-03-24 14:21:47 +01:00
|
|
|
ITfThreadMgrEventSink *iface, ITfDocumentMgr *pdim)
|
|
|
|
{
|
|
|
|
ThreadMgr *This = impl_from_ITfThreadMgrEventSink(iface);
|
2016-05-04 19:41:29 +02:00
|
|
|
ITfThreadMgrEventSink *sink;
|
|
|
|
struct list *cursor;
|
2009-03-24 14:21:47 +01:00
|
|
|
|
|
|
|
TRACE("(%p) %p\n",This,pdim);
|
|
|
|
|
2016-05-04 19:41:29 +02:00
|
|
|
SINK_FOR_EACH(cursor, &This->ThreadMgrEventSink, ITfThreadMgrEventSink, sink)
|
2009-03-24 14:21:47 +01:00
|
|
|
{
|
2016-05-04 19:41:29 +02:00
|
|
|
ITfThreadMgrEventSink_OnUninitDocumentMgr(sink, pdim);
|
2009-03-24 14:21:47 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2009-09-19 23:33:29 +02:00
|
|
|
static HRESULT WINAPI ThreadMgrEventSink_OnSetFocus(
|
2009-03-24 14:21:47 +01:00
|
|
|
ITfThreadMgrEventSink *iface, ITfDocumentMgr *pdimFocus,
|
|
|
|
ITfDocumentMgr *pdimPrevFocus)
|
|
|
|
{
|
|
|
|
ThreadMgr *This = impl_from_ITfThreadMgrEventSink(iface);
|
2016-05-04 19:41:29 +02:00
|
|
|
ITfThreadMgrEventSink *sink;
|
|
|
|
struct list *cursor;
|
2009-03-24 14:21:47 +01:00
|
|
|
|
|
|
|
TRACE("(%p) %p %p\n",This,pdimFocus, pdimPrevFocus);
|
|
|
|
|
2016-05-04 19:41:29 +02:00
|
|
|
SINK_FOR_EACH(cursor, &This->ThreadMgrEventSink, ITfThreadMgrEventSink, sink)
|
2009-03-24 14:21:47 +01:00
|
|
|
{
|
2016-05-04 19:41:29 +02:00
|
|
|
ITfThreadMgrEventSink_OnSetFocus(sink, pdimFocus, pdimPrevFocus);
|
2009-03-24 14:21:47 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2009-09-19 23:33:29 +02:00
|
|
|
static HRESULT WINAPI ThreadMgrEventSink_OnPushContext(
|
2009-03-24 14:21:47 +01:00
|
|
|
ITfThreadMgrEventSink *iface, ITfContext *pic)
|
|
|
|
{
|
|
|
|
ThreadMgr *This = impl_from_ITfThreadMgrEventSink(iface);
|
2016-05-04 19:41:29 +02:00
|
|
|
ITfThreadMgrEventSink *sink;
|
|
|
|
struct list *cursor;
|
2009-03-24 14:21:47 +01:00
|
|
|
|
|
|
|
TRACE("(%p) %p\n",This,pic);
|
|
|
|
|
2016-05-04 19:41:29 +02:00
|
|
|
SINK_FOR_EACH(cursor, &This->ThreadMgrEventSink, ITfThreadMgrEventSink, sink)
|
2009-03-24 14:21:47 +01:00
|
|
|
{
|
2016-05-04 19:41:29 +02:00
|
|
|
ITfThreadMgrEventSink_OnPushContext(sink, pic);
|
2009-03-24 14:21:47 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2009-09-19 23:33:29 +02:00
|
|
|
static HRESULT WINAPI ThreadMgrEventSink_OnPopContext(
|
2009-03-24 14:21:47 +01:00
|
|
|
ITfThreadMgrEventSink *iface, ITfContext *pic)
|
|
|
|
{
|
|
|
|
ThreadMgr *This = impl_from_ITfThreadMgrEventSink(iface);
|
2016-05-04 19:41:29 +02:00
|
|
|
ITfThreadMgrEventSink *sink;
|
|
|
|
struct list *cursor;
|
2009-03-24 14:21:47 +01:00
|
|
|
|
|
|
|
TRACE("(%p) %p\n",This,pic);
|
|
|
|
|
2016-05-04 19:41:29 +02:00
|
|
|
SINK_FOR_EACH(cursor, &This->ThreadMgrEventSink, ITfThreadMgrEventSink, sink)
|
2009-03-24 14:21:47 +01:00
|
|
|
{
|
2016-05-04 19:41:29 +02:00
|
|
|
ITfThreadMgrEventSink_OnPopContext(sink, pic);
|
2009-03-24 14:21:47 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2013-11-17 09:21:51 +01:00
|
|
|
static const ITfThreadMgrEventSinkVtbl ThreadMgrEventSinkVtbl =
|
2009-03-24 14:21:47 +01:00
|
|
|
{
|
|
|
|
ThreadMgrEventSink_QueryInterface,
|
|
|
|
ThreadMgrEventSink_AddRef,
|
|
|
|
ThreadMgrEventSink_Release,
|
|
|
|
ThreadMgrEventSink_OnInitDocumentMgr,
|
|
|
|
ThreadMgrEventSink_OnUninitDocumentMgr,
|
|
|
|
ThreadMgrEventSink_OnSetFocus,
|
|
|
|
ThreadMgrEventSink_OnPushContext,
|
|
|
|
ThreadMgrEventSink_OnPopContext
|
|
|
|
};
|
|
|
|
|
2015-10-28 22:27:26 +01:00
|
|
|
/*****************************************************
|
|
|
|
* ITfUIElementMgr functions
|
|
|
|
*****************************************************/
|
|
|
|
static HRESULT WINAPI UIElementMgr_QueryInterface(ITfUIElementMgr *iface, REFIID iid, void **ppvOut)
|
|
|
|
{
|
|
|
|
ThreadMgr *This = impl_from_ITfUIElementMgr(iface);
|
|
|
|
|
2016-12-09 15:05:48 +01:00
|
|
|
return ITfThreadMgrEx_QueryInterface(&This->ITfThreadMgrEx_iface, iid, ppvOut);
|
2015-10-28 22:27:26 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI UIElementMgr_AddRef(ITfUIElementMgr *iface)
|
|
|
|
{
|
|
|
|
ThreadMgr *This = impl_from_ITfUIElementMgr(iface);
|
|
|
|
|
|
|
|
return ITfThreadMgrEx_AddRef(&This->ITfThreadMgrEx_iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI UIElementMgr_Release(ITfUIElementMgr *iface)
|
|
|
|
{
|
|
|
|
ThreadMgr *This = impl_from_ITfUIElementMgr(iface);
|
|
|
|
|
|
|
|
return ITfThreadMgrEx_Release(&This->ITfThreadMgrEx_iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI UIElementMgr_BeginUIElement(ITfUIElementMgr *iface, ITfUIElement *element,
|
|
|
|
BOOL *show, DWORD *id)
|
|
|
|
{
|
|
|
|
ThreadMgr *This = impl_from_ITfUIElementMgr(iface);
|
|
|
|
|
|
|
|
FIXME("STUB:(%p)\n", This);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI UIElementMgr_UpdateUIElement(ITfUIElementMgr *iface, DWORD id)
|
|
|
|
{
|
|
|
|
ThreadMgr *This = impl_from_ITfUIElementMgr(iface);
|
|
|
|
|
|
|
|
FIXME("STUB:(%p)\n", This);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI UIElementMgr_EndUIElement(ITfUIElementMgr *iface, DWORD id)
|
|
|
|
{
|
|
|
|
ThreadMgr *This = impl_from_ITfUIElementMgr(iface);
|
|
|
|
|
|
|
|
FIXME("STUB:(%p)\n", This);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI UIElementMgr_GetUIElement(ITfUIElementMgr *iface, DWORD id,
|
|
|
|
ITfUIElement **element)
|
|
|
|
{
|
|
|
|
ThreadMgr *This = impl_from_ITfUIElementMgr(iface);
|
|
|
|
|
|
|
|
FIXME("STUB:(%p)\n", This);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI UIElementMgr_EnumUIElements(ITfUIElementMgr *iface,
|
|
|
|
IEnumTfUIElements **enum_elements)
|
|
|
|
{
|
|
|
|
ThreadMgr *This = impl_from_ITfUIElementMgr(iface);
|
|
|
|
|
|
|
|
FIXME("STUB:(%p)\n", This);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const ITfUIElementMgrVtbl ThreadMgrUIElementMgrVtbl =
|
|
|
|
{
|
|
|
|
UIElementMgr_QueryInterface,
|
|
|
|
UIElementMgr_AddRef,
|
|
|
|
UIElementMgr_Release,
|
|
|
|
|
|
|
|
UIElementMgr_BeginUIElement,
|
|
|
|
UIElementMgr_UpdateUIElement,
|
|
|
|
UIElementMgr_EndUIElement,
|
|
|
|
UIElementMgr_GetUIElement,
|
|
|
|
UIElementMgr_EnumUIElements
|
|
|
|
};
|
|
|
|
|
2009-09-08 17:30:10 +02:00
|
|
|
/*****************************************************
|
|
|
|
* ITfSourceSingle functions
|
|
|
|
*****************************************************/
|
|
|
|
static HRESULT WINAPI ThreadMgrSourceSingle_QueryInterface(ITfSourceSingle *iface, REFIID iid, LPVOID *ppvOut)
|
|
|
|
{
|
2013-11-17 09:21:51 +01:00
|
|
|
ThreadMgr *This = impl_from_ITfSourceSingle(iface);
|
2015-10-28 22:27:25 +01:00
|
|
|
return ITfThreadMgrEx_QueryInterface(&This->ITfThreadMgrEx_iface, iid, ppvOut);
|
2009-09-08 17:30:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI ThreadMgrSourceSingle_AddRef(ITfSourceSingle *iface)
|
|
|
|
{
|
2013-11-17 09:21:51 +01:00
|
|
|
ThreadMgr *This = impl_from_ITfSourceSingle(iface);
|
2015-10-28 22:27:25 +01:00
|
|
|
return ITfThreadMgrEx_AddRef(&This->ITfThreadMgrEx_iface);
|
2009-09-08 17:30:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI ThreadMgrSourceSingle_Release(ITfSourceSingle *iface)
|
|
|
|
{
|
2013-11-17 09:21:51 +01:00
|
|
|
ThreadMgr *This = impl_from_ITfSourceSingle(iface);
|
2015-10-28 22:27:25 +01:00
|
|
|
return ITfThreadMgrEx_Release(&This->ITfThreadMgrEx_iface);
|
2009-09-08 17:30:10 +02:00
|
|
|
}
|
|
|
|
|
2009-09-19 23:33:29 +02:00
|
|
|
static HRESULT WINAPI ThreadMgrSourceSingle_AdviseSingleSink( ITfSourceSingle *iface,
|
2009-09-08 17:30:10 +02:00
|
|
|
TfClientId tid, REFIID riid, IUnknown *punk)
|
|
|
|
{
|
2013-11-17 09:21:51 +01:00
|
|
|
ThreadMgr *This = impl_from_ITfSourceSingle(iface);
|
2009-09-08 17:30:10 +02:00
|
|
|
FIXME("STUB:(%p) %i %s %p\n",This, tid, debugstr_guid(riid),punk);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2009-09-19 23:33:29 +02:00
|
|
|
static HRESULT WINAPI ThreadMgrSourceSingle_UnadviseSingleSink( ITfSourceSingle *iface,
|
2009-09-08 17:30:10 +02:00
|
|
|
TfClientId tid, REFIID riid)
|
|
|
|
{
|
2013-11-17 09:21:51 +01:00
|
|
|
ThreadMgr *This = impl_from_ITfSourceSingle(iface);
|
2009-09-08 17:30:10 +02:00
|
|
|
FIXME("STUB:(%p) %i %s\n",This, tid, debugstr_guid(riid));
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2013-11-17 09:21:51 +01:00
|
|
|
static const ITfSourceSingleVtbl SourceSingleVtbl =
|
2009-09-08 17:30:10 +02:00
|
|
|
{
|
|
|
|
ThreadMgrSourceSingle_QueryInterface,
|
|
|
|
ThreadMgrSourceSingle_AddRef,
|
|
|
|
ThreadMgrSourceSingle_Release,
|
|
|
|
ThreadMgrSourceSingle_AdviseSingleSink,
|
2013-11-17 09:21:51 +01:00
|
|
|
ThreadMgrSourceSingle_UnadviseSingleSink
|
2009-09-08 17:30:10 +02:00
|
|
|
};
|
|
|
|
|
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)
|
|
|
|
{
|
2015-10-28 22:27:25 +01:00
|
|
|
ThreadMgr_AddRef(&This->ITfThreadMgrEx_iface);
|
|
|
|
*ppOut = (IUnknown*)&This->ITfThreadMgrEx_iface;
|
2009-02-02 17:24:47 +01:00
|
|
|
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;
|
|
|
|
|
2015-10-28 22:27:25 +01:00
|
|
|
This->ITfThreadMgrEx_iface.lpVtbl = &ThreadMgrExVtbl;
|
2013-11-17 09:21:51 +01:00
|
|
|
This->ITfSource_iface.lpVtbl = &ThreadMgrSourceVtbl;
|
2015-10-28 22:27:25 +01:00
|
|
|
This->ITfKeystrokeMgr_iface.lpVtbl = &KeystrokeMgrVtbl;
|
2013-11-17 09:21:51 +01:00
|
|
|
This->ITfMessagePump_iface.lpVtbl = &MessagePumpVtbl;
|
|
|
|
This->ITfClientId_iface.lpVtbl = &ClientIdVtbl;
|
|
|
|
This->ITfThreadMgrEventSink_iface.lpVtbl = &ThreadMgrEventSinkVtbl;
|
2015-10-28 22:27:26 +01:00
|
|
|
This->ITfUIElementMgr_iface.lpVtbl = &ThreadMgrUIElementMgrVtbl;
|
2013-11-17 09:21:51 +01:00
|
|
|
This->ITfSourceSingle_iface.lpVtbl = &SourceSingleVtbl;
|
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
|
|
|
|
2016-11-26 22:58:06 +01:00
|
|
|
CompartmentMgr_Constructor((IUnknown*)&This->ITfThreadMgrEx_iface, &IID_IUnknown, (IUnknown**)&This->CompartmentMgr);
|
2009-06-11 20:33:07 +02:00
|
|
|
|
2009-05-07 15:31:32 +02:00
|
|
|
list_init(&This->CurrentPreservedKeys);
|
2009-07-10 14:36:56 +02:00
|
|
|
list_init(&This->CreatedDocumentMgrs);
|
2009-09-01 14:07:57 +02:00
|
|
|
list_init(&This->AssociatedFocusWindows);
|
2009-05-07 15:31:32 +02: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);
|
2019-07-22 18:39:06 +02:00
|
|
|
list_init(&This->UIElementSink);
|
2019-07-25 20:35:05 +02:00
|
|
|
list_init(&This->InputProcessorProfileActivationSink);
|
2009-03-24 14:21:28 +01:00
|
|
|
|
2009-01-27 21:15:30 +01:00
|
|
|
TRACE("returning %p\n", This);
|
2015-10-28 22:27:25 +01:00
|
|
|
*ppOut = (IUnknown *)&This->ITfThreadMgrEx_iface;
|
2009-01-27 21:15:30 +01:00
|
|
|
return S_OK;
|
|
|
|
}
|
2009-07-10 14:36:56 +02:00
|
|
|
|
2009-07-10 14:38:20 +02:00
|
|
|
/**************************************************
|
2011-08-24 15:28:14 +02:00
|
|
|
* IEnumTfDocumentMgrs implementation
|
2009-07-10 14:38:20 +02:00
|
|
|
**************************************************/
|
|
|
|
static void EnumTfDocumentMgr_Destructor(EnumTfDocumentMgr *This)
|
|
|
|
{
|
|
|
|
TRACE("destroying %p\n", This);
|
|
|
|
HeapFree(GetProcessHeap(),0,This);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI EnumTfDocumentMgr_QueryInterface(IEnumTfDocumentMgrs *iface, REFIID iid, LPVOID *ppvOut)
|
|
|
|
{
|
2013-11-17 09:21:51 +01:00
|
|
|
EnumTfDocumentMgr *This = impl_from_IEnumTfDocumentMgrs(iface);
|
2009-07-10 14:38:20 +02:00
|
|
|
*ppvOut = NULL;
|
|
|
|
|
|
|
|
if (IsEqualIID(iid, &IID_IUnknown) || IsEqualIID(iid, &IID_IEnumTfDocumentMgrs))
|
|
|
|
{
|
2013-11-17 09:21:51 +01:00
|
|
|
*ppvOut = &This->IEnumTfDocumentMgrs_iface;
|
2009-07-10 14:38:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (*ppvOut)
|
|
|
|
{
|
2012-08-19 20:01:36 +02:00
|
|
|
IEnumTfDocumentMgrs_AddRef(iface);
|
2009-07-10 14:38:20 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
WARN("unsupported interface: %s\n", debugstr_guid(iid));
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI EnumTfDocumentMgr_AddRef(IEnumTfDocumentMgrs *iface)
|
|
|
|
{
|
2013-11-17 09:21:51 +01:00
|
|
|
EnumTfDocumentMgr *This = impl_from_IEnumTfDocumentMgrs(iface);
|
2009-07-10 14:38:20 +02:00
|
|
|
return InterlockedIncrement(&This->refCount);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI EnumTfDocumentMgr_Release(IEnumTfDocumentMgrs *iface)
|
|
|
|
{
|
2013-11-17 09:21:51 +01:00
|
|
|
EnumTfDocumentMgr *This = impl_from_IEnumTfDocumentMgrs(iface);
|
2009-07-10 14:38:20 +02:00
|
|
|
ULONG ret;
|
|
|
|
|
|
|
|
ret = InterlockedDecrement(&This->refCount);
|
|
|
|
if (ret == 0)
|
|
|
|
EnumTfDocumentMgr_Destructor(This);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI EnumTfDocumentMgr_Next(IEnumTfDocumentMgrs *iface,
|
|
|
|
ULONG ulCount, ITfDocumentMgr **rgDocumentMgr, ULONG *pcFetched)
|
|
|
|
{
|
2013-11-17 09:21:51 +01:00
|
|
|
EnumTfDocumentMgr *This = impl_from_IEnumTfDocumentMgrs(iface);
|
2009-07-10 14:38:20 +02:00
|
|
|
ULONG fetched = 0;
|
|
|
|
|
|
|
|
TRACE("(%p)\n",This);
|
|
|
|
|
|
|
|
if (rgDocumentMgr == NULL) return E_POINTER;
|
|
|
|
|
|
|
|
while (fetched < ulCount)
|
|
|
|
{
|
|
|
|
DocumentMgrEntry *mgrentry;
|
|
|
|
if (This->index == NULL)
|
|
|
|
break;
|
|
|
|
|
|
|
|
mgrentry = LIST_ENTRY(This->index,DocumentMgrEntry,entry);
|
|
|
|
if (mgrentry == NULL)
|
|
|
|
break;
|
|
|
|
|
|
|
|
*rgDocumentMgr = mgrentry->docmgr;
|
|
|
|
ITfDocumentMgr_AddRef(*rgDocumentMgr);
|
|
|
|
|
|
|
|
This->index = list_next(This->head, This->index);
|
|
|
|
++fetched;
|
|
|
|
++rgDocumentMgr;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pcFetched) *pcFetched = fetched;
|
|
|
|
return fetched == ulCount ? S_OK : S_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI EnumTfDocumentMgr_Skip( IEnumTfDocumentMgrs* iface, ULONG celt)
|
|
|
|
{
|
2013-11-17 09:21:51 +01:00
|
|
|
EnumTfDocumentMgr *This = impl_from_IEnumTfDocumentMgrs(iface);
|
2013-02-13 22:06:41 +01:00
|
|
|
ULONG i;
|
2013-11-17 09:21:51 +01:00
|
|
|
|
2009-07-10 14:38:20 +02:00
|
|
|
TRACE("(%p)\n",This);
|
|
|
|
for(i = 0; i < celt && This->index != NULL; i++)
|
|
|
|
This->index = list_next(This->head, This->index);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI EnumTfDocumentMgr_Reset( IEnumTfDocumentMgrs* iface)
|
|
|
|
{
|
2013-11-17 09:21:51 +01:00
|
|
|
EnumTfDocumentMgr *This = impl_from_IEnumTfDocumentMgrs(iface);
|
2009-07-10 14:38:20 +02:00
|
|
|
TRACE("(%p)\n",This);
|
|
|
|
This->index = list_head(This->head);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI EnumTfDocumentMgr_Clone( IEnumTfDocumentMgrs *iface,
|
|
|
|
IEnumTfDocumentMgrs **ppenum)
|
|
|
|
{
|
2013-11-17 09:21:51 +01:00
|
|
|
EnumTfDocumentMgr *This = impl_from_IEnumTfDocumentMgrs(iface);
|
2009-07-10 14:38:20 +02:00
|
|
|
HRESULT res;
|
|
|
|
|
|
|
|
TRACE("(%p)\n",This);
|
|
|
|
|
|
|
|
if (ppenum == NULL) return E_POINTER;
|
|
|
|
|
|
|
|
res = EnumTfDocumentMgr_Constructor(This->head, ppenum);
|
|
|
|
if (SUCCEEDED(res))
|
|
|
|
{
|
2013-11-17 09:21:51 +01:00
|
|
|
EnumTfDocumentMgr *new_This = impl_from_IEnumTfDocumentMgrs(*ppenum);
|
2009-07-10 14:38:20 +02:00
|
|
|
new_This->index = This->index;
|
|
|
|
}
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2013-11-17 09:21:51 +01:00
|
|
|
static const IEnumTfDocumentMgrsVtbl EnumTfDocumentMgrsVtbl =
|
|
|
|
{
|
2009-07-10 14:38:20 +02:00
|
|
|
EnumTfDocumentMgr_QueryInterface,
|
|
|
|
EnumTfDocumentMgr_AddRef,
|
|
|
|
EnumTfDocumentMgr_Release,
|
|
|
|
EnumTfDocumentMgr_Clone,
|
|
|
|
EnumTfDocumentMgr_Next,
|
|
|
|
EnumTfDocumentMgr_Reset,
|
|
|
|
EnumTfDocumentMgr_Skip
|
|
|
|
};
|
|
|
|
|
|
|
|
static HRESULT EnumTfDocumentMgr_Constructor(struct list* head, IEnumTfDocumentMgrs **ppOut)
|
|
|
|
{
|
|
|
|
EnumTfDocumentMgr *This;
|
|
|
|
|
|
|
|
This = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(EnumTfDocumentMgr));
|
|
|
|
if (This == NULL)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
2013-11-17 09:21:51 +01:00
|
|
|
This->IEnumTfDocumentMgrs_iface.lpVtbl= &EnumTfDocumentMgrsVtbl;
|
2009-07-10 14:38:20 +02:00
|
|
|
This->refCount = 1;
|
|
|
|
This->head = head;
|
|
|
|
This->index = list_head(This->head);
|
|
|
|
|
2016-07-01 10:29:56 +02:00
|
|
|
TRACE("returning %p\n", &This->IEnumTfDocumentMgrs_iface);
|
|
|
|
*ppOut = &This->IEnumTfDocumentMgrs_iface;
|
2009-07-10 14:38:20 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2013-11-17 09:21:51 +01:00
|
|
|
void ThreadMgr_OnDocumentMgrDestruction(ITfThreadMgr *iface, ITfDocumentMgr *mgr)
|
2009-07-10 14:36:56 +02:00
|
|
|
{
|
2015-10-28 22:27:25 +01:00
|
|
|
ThreadMgr *This = impl_from_ITfThreadMgrEx((ITfThreadMgrEx *)iface);
|
2009-07-10 14:36:56 +02:00
|
|
|
struct list *cursor;
|
|
|
|
LIST_FOR_EACH(cursor, &This->CreatedDocumentMgrs)
|
|
|
|
{
|
|
|
|
DocumentMgrEntry *mgrentry = LIST_ENTRY(cursor,DocumentMgrEntry,entry);
|
|
|
|
if (mgrentry->docmgr == mgr)
|
|
|
|
{
|
|
|
|
list_remove(cursor);
|
|
|
|
HeapFree(GetProcessHeap(),0,mgrentry);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2011-08-03 23:50:18 +02:00
|
|
|
FIXME("ITfDocumentMgr %p not found in this thread\n",mgr);
|
2009-07-10 14:36:56 +02:00
|
|
|
}
|