From 987387c7c8c88095e1b45d0dc4ce99fecf0c2912 Mon Sep 17 00:00:00 2001 From: Aric Stewart Date: Wed, 22 Apr 2009 12:37:43 -0500 Subject: [PATCH] msctf: Add ITfKeystrokeMgr framework to ThreadMgr. --- dlls/msctf/threadmgr.c | 168 +++++++++++++++++++++++++++++++++++++++++ include/msctf.idl | 82 ++++++++++++++++++++ 2 files changed, 250 insertions(+) diff --git a/dlls/msctf/threadmgr.c b/dlls/msctf/threadmgr.c index f6f9be485ca..2d43a198072 100644 --- a/dlls/msctf/threadmgr.c +++ b/dlls/msctf/threadmgr.c @@ -59,6 +59,7 @@ typedef struct tagThreadMgrSink { typedef struct tagACLMulti { const ITfThreadMgrVtbl *ThreadMgrVtbl; const ITfSourceVtbl *SourceVtbl; + const ITfKeystrokeMgrVtbl *KeystrokeMgrVtbl; LONG refCount; const ITfThreadMgrEventSinkVtbl *ThreadMgrEventSinkVtbl; /* internal */ @@ -79,6 +80,11 @@ static inline ThreadMgr *impl_from_ITfSourceVtbl(ITfSource *iface) return (ThreadMgr *)((char *)iface - FIELD_OFFSET(ThreadMgr,SourceVtbl)); } +static inline ThreadMgr *impl_from_ITfKeystrokeMgrVtbl(ITfKeystrokeMgr *iface) +{ + return (ThreadMgr *)((char *)iface - FIELD_OFFSET(ThreadMgr,KeystrokeMgrVtbl)); +} + static inline ThreadMgr *impl_from_ITfThreadMgrEventSink(ITfThreadMgrEventSink *iface) { return (ThreadMgr *)((char *)iface - FIELD_OFFSET(ThreadMgr,ThreadMgrEventSinkVtbl)); @@ -153,6 +159,10 @@ static HRESULT WINAPI ThreadMgr_QueryInterface(ITfThreadMgr *iface, REFIID iid, { *ppvOut = &This->SourceVtbl; } + else if (IsEqualIID(iid, &IID_ITfKeystrokeMgr)) + { + *ppvOut = &This->KeystrokeMgrVtbl; + } if (*ppvOut) { @@ -408,6 +418,163 @@ static const ITfSourceVtbl ThreadMgr_SourceVtbl = ThreadMgrSource_UnadviseSink, }; +/***************************************************** + * ITfKeystrokeMgr functions + *****************************************************/ + +static HRESULT WINAPI KeystrokeMgr_QueryInterface(ITfKeystrokeMgr *iface, REFIID iid, LPVOID *ppvOut) +{ + ThreadMgr *This = impl_from_ITfKeystrokeMgrVtbl(iface); + return ThreadMgr_QueryInterface((ITfThreadMgr *)This, iid, *ppvOut); +} + +static ULONG WINAPI KeystrokeMgr_AddRef(ITfKeystrokeMgr *iface) +{ + ThreadMgr *This = impl_from_ITfKeystrokeMgrVtbl(iface); + return ThreadMgr_AddRef((ITfThreadMgr*)This); +} + +static ULONG WINAPI KeystrokeMgr_Release(ITfKeystrokeMgr *iface) +{ + ThreadMgr *This = impl_from_ITfKeystrokeMgrVtbl(iface); + return ThreadMgr_Release((ITfThreadMgr *)This); +} + +static HRESULT WINAPI KeystrokeMgr_AdviseKeyEventSink(ITfKeystrokeMgr *iface, + TfClientId tid, ITfKeyEventSink *pSink, BOOL fForeground) +{ + ThreadMgr *This = impl_from_ITfKeystrokeMgrVtbl(iface); + FIXME("STUB:(%p)\n",This); + return E_NOTIMPL; +} + +static HRESULT WINAPI KeystrokeMgr_UnadviseKeyEventSink(ITfKeystrokeMgr *iface, + TfClientId tid) +{ + ThreadMgr *This = impl_from_ITfKeystrokeMgrVtbl(iface); + FIXME("STUB:(%p)\n",This); + return E_NOTIMPL; +} + +static HRESULT WINAPI KeystrokeMgr_GetForeground(ITfKeystrokeMgr *iface, + CLSID *pclsid) +{ + ThreadMgr *This = impl_from_ITfKeystrokeMgrVtbl(iface); + FIXME("STUB:(%p)\n",This); + return E_NOTIMPL; +} + +static HRESULT WINAPI KeystrokeMgr_TestKeyDown(ITfKeystrokeMgr *iface, + WPARAM wParam, LPARAM lParam, BOOL *pfEaten) +{ + ThreadMgr *This = impl_from_ITfKeystrokeMgrVtbl(iface); + FIXME("STUB:(%p)\n",This); + return E_NOTIMPL; +} + +static HRESULT WINAPI KeystrokeMgr_TestKeyUp(ITfKeystrokeMgr *iface, + WPARAM wParam, LPARAM lParam, BOOL *pfEaten) +{ + ThreadMgr *This = impl_from_ITfKeystrokeMgrVtbl(iface); + FIXME("STUB:(%p)\n",This); + return E_NOTIMPL; +} + +static HRESULT WINAPI KeystrokeMgr_KeyDown(ITfKeystrokeMgr *iface, + WPARAM wParam, LPARAM lParam, BOOL *pfEaten) +{ + ThreadMgr *This = impl_from_ITfKeystrokeMgrVtbl(iface); + FIXME("STUB:(%p)\n",This); + return E_NOTIMPL; +} + +static HRESULT WINAPI KeystrokeMgr_KeyUp(ITfKeystrokeMgr *iface, + WPARAM wParam, LPARAM lParam, BOOL *pfEaten) +{ + ThreadMgr *This = impl_from_ITfKeystrokeMgrVtbl(iface); + FIXME("STUB:(%p)\n",This); + return E_NOTIMPL; +} + +static HRESULT WINAPI KeystrokeMgr_GetPreservedKey(ITfKeystrokeMgr *iface, + ITfContext *pic, const TF_PRESERVEDKEY *pprekey, GUID *pguid) +{ + ThreadMgr *This = impl_from_ITfKeystrokeMgrVtbl(iface); + FIXME("STUB:(%p)\n",This); + return E_NOTIMPL; +} + +static HRESULT WINAPI KeystrokeMgr_IsPreservedKey(ITfKeystrokeMgr *iface, + REFGUID rguid, const TF_PRESERVEDKEY *pprekey, BOOL *pfRegistered) +{ + ThreadMgr *This = impl_from_ITfKeystrokeMgrVtbl(iface); + FIXME("STUB:(%p)\n",This); + return E_NOTIMPL; +} + +static HRESULT WINAPI KeystrokeMgr_PreserveKey(ITfKeystrokeMgr *iface, + TfClientId tid, REFGUID rguid, const TF_PRESERVEDKEY *prekey, + const WCHAR *pchDesc, ULONG cchDesc) +{ + ThreadMgr *This = impl_from_ITfKeystrokeMgrVtbl(iface); + FIXME("STUB:(%p)\n",This); + return E_NOTIMPL; +} + +static HRESULT WINAPI KeystrokeMgr_UnpreserveKey(ITfKeystrokeMgr *iface, + REFGUID rguid, const TF_PRESERVEDKEY *pprekey) +{ + ThreadMgr *This = impl_from_ITfKeystrokeMgrVtbl(iface); + FIXME("STUB:(%p)\n",This); + return E_NOTIMPL; +} + +static HRESULT WINAPI KeystrokeMgr_SetPreservedKeyDescription(ITfKeystrokeMgr *iface, + REFGUID rguid, const WCHAR *pchDesc, ULONG cchDesc) +{ + ThreadMgr *This = impl_from_ITfKeystrokeMgrVtbl(iface); + FIXME("STUB:(%p)\n",This); + return E_NOTIMPL; +} + +static HRESULT WINAPI KeystrokeMgr_GetPreservedKeyDescription(ITfKeystrokeMgr *iface, + REFGUID rguid, BSTR *pbstrDesc) +{ + ThreadMgr *This = impl_from_ITfKeystrokeMgrVtbl(iface); + FIXME("STUB:(%p)\n",This); + return E_NOTIMPL; +} + +static HRESULT WINAPI KeystrokeMgr_SimulatePreservedKey(ITfKeystrokeMgr *iface, + ITfContext *pic, REFGUID rguid, BOOL *pfEaten) +{ + ThreadMgr *This = impl_from_ITfKeystrokeMgrVtbl(iface); + FIXME("STUB:(%p)\n",This); + return E_NOTIMPL; +} + +static const ITfKeystrokeMgrVtbl ThreadMgr_KeystrokeMgrVtbl = +{ + 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 +}; + /***************************************************** * ITfThreadMgrEventSink functions (internal) *****************************************************/ @@ -550,6 +717,7 @@ HRESULT ThreadMgr_Constructor(IUnknown *pUnkOuter, IUnknown **ppOut) This->ThreadMgrVtbl= &ThreadMgr_ThreadMgrVtbl; This->SourceVtbl = &ThreadMgr_SourceVtbl; + This->KeystrokeMgrVtbl= &ThreadMgr_KeystrokeMgrVtbl; This->ThreadMgrEventSinkVtbl = &ThreadMgr_ThreadMgrEventSinkVtbl; This->refCount = 1; TlsSetValue(tlsIndex,This); diff --git a/include/msctf.idl b/include/msctf.idl index c81c0dae9b8..a0708ab5c85 100644 --- a/include/msctf.idl +++ b/include/msctf.idl @@ -56,6 +56,7 @@ interface ITfRangeBackup; interface IEnumTfLanguageProfiles; interface ITfEditRecord; interface ITfCompositionView; +interface ITfKeyEventSink; typedef [uuid(e1b5808d-1e46-4c19-84dc-68c5f5978cc8)] struct TF_LANGUAGEPROFILE { @@ -66,6 +67,12 @@ typedef [uuid(e1b5808d-1e46-4c19-84dc-68c5f5978cc8)] struct TF_LANGUAGEPROFILE GUID guidProfile; } TF_LANGUAGEPROFILE; +typedef [uuid(77c12f95-b783-450d-879f-1cd2362c6521)] struct TF_PRESERVEDKEY +{ + UINT uVKey; + UINT uModifiers; +} TF_PRESERVEDKEY; + [ object, uuid(aa80e801-2021-11d2-93e0-0060b067b86e), @@ -510,3 +517,78 @@ interface ITfThreadMgrEventSink : IUnknown HRESULT OnPopContext( [in] ITfContext *pic); }; + +[ + object, + local, + uuid(aa80e7f0-2021-11d2-93e0-0060b067b86e), + pointer_default(unique) +] +interface ITfKeystrokeMgr : IUnknown +{ + HRESULT AdviseKeyEventSink( + [in] TfClientId tid, + [in] ITfKeyEventSink *pSink, + [in] BOOL fForeground); + + HRESULT UnadviseKeyEventSink( + [in] TfClientId tid); + + HRESULT GetForeground( + [out] CLSID *pclsid); + + HRESULT TestKeyDown( + [in] WPARAM wParam, + [in] LPARAM lParam, + [out] BOOL *pfEaten); + + HRESULT TestKeyUp( + [in] WPARAM wParam, + [in] LPARAM lParam, + [out] BOOL *pfEaten); + + HRESULT KeyDown( + [in] WPARAM wParam, + [in] LPARAM lParam, + [out] BOOL *pfEaten); + + HRESULT KeyUp( + [in] WPARAM wParam, + [in] LPARAM lParam, + [out] BOOL *pfEaten); + + HRESULT GetPreservedKey( + [in] ITfContext *pic, + [in] const TF_PRESERVEDKEY *pprekey, + [out] GUID *pguid); + + HRESULT IsPreservedKey( + [in] REFGUID rguid, + [in] const TF_PRESERVEDKEY *pprekey, + [out] BOOL *pfRegistered); + + HRESULT PreserveKey( + [in] TfClientId tid, + [in] REFGUID rguid, + [in] const TF_PRESERVEDKEY *prekey, + [in, size_is(cchDesc)] const WCHAR *pchDesc, + [in] ULONG cchDesc); + + HRESULT UnpreserveKey( + [in] REFGUID rguid, + [in] const TF_PRESERVEDKEY *pprekey); + + HRESULT SetPreservedKeyDescription( + [in] REFGUID rguid, + [in, size_is(cchDesc)] const WCHAR *pchDesc, + [in] ULONG cchDesc); + + HRESULT GetPreservedKeyDescription( + [in] REFGUID rguid, + [out] BSTR *pbstrDesc); + + HRESULT SimulatePreservedKey( + [in] ITfContext *pic, + [in] REFGUID rguid, + [out] BOOL *pfEaten); +};