ReactOS.org
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2024
December
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
August
July
June
May
April
March
February
January
2008
December
November
October
September
August
July
June
May
April
March
February
January
2007
December
November
October
September
August
July
June
May
April
March
February
January
2006
December
November
October
September
August
July
June
May
April
March
February
January
2005
December
November
October
September
August
July
June
May
April
March
February
January
2004
December
November
October
September
August
July
June
May
April
March
February
List overview
Download
Ros-diffs
December 2023
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
----- 2008 -----
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
----- 2007 -----
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
----- 2006 -----
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006
----- 2005 -----
December 2005
November 2005
October 2005
September 2005
August 2005
July 2005
June 2005
May 2005
April 2005
March 2005
February 2005
January 2005
----- 2004 -----
December 2004
November 2004
October 2004
September 2004
August 2004
July 2004
June 2004
May 2004
April 2004
March 2004
February 2004
ros-diffs@reactos.org
20 participants
274 discussions
Start a n
N
ew thread
[reactos] 01/01: [MSCTFIME] Implemenet CicBridge::InitIMMX/UnInitIMMX (#6201)
by Katayama Hirofumi MZ
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=0d8e6e781c43be1770eba…
commit 0d8e6e781c43be1770eba8a762a6b0a3cfcbc9be Author: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com> AuthorDate: Wed Dec 20 16:12:57 2023 +0900 Commit: GitHub <noreply(a)github.com> CommitDate: Wed Dec 20 16:12:57 2023 +0900 [MSCTFIME] Implemenet CicBridge::InitIMMX/UnInitIMMX (#6201) - Define LIBTHREAD structure. - Add InitDisplayAttrbuteLib and UninitDisplayAttrbuteLib helper functions. - Define CThreadMgrEventSink class. - Strengthen CicBridge class. CORE-19360 --- dll/ime/msctfime/msctfime.cpp | 416 +++++++++++++++++++++++++++++++++++++----- 1 file changed, 372 insertions(+), 44 deletions(-) diff --git a/dll/ime/msctfime/msctfime.cpp b/dll/ime/msctfime/msctfime.cpp index b2a0b979bbb..db9c0fe352b 100644 --- a/dll/ime/msctfime/msctfime.cpp +++ b/dll/ime/msctfime/msctfime.cpp @@ -26,6 +26,9 @@ UINT WM_MSIME_SHOWIMEPAD = 0; UINT WM_MSIME_MOUSE = 0; UINT WM_MSIME_KEYMAP = 0; +/** + * @implemented + */ BOOL IsMsImeMessage(UINT uMsg) { return (uMsg == WM_MSIME_SERVICE || @@ -40,6 +43,33 @@ BOOL IsMsImeMessage(UINT uMsg) uMsg == WM_MSIME_KEYMAP); } +/** + * @implemented + */ +BOOL RegisterMSIMEMessage(VOID) +{ + WM_MSIME_SERVICE = RegisterWindowMessageW(L"MSIMEService"); + WM_MSIME_UIREADY = RegisterWindowMessageW(L"MSIMEUIReady"); + WM_MSIME_RECONVERTREQUEST = RegisterWindowMessageW(L"MSIMEReconvertRequest"); + WM_MSIME_RECONVERT = RegisterWindowMessageW(L"MSIMEReconvert"); + WM_MSIME_DOCUMENTFEED = RegisterWindowMessageW(L"MSIMEDocumentFeed"); + WM_MSIME_QUERYPOSITION = RegisterWindowMessageW(L"MSIMEQueryPosition"); + WM_MSIME_MODEBIAS = RegisterWindowMessageW(L"MSIMEModeBias"); + WM_MSIME_SHOWIMEPAD = RegisterWindowMessageW(L"MSIMEShowImePad"); + WM_MSIME_MOUSE = RegisterWindowMessageW(L"MSIMEMouseOperation"); + WM_MSIME_KEYMAP = RegisterWindowMessageW(L"MSIMEKeyMap"); + return (WM_MSIME_SERVICE && + WM_MSIME_UIREADY && + WM_MSIME_RECONVERTREQUEST && + WM_MSIME_RECONVERT && + WM_MSIME_DOCUMENTFEED && + WM_MSIME_QUERYPOSITION && + WM_MSIME_MODEBIAS && + WM_MSIME_SHOWIMEPAD && + WM_MSIME_MOUSE && + WM_MSIME_KEYMAP); +} + typedef BOOLEAN (WINAPI *FN_DllShutDownInProgress)(VOID); EXTERN_C BOOLEAN WINAPI @@ -82,6 +112,58 @@ IsInteractiveUserLogon(VOID) return bOK && IsMember; } +typedef struct LIBTHREAD +{ + IUnknown *m_pUnknown1; + ITfDisplayAttributeMgr *m_pDisplayAttrMgr; +} LIBTHREAD, *PLIBTHREAD; + +HRESULT InitDisplayAttrbuteLib(PLIBTHREAD pLibThread) +{ + if (!pLibThread) + return E_FAIL; + + if (pLibThread->m_pDisplayAttrMgr) + { + pLibThread->m_pDisplayAttrMgr->Release(); + pLibThread->m_pDisplayAttrMgr = NULL; + } + + //FIXME + return E_NOTIMPL; +} + +HRESULT UninitDisplayAttrbuteLib(PLIBTHREAD pLibThread) +{ + if (!pLibThread) + return E_FAIL; + + if (pLibThread->m_pDisplayAttrMgr) + { + pLibThread->m_pDisplayAttrMgr->Release(); + pLibThread->m_pDisplayAttrMgr = NULL; + } + + return S_OK; +} + +void TFUninitLib_Thread(PLIBTHREAD pLibThread) +{ + if (!pLibThread) + return; + + if (pLibThread->m_pUnknown1) + { + pLibThread->m_pUnknown1->Release(); + pLibThread->m_pUnknown1 = NULL; + } + if (pLibThread->m_pDisplayAttrMgr) + { + pLibThread->m_pDisplayAttrMgr->Release(); + pLibThread->m_pDisplayAttrMgr = NULL; + } +} + /* FIXME */ class CicInputContext : public ITfContextOwnerCompositionSink { @@ -305,21 +387,222 @@ struct ITfSysHookSink : IUnknown class TLS; +typedef INT (CALLBACK *FN_INITDOCMGR)(UINT, ITfDocumentMgr *, ITfDocumentMgr *, LPVOID); +typedef INT (CALLBACK *FN_PUSHPOP)(UINT, ITfContext *, LPVOID); + +class CThreadMgrEventSink : public ITfThreadMgrEventSink +{ +protected: + ITfThreadMgr *m_pThreadMgr; + DWORD m_dwCookie; + FN_INITDOCMGR m_fnInit; + FN_PUSHPOP m_fnPushPop; + DWORD m_dw; + LPVOID m_pCallbackPV; + LONG m_cRefs; + +public: + CThreadMgrEventSink( + FN_INITDOCMGR fnInit, + FN_PUSHPOP fnPushPop = NULL, + LPVOID pvCallbackPV = NULL); + virtual ~CThreadMgrEventSink() { } + + void SetCallbackPV(LPVOID pv); + HRESULT _Advise(ITfThreadMgr *pThreadMgr); + HRESULT _Unadvise(); + + // IUnknown interface + STDMETHODIMP QueryInterface(REFIID riid, LPVOID* ppvObj) override; + STDMETHODIMP_(ULONG) AddRef() override; + STDMETHODIMP_(ULONG) Release() override; + + // ITfThreadMgrEventSink interface + STDMETHODIMP OnInitDocumentMgr(ITfDocumentMgr *pdim) override; + STDMETHODIMP OnUninitDocumentMgr(ITfDocumentMgr *pdim) override; + STDMETHODIMP OnSetFocus(ITfDocumentMgr *pdimFocus, ITfDocumentMgr *pdimPrevFocus) override; + STDMETHODIMP OnPushContext(ITfContext *pic) override; + STDMETHODIMP OnPopContext(ITfContext *pic) override; + + static INT CALLBACK DIMCallback( + UINT nCode, + ITfDocumentMgr *pDocMgr1, + ITfDocumentMgr *pDocMgr2, + LPVOID pUserData); +}; + +/** + * @implemented + */ +CThreadMgrEventSink::CThreadMgrEventSink( + FN_INITDOCMGR fnInit, + FN_PUSHPOP fnPushPop, + LPVOID pvCallbackPV) +{ + m_fnInit = fnInit; + m_fnPushPop = fnPushPop; + m_pCallbackPV = pvCallbackPV; + m_cRefs = 1; +} + +/** + * @implemented + */ +STDMETHODIMP CThreadMgrEventSink::QueryInterface(REFIID riid, LPVOID* ppvObj) +{ + if (IsEqualIID(riid, IID_IUnknown) || IsEqualIID(riid, IID_ITfThreadMgrEventSink)) + { + *ppvObj = this; + AddRef(); + return S_OK; + } + *ppvObj = NULL; + return E_NOINTERFACE; +} + +/** + * @implemented + */ +STDMETHODIMP_(ULONG) CThreadMgrEventSink::AddRef() +{ + return ::InterlockedIncrement(&m_cRefs); +} + +/** + * @implemented + */ +STDMETHODIMP_(ULONG) CThreadMgrEventSink::Release() +{ + if (::InterlockedDecrement(&m_cRefs) == 0) + { + delete this; + return 0; + } + return m_cRefs; +} + +INT CALLBACK +CThreadMgrEventSink::DIMCallback( + UINT nCode, + ITfDocumentMgr *pDocMgr1, + ITfDocumentMgr *pDocMgr2, + LPVOID pUserData) +{ + return E_NOTIMPL; +} + +STDMETHODIMP CThreadMgrEventSink::OnInitDocumentMgr(ITfDocumentMgr *pdim) +{ + if (!m_fnInit) + return S_OK; + return m_fnInit(0, pdim, NULL, m_pCallbackPV); +} + +STDMETHODIMP CThreadMgrEventSink::OnUninitDocumentMgr(ITfDocumentMgr *pdim) +{ + if (!m_fnInit) + return S_OK; + return m_fnInit(1, pdim, NULL, m_pCallbackPV); +} + +STDMETHODIMP +CThreadMgrEventSink::OnSetFocus(ITfDocumentMgr *pdimFocus, ITfDocumentMgr *pdimPrevFocus) +{ + if (!m_fnInit) + return S_OK; + return m_fnInit(2, pdimFocus, pdimPrevFocus, m_pCallbackPV); +} + +STDMETHODIMP CThreadMgrEventSink::OnPushContext(ITfContext *pic) +{ + if (!m_fnPushPop) + return S_OK; + return m_fnPushPop(3, pic, m_pCallbackPV); +} + +STDMETHODIMP CThreadMgrEventSink::OnPopContext(ITfContext *pic) +{ + if (!m_fnPushPop) + return S_OK; + return m_fnPushPop(4, pic, m_pCallbackPV); +} + +void CThreadMgrEventSink::SetCallbackPV(LPVOID pv) +{ + if (!m_pCallbackPV) + m_pCallbackPV = pv; +} + +HRESULT CThreadMgrEventSink::_Advise(ITfThreadMgr *pThreadMgr) +{ + m_pThreadMgr = NULL; + + HRESULT hr = E_FAIL; + ITfSource *pSource = NULL; + if (pThreadMgr->QueryInterface(IID_ITfSource, (void **)&pSource) == S_OK && + pSource->AdviseSink(IID_ITfThreadMgrEventSink, this, &m_dwCookie) == S_OK) + { + m_pThreadMgr = pThreadMgr; + pThreadMgr->AddRef(); + hr = S_OK; + } + + if (pSource) + pSource->Release(); + + return hr; +} + +HRESULT CThreadMgrEventSink::_Unadvise() +{ + HRESULT hr = E_FAIL; + ITfSource *pSource = NULL; + + if (m_pThreadMgr) + { + if (m_pThreadMgr->QueryInterface(IID_ITfSource, (void **)&pSource) == S_OK && + pSource->UnadviseSink(m_dwCookie) == S_OK) + { + hr = S_OK; + } + + if (pSource) + pSource->Release(); + } + + if (m_pThreadMgr) + { + m_pThreadMgr->Release(); + m_pThreadMgr = NULL; + } + + return hr; +} + /* FIXME */ class CicBridge : public ITfSysHookSink { protected: LONG m_cRefs; DWORD m_dwImmxInit; - DWORD m_dwUnknown[10]; + DWORD m_dw[3]; + ITfKeystrokeMgr *m_pKeystrokeMgr; + ITfDocumentMgr *m_pDocMgr; + CThreadMgrEventSink *m_pThreadMgrEventSink; + TfClientId m_cliendId; + LIBTHREAD m_LibThread; + DWORD m_dw21; public: CicBridge(); virtual ~CicBridge(); + // IUnknown interface STDMETHODIMP QueryInterface(REFIID riid, LPVOID* ppvObj) override; STDMETHODIMP_(ULONG) AddRef() override; STDMETHODIMP_(ULONG) Release() override; + + // ITfSysHookSink interface STDMETHODIMP OnPreFocusDIM(HWND hwnd) override; STDMETHODIMP OnSysKeyboardProc(UINT, LONG) override; STDMETHODIMP OnSysShellProc(INT, UINT, LONG) override; @@ -822,13 +1105,13 @@ CicProfile::InitProfileInstance(TLS *pTLS) CicBridge::CicBridge() { m_dwImmxInit &= ~1; - m_dwUnknown[0] &= ~1; - m_dwUnknown[1] &= ~1; - m_dwUnknown[9] &= ~1; - m_dwUnknown[3] = 0; - m_dwUnknown[4] = 0; - m_dwUnknown[5] = 0; - m_dwUnknown[6] = 0; + m_dw[0] &= ~1; + m_dw[1] &= ~1; + m_dw21 &= ~1; + m_pKeystrokeMgr = NULL; + m_pDocMgr = NULL; + m_pThreadMgrEventSink = NULL; + m_cliendId = 0; m_cRefs = 1; } @@ -926,7 +1209,7 @@ HRESULT CicBridge::DestroyInputContext(TLS *pTLS, HIMC hIMC) /** * @unimplemented */ -HRESULT CicBridge::InitIMMX(TLS *pTLS) +HRESULT CicBridge::ActivateIMMX(TLS *pTLS, ITfThreadMgr *pThreadMgr) { return E_NOTIMPL; } @@ -934,25 +1217,93 @@ HRESULT CicBridge::InitIMMX(TLS *pTLS) /** * @unimplemented */ -HRESULT CicBridge::ActivateIMMX(TLS *pTLS, ITfThreadMgr *pThreadMgr) +HRESULT CicBridge::DeactivateIMMX(TLS *pTLS, ITfThreadMgr *pThreadMgr) { return E_NOTIMPL; } /** - * @unimplemented + * @implemented */ -HRESULT CicBridge::DeactivateIMMX(TLS *pTLS, ITfThreadMgr *pThreadMgr) +HRESULT CicBridge::InitIMMX(TLS *pTLS) { - return E_NOTIMPL; + if (m_dwImmxInit & 1) + return S_OK; + + HRESULT hr; + if (!pTLS->m_pThreadMgr) + { + hr = TF_CreateThreadMgr(&pTLS->m_pThreadMgr); + if (FAILED(hr)) + return E_FAIL; + + hr = pTLS->m_pThreadMgr->QueryInterface(IID_ITfThreadMgr, (void **)&pTLS->m_pThreadMgr); + if (FAILED(hr)) + { + pTLS->m_pThreadMgr->Release(); + pTLS->m_pThreadMgr = NULL; + return E_FAIL; + } + } + + if (!m_pThreadMgrEventSink) + { + m_pThreadMgrEventSink = + new CThreadMgrEventSink(CThreadMgrEventSink::DIMCallback, NULL, NULL); + if (!m_pThreadMgrEventSink) + { + UnInitIMMX(pTLS); + return E_FAIL; + } + } + + m_pThreadMgrEventSink->SetCallbackPV(m_pThreadMgrEventSink); + m_pThreadMgrEventSink->_Advise(pTLS->m_pThreadMgr); + + if (!pTLS->m_pProfile) + { + pTLS->m_pProfile = new CicProfile(); + if (!pTLS->m_pProfile) + return E_OUTOFMEMORY; + hr = pTLS->m_pProfile->InitProfileInstance(pTLS); + if (FAILED(hr)) + { + UnInitIMMX(pTLS); + return E_FAIL; + } + } + + hr = pTLS->m_pThreadMgr->QueryInterface(IID_ITfKeystrokeMgr, (void **)&m_pKeystrokeMgr); + if (FAILED(hr)) + { + UnInitIMMX(pTLS); + return E_FAIL; + } + + hr = InitDisplayAttrbuteLib(&m_LibThread); + if (FAILED(hr)) + { + UnInitIMMX(pTLS); + return E_FAIL; + } + + m_dwImmxInit |= 1; + return S_OK; } /** - * @unimplemented + * @implemented */ BOOL CicBridge::UnInitIMMX(TLS *pTLS) { - //FIXME + UninitDisplayAttrbuteLib(&m_LibThread); + TFUninitLib_Thread(&m_LibThread); + + if (m_pKeystrokeMgr) + { + m_pKeystrokeMgr->Release(); + m_pKeystrokeMgr = NULL; + } if (pTLS->m_pProfile) { @@ -960,7 +1311,12 @@ BOOL CicBridge::UnInitIMMX(TLS *pTLS) pTLS->m_pProfile = NULL; } - //FIXME + if (m_pThreadMgrEventSink) + { + m_pThreadMgrEventSink->_Unadvise(); + m_pThreadMgrEventSink->Release(); + m_pThreadMgrEventSink = NULL; + } if (pTLS->m_pThreadMgr) { @@ -969,7 +1325,6 @@ BOOL CicBridge::UnInitIMMX(TLS *pTLS) } m_dwImmxInit &= ~1; - return TRUE; } @@ -1746,33 +2101,6 @@ VOID UnregisterImeClass(VOID) DestroyIcon(wcx.hIconSm); } -/** - * @implemented - */ -BOOL RegisterMSIMEMessage(VOID) -{ - WM_MSIME_SERVICE = RegisterWindowMessageW(L"MSIMEService"); - WM_MSIME_UIREADY = RegisterWindowMessageW(L"MSIMEUIReady"); - WM_MSIME_RECONVERTREQUEST = RegisterWindowMessageW(L"MSIMEReconvertRequest"); - WM_MSIME_RECONVERT = RegisterWindowMessageW(L"MSIMEReconvert"); - WM_MSIME_DOCUMENTFEED = RegisterWindowMessageW(L"MSIMEDocumentFeed"); - WM_MSIME_QUERYPOSITION = RegisterWindowMessageW(L"MSIMEQueryPosition"); - WM_MSIME_MODEBIAS = RegisterWindowMessageW(L"MSIMEModeBias"); - WM_MSIME_SHOWIMEPAD = RegisterWindowMessageW(L"MSIMEShowImePad"); - WM_MSIME_MOUSE = RegisterWindowMessageW(L"MSIMEMouseOperation"); - WM_MSIME_KEYMAP = RegisterWindowMessageW(L"MSIMEKeyMap"); - return (WM_MSIME_SERVICE && - WM_MSIME_UIREADY && - WM_MSIME_RECONVERTREQUEST && - WM_MSIME_RECONVERT && - WM_MSIME_DOCUMENTFEED && - WM_MSIME_QUERYPOSITION && - WM_MSIME_MODEBIAS && - WM_MSIME_SHOWIMEPAD && - WM_MSIME_MOUSE && - WM_MSIME_KEYMAP); -} - /** * @implemented */
1 year
1
0
0
0
[reactos] 01/01: [MSCTFIME] Implement CActiveLanguageProfileNotifySink (#6200)
by Katayama Hirofumi MZ
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=0b7405abf20e33caaf944…
commit 0b7405abf20e33caaf944560483f7247e80d3558 Author: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com> AuthorDate: Wed Dec 20 12:29:03 2023 +0900 Commit: GitHub <noreply(a)github.com> CommitDate: Wed Dec 20 12:29:03 2023 +0900 [MSCTFIME] Implement CActiveLanguageProfileNotifySink (#6200) - Add link to msctf.dll. - Implement CActiveLanguageProfileNotifySink class. - Strengthen CicProfile class. CORE-19360 --- dll/ime/msctfime/CMakeLists.txt | 2 +- dll/ime/msctfime/msctfime.cpp | 368 +++++++++++++++++++++++++++++++++++++++- 2 files changed, 368 insertions(+), 2 deletions(-) diff --git a/dll/ime/msctfime/CMakeLists.txt b/dll/ime/msctfime/CMakeLists.txt index db81c3f65e6..72e89de4e9c 100644 --- a/dll/ime/msctfime/CMakeLists.txt +++ b/dll/ime/msctfime/CMakeLists.txt @@ -17,5 +17,5 @@ add_library(msctfime MODULE set_module_type(msctfime win32dll UNICODE) set_target_properties(msctfime PROPERTIES SUFFIX ".ime") target_link_libraries(msctfime wine uuid) -add_importlibs(msctfime oleaut32 imm32 user32 gdi32 advapi32 comctl32 msvcrt kernel32 ntdll) +add_importlibs(msctfime msctf oleaut32 imm32 user32 gdi32 advapi32 comctl32 msvcrt kernel32 ntdll) add_cd_file(TARGET msctfime DESTINATION reactos/system32 FOR all) diff --git a/dll/ime/msctfime/msctfime.cpp b/dll/ime/msctfime/msctfime.cpp index 8ada6608e6c..b2a0b979bbb 100644 --- a/dll/ime/msctfime/msctfime.cpp +++ b/dll/ime/msctfime/msctfime.cpp @@ -334,12 +334,348 @@ public: HRESULT ConfigureRegisterWord(TLS* pTLS, ITfThreadMgr *pThreadMgr, HKL hKL, HWND hWnd, LPVOID lpData); }; +class CActiveLanguageProfileNotifySink : public ITfActiveLanguageProfileNotifySink +{ +protected: + typedef INT (CALLBACK *FN_COMPARE)(REFGUID rguid1, REFGUID rguid2, BOOL fActivated, LPVOID pUserData); + LONG m_cRefs; + ITfThreadMgr *m_pThreadMgr; + DWORD m_dwConnection; + FN_COMPARE m_fnCompare; + LPVOID m_pUserData; + +public: + CActiveLanguageProfileNotifySink(FN_COMPARE fnCompare, void *pUserData); + virtual ~CActiveLanguageProfileNotifySink(); + + HRESULT _Advise(ITfThreadMgr *pThreadMgr); + HRESULT _Unadvise(); + + // IUnknown interface + STDMETHODIMP QueryInterface(REFIID riid, LPVOID* ppvObj) override; + STDMETHODIMP_(ULONG) AddRef() override; + STDMETHODIMP_(ULONG) Release() override; + + // ITfActiveLanguageProfileNotifySink interface + STDMETHODIMP + OnActivated( + REFCLSID clsid, + REFGUID guidProfile, + BOOL fActivated) override; +}; + +/** + * @implemented + */ +CActiveLanguageProfileNotifySink::CActiveLanguageProfileNotifySink( + FN_COMPARE fnCompare, + void *pUserData) +{ + m_dwConnection = (DWORD)-1; + m_fnCompare = fnCompare; + m_cRefs = 1; + m_pUserData = pUserData; +} + +/** + * @implemented + */ +CActiveLanguageProfileNotifySink::~CActiveLanguageProfileNotifySink() +{ +} + +/** + * @implemented + */ +STDMETHODIMP CActiveLanguageProfileNotifySink::QueryInterface(REFIID riid, LPVOID* ppvObj) +{ + if (IsEqualIID(riid, IID_IUnknown) || IsEqualIID(riid, IID_ITfActiveLanguageProfileNotifySink)) + { + *ppvObj = this; + AddRef(); + return S_OK; + } + *ppvObj = NULL; + return E_NOINTERFACE; +} + +/** + * @implemented + */ +STDMETHODIMP_(ULONG) CActiveLanguageProfileNotifySink::AddRef() +{ + return ::InterlockedIncrement(&m_cRefs); +} + +/** + * @implemented + */ +STDMETHODIMP_(ULONG) CActiveLanguageProfileNotifySink::Release() +{ + if (::InterlockedDecrement(&m_cRefs) == 0) + { + delete this; + return 0; + } + return m_cRefs; +} + +/** + * @implemented + */ +STDMETHODIMP +CActiveLanguageProfileNotifySink::OnActivated( + REFCLSID clsid, + REFGUID guidProfile, + BOOL fActivated) +{ + if (!m_fnCompare) + return 0; + + return m_fnCompare(clsid, guidProfile, fActivated, m_pUserData); +} + +/** + * @implemented + */ +HRESULT +CActiveLanguageProfileNotifySink::_Advise( + ITfThreadMgr *pThreadMgr) +{ + m_pThreadMgr = NULL; + + ITfSource *pSource = NULL; + HRESULT hr = pThreadMgr->QueryInterface(IID_ITfSource, (void **)&pSource); + if (FAILED(hr)) + return E_FAIL; + + hr = pSource->AdviseSink(IID_ITfActiveLanguageProfileNotifySink, this, &m_dwConnection); + if (SUCCEEDED(hr)) + { + m_pThreadMgr = pThreadMgr; + pThreadMgr->AddRef(); + hr = S_OK; + } + else + { + hr = E_FAIL; + } + + if (pSource) + pSource->Release(); + + return hr; +} + +/** + * @implemented + */ +HRESULT +CActiveLanguageProfileNotifySink::_Unadvise() +{ + if (!m_pThreadMgr) + return E_FAIL; + + ITfSource *pSource = NULL; + HRESULT hr = m_pThreadMgr->QueryInterface(IID_ITfSource, (void **)&pSource); + if (SUCCEEDED(hr)) + { + hr = pSource->UnadviseSink(m_dwConnection); + if (SUCCEEDED(hr)) + hr = S_OK; + } + + if (pSource) + pSource->Release(); + + if (m_pThreadMgr) + { + m_pThreadMgr->Release(); + m_pThreadMgr = NULL; + } + + return hr; +} + /* FIXME */ -struct CicProfile : IUnknown +class CicProfile : public IUnknown { +protected: + ITfInputProcessorProfiles *m_pIPProfiles; + CActiveLanguageProfileNotifySink *m_pActiveLanguageProfileNotifySink; + LANGID m_LangID1; + WORD m_padding1; + DWORD m_dwFlags; + UINT m_nCodePage; + LANGID m_LangID2; + WORD m_padding2; + DWORD m_dw3[1]; + LONG m_cRefs; + + static INT CALLBACK + ActiveLanguageProfileNotifySinkCallback( + REFGUID rguid1, + REFGUID rguid2, + BOOL fActivated, + LPVOID pUserData); + +public: + CicProfile(); + virtual ~CicProfile(); + + // IUnknown interface + STDMETHODIMP QueryInterface(REFIID riid, LPVOID* ppvObj) override; + STDMETHODIMP_(ULONG) AddRef() override; + STDMETHODIMP_(ULONG) Release() override; + HRESULT GetActiveLanguageProfile(HKL hKL, REFGUID rguid, TF_LANGUAGEPROFILE *pProfile); + HRESULT GetLangId(LANGID *pLangID); + HRESULT GetCodePageA(UINT *puCodePage); + + HRESULT InitProfileInstance(TLS *pTLS); }; +/** + * @implemented + */ +CicProfile::CicProfile() +{ + m_dwFlags &= 0xFFFFFFF0; + m_cRefs = 1; + m_pIPProfiles = NULL; + m_pActiveLanguageProfileNotifySink = NULL; + m_LangID1 = 0; + m_nCodePage = CP_ACP; + m_LangID2 = 0; + m_dw3[0] = 0; +} + +/** + * @implemented + */ +CicProfile::~CicProfile() +{ + if (m_pIPProfiles) + { + if (m_LangID1) + m_pIPProfiles->ChangeCurrentLanguage(m_LangID1); + + m_pIPProfiles->Release(); + m_pIPProfiles = NULL; + } + + if (m_pActiveLanguageProfileNotifySink) + { + m_pActiveLanguageProfileNotifySink->_Unadvise(); + m_pActiveLanguageProfileNotifySink->Release(); + m_pActiveLanguageProfileNotifySink = NULL; + } +} + +/** + * @implemented + */ +STDMETHODIMP CicProfile::QueryInterface(REFIID riid, LPVOID* ppvObj) +{ + *ppvObj = NULL; + return E_NOINTERFACE; +} + +/** + * @implemented + */ +STDMETHODIMP_(ULONG) CicProfile::AddRef() +{ + return ::InterlockedIncrement(&m_cRefs); +} + +/** + * @implemented + */ +STDMETHODIMP_(ULONG) CicProfile::Release() +{ + if (::InterlockedDecrement(&m_cRefs) == 0) + { + delete this; + return 0; + } + return m_cRefs; +} + +/** + * @implemented + */ +INT CALLBACK +CicProfile::ActiveLanguageProfileNotifySinkCallback( + REFGUID rguid1, + REFGUID rguid2, + BOOL fActivated, + LPVOID pUserData) +{ + CicProfile *pThis = (CicProfile *)pUserData; + pThis->m_dwFlags &= ~0xE; + return 0; +} + +/** + * @implemented + */ +HRESULT CicProfile::GetCodePageA(UINT *puCodePage) +{ + if (!puCodePage) + return E_INVALIDARG; + + if (m_dwFlags & 2) + { + *puCodePage = m_nCodePage; + return S_OK; + } + + *puCodePage = 0; + + LANGID LangID; + HRESULT hr = GetLangId(&LangID); + if (FAILED(hr)) + return E_FAIL; + + WCHAR szBuff[12]; + INT cch = ::GetLocaleInfoW(LangID, LOCALE_IDEFAULTANSICODEPAGE, szBuff, _countof(szBuff)); + if (cch) + { + szBuff[cch] = 0; + m_nCodePage = *puCodePage = wcstoul(szBuff, NULL, 10); + m_dwFlags |= 2; + } + + return S_OK; +} + +/** + * @implemented + */ +HRESULT CicProfile::GetLangId(LANGID *pLangID) +{ + *pLangID = 0; + + if (!m_pIPProfiles) + return E_FAIL; + + if (m_dwFlags & 4) + { + *pLangID = m_LangID2; + return S_OK; + } + + HRESULT hr = m_pIPProfiles->GetCurrentLanguage(pLangID); + if (SUCCEEDED(hr)) + { + m_dwFlags |= 4; + m_LangID2 = *pLangID; + } + + return hr; +} + class TLS { public: @@ -449,6 +785,36 @@ BOOL TLS::InternalDestroyTLS() return TRUE; } +/** + * @implemented + */ +HRESULT +CicProfile::InitProfileInstance(TLS *pTLS) +{ + HRESULT hr = TF_CreateInputProcessorProfiles(&m_pIPProfiles); + if (FAILED(hr)) + return hr; + + if (!m_pActiveLanguageProfileNotifySink) + { + CActiveLanguageProfileNotifySink *pSink = + new CActiveLanguageProfileNotifySink( + CicProfile::ActiveLanguageProfileNotifySinkCallback, this); + if (!pSink) + { + m_pIPProfiles->Release(); + m_pIPProfiles = NULL; + return E_FAIL; + } + m_pActiveLanguageProfileNotifySink = pSink; + } + + if (pTLS->m_pThreadMgr) + m_pActiveLanguageProfileNotifySink->_Advise(pTLS->m_pThreadMgr); + + return hr; +} + /*********************************************************************** * CicBridge */
1 year
1
0
0
0
[reactos] 01/01: [MSCTFIME] Fix build of #6197 (6c438e4) Part 2
by Katayama Hirofumi MZ
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=f889c29af691e0e956c8d…
commit f889c29af691e0e956c8d3bae08f7b647c9ff643 Author: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com> AuthorDate: Tue Dec 19 20:10:53 2023 +0900 Commit: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com> CommitDate: Tue Dec 19 20:10:53 2023 +0900 [MSCTFIME] Fix build of #6197 (6c438e4) Part 2 Add link to oleaut32.dll. CORE-19360 --- dll/ime/msctfime/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dll/ime/msctfime/CMakeLists.txt b/dll/ime/msctfime/CMakeLists.txt index 3dea866e674..db81c3f65e6 100644 --- a/dll/ime/msctfime/CMakeLists.txt +++ b/dll/ime/msctfime/CMakeLists.txt @@ -17,5 +17,5 @@ add_library(msctfime MODULE set_module_type(msctfime win32dll UNICODE) set_target_properties(msctfime PROPERTIES SUFFIX ".ime") target_link_libraries(msctfime wine uuid) -add_importlibs(msctfime imm32 user32 gdi32 advapi32 comctl32 msvcrt kernel32 ntdll) +add_importlibs(msctfime oleaut32 imm32 user32 gdi32 advapi32 comctl32 msvcrt kernel32 ntdll) add_cd_file(TARGET msctfime DESTINATION reactos/system32 FOR all)
1 year
1
0
0
0
[reactos] 01/01: [MSCTFIME] Fix build of #6197 (6c438e4)
by Katayama Hirofumi MZ
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=a4491256924ef73f3a228…
commit a4491256924ef73f3a228fb5816ac158b768b4a6 Author: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com> AuthorDate: Tue Dec 19 19:36:53 2023 +0900 Commit: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com> CommitDate: Tue Dec 19 19:36:53 2023 +0900 [MSCTFIME] Fix build of #6197 (6c438e4) CORE-19360 --- dll/ime/msctfime/msctfime.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/dll/ime/msctfime/msctfime.cpp b/dll/ime/msctfime/msctfime.cpp index 1fcdf3363a4..8ada6608e6c 100644 --- a/dll/ime/msctfime/msctfime.cpp +++ b/dll/ime/msctfime/msctfime.cpp @@ -684,13 +684,13 @@ CicBridge::ConfigureRegisterWord( if (FAILED(hr)) return hr; - ITfFunctionProvider *pProvider; + ITfFunctionProvider *pProvider = NULL; hr = pThreadMgr->GetFunctionProvider(profile.clsid, &pProvider); if (FAILED(hr)) return hr; - ITfFnConfigureRegisterWord *pFunction; - hr = pProvider->GetFunction(GUID_NULL, IID_ITfFnConfigureRegisterWord, (IUnknown**)pFunction); + ITfFnConfigureRegisterWord *pFunction = NULL; + hr = pProvider->GetFunction(GUID_NULL, IID_ITfFnConfigureRegisterWord, (IUnknown**)&pFunction); if (FAILED(hr)) { pProvider->Release();
1 year
1
0
0
0
[reactos] 01/01: [MSCTFIME] Implement ImeConfigure (#6197)
by Katayama Hirofumi MZ
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=6c438e4530fe2e26c4b89…
commit 6c438e4530fe2e26c4b8922934660e68cfb79aa4 Author: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com> AuthorDate: Tue Dec 19 19:23:52 2023 +0900 Commit: GitHub <noreply(a)github.com> CommitDate: Tue Dec 19 19:23:52 2023 +0900 [MSCTFIME] Implement ImeConfigure (#6197) Add code to CicInputContext and CicBridge classes. Implement ImeConfigure function by using them. CORE-19360 --- dll/ime/msctfime/msctfime.cpp | 166 +++++++++++++++++++++++++++++++++++++++++- dll/ime/msctfime/msctfime.h | 2 + 2 files changed, 166 insertions(+), 2 deletions(-) diff --git a/dll/ime/msctfime/msctfime.cpp b/dll/ime/msctfime/msctfime.cpp index 8d1d17f364a..1fcdf3363a4 100644 --- a/dll/ime/msctfime/msctfime.cpp +++ b/dll/ime/msctfime/msctfime.cpp @@ -83,7 +83,7 @@ IsInteractiveUserLogon(VOID) } /* FIXME */ -class CicInputContext : public IUnknown +class CicInputContext : public ITfContextOwnerCompositionSink { LONG m_cRefs; public: @@ -95,10 +95,16 @@ public: { } + // IUnknown interface STDMETHODIMP QueryInterface(REFIID riid, LPVOID* ppvObj) override; STDMETHODIMP_(ULONG) AddRef() override; STDMETHODIMP_(ULONG) Release() override; + // ITfContextOwnerCompositionSink interface + STDMETHODIMP OnStartComposition(ITfCompositionView *pComposition, BOOL *pfOk) override; + STDMETHODIMP OnUpdateComposition(ITfCompositionView *pComposition, ITfRange *pRangeNew) override; + STDMETHODIMP OnEndComposition(ITfCompositionView *pComposition) override; + HRESULT GetGuidAtom( _Inout_ IMCLock& imcLock, @@ -152,6 +158,38 @@ STDMETHODIMP_(ULONG) CicInputContext::Release() return m_cRefs; } +/** + * @unimplemented + */ +STDMETHODIMP +CicInputContext::OnStartComposition( + ITfCompositionView *pComposition, + BOOL *pfOk) +{ + return E_NOTIMPL; +} + +/** + * @unimplemented + */ +STDMETHODIMP +CicInputContext::OnUpdateComposition( + ITfCompositionView *pComposition, + ITfRange *pRangeNew) +{ + return E_NOTIMPL; +} + +/** + * @unimplemented + */ +STDMETHODIMP +CicInputContext::OnEndComposition( + ITfCompositionView *pComposition) +{ + return E_NOTIMPL; +} + /** * @unimplemented */ @@ -291,11 +329,15 @@ public: HRESULT ActivateIMMX(TLS *pTLS, ITfThreadMgr *pThreadMgr); HRESULT DeactivateIMMX(TLS *pTLS, ITfThreadMgr *pThreadMgr); HRESULT DestroyInputContext(TLS *pTLS, HIMC hIMC); + + HRESULT ConfigureGeneral(TLS* pTLS, ITfThreadMgr *pThreadMgr, HKL hKL, HWND hWnd); + HRESULT ConfigureRegisterWord(TLS* pTLS, ITfThreadMgr *pThreadMgr, HKL hKL, HWND hWnd, LPVOID lpData); }; /* FIXME */ struct CicProfile : IUnknown { + HRESULT GetActiveLanguageProfile(HKL hKL, REFGUID rguid, TF_LANGUAGEPROFILE *pProfile); }; class TLS @@ -589,6 +631,112 @@ STDMETHODIMP CicBridge::OnSysShellProc(INT, UINT, LONG) return S_OK; } +HRESULT +CicBridge::ConfigureGeneral( + TLS* pTLS, + ITfThreadMgr *pThreadMgr, + HKL hKL, + HWND hWnd) +{ + CicProfile *pProfile = pTLS->m_pProfile; + if (!pProfile) + return E_OUTOFMEMORY; + + TF_LANGUAGEPROFILE profile; + HRESULT hr = pProfile->GetActiveLanguageProfile(hKL, GUID_TFCAT_TIP_KEYBOARD, &profile); + if (FAILED(hr)) + return hr; + + ITfFunctionProvider *pProvider = NULL; + hr = pThreadMgr->GetFunctionProvider(profile.clsid, &pProvider); + if (FAILED(hr)) + return hr; + + ITfFnConfigure *pFnConfigure = NULL; + hr = pProvider->GetFunction(GUID_NULL, IID_ITfFnConfigure, (IUnknown**)&pFnConfigure); + if (FAILED(hr)) + { + pProvider->Release(); + return hr; + } + + hr = pFnConfigure->Show(hWnd, profile.langid, profile.guidProfile); + + pFnConfigure->Release(); + pProvider->Release(); + return hr; +} + +HRESULT +CicBridge::ConfigureRegisterWord( + TLS* pTLS, + ITfThreadMgr *pThreadMgr, + HKL hKL, + HWND hWnd, + LPVOID lpData) +{ + CicProfile *pProfile = pTLS->m_pProfile; + if (!pProfile) + return E_OUTOFMEMORY; + + TF_LANGUAGEPROFILE profile; + HRESULT hr = pProfile->GetActiveLanguageProfile(hKL, GUID_TFCAT_TIP_KEYBOARD, &profile); + if (FAILED(hr)) + return hr; + + ITfFunctionProvider *pProvider; + hr = pThreadMgr->GetFunctionProvider(profile.clsid, &pProvider); + if (FAILED(hr)) + return hr; + + ITfFnConfigureRegisterWord *pFunction; + hr = pProvider->GetFunction(GUID_NULL, IID_ITfFnConfigureRegisterWord, (IUnknown**)pFunction); + if (FAILED(hr)) + { + pProvider->Release(); + return hr; + } + + REGISTERWORDW* pRegWord = (REGISTERWORDW*)lpData; + if (pRegWord) + { + if (pRegWord->lpWord) + { + hr = E_OUTOFMEMORY; + BSTR bstrWord = SysAllocString(pRegWord->lpWord); + if (bstrWord) + { + hr = pFunction->Show(hWnd, profile.langid, profile.guidProfile, bstrWord); + SysFreeString(bstrWord); + } + } + else + { + hr = pFunction->Show(hWnd, profile.langid, profile.guidProfile, NULL); + } + } + + pProvider->Release(); + pFunction->Release(); + return hr; +} + +/*********************************************************************** + * CicProfile + */ + +/** + * @unimplemented + */ +HRESULT +CicProfile::GetActiveLanguageProfile( + HKL hKL, + REFGUID rguid, + TF_LANGUAGEPROFILE *pProfile) +{ + return E_NOTIMPL; +} + /*********************************************************************** * ImeInquire (MSCTFIME.@) * @@ -709,7 +857,21 @@ ImeConfigure( _In_ DWORD dwMode, _Inout_opt_ LPVOID lpData) { - FIXME("stub:(%p, %p, %lu, %p)\n", hKL, hWnd, dwMode, lpData); + TRACE("(%p, %p, %lu, %p)\n", hKL, hWnd, dwMode, lpData); + + TLS *pTLS = TLS::GetTLS(); + if (!pTLS || !pTLS->m_pBridge || !pTLS->m_pThreadMgr) + return FALSE; + + CicBridge *pBridge = pTLS->m_pBridge; + ITfThreadMgr *pThreadMgr = pTLS->m_pThreadMgr; + + if (dwMode & 1) + return (pBridge->ConfigureGeneral(pTLS, pThreadMgr, hKL, hWnd) == S_OK); + + if (dwMode & 2) + return (pBridge->ConfigureRegisterWord(pTLS, pThreadMgr, hKL, hWnd, lpData) == S_OK); + return FALSE; } diff --git a/dll/ime/msctfime/msctfime.h b/dll/ime/msctfime/msctfime.h index 9b962285029..892bd76ef26 100644 --- a/dll/ime/msctfime/msctfime.h +++ b/dll/ime/msctfime/msctfime.h @@ -16,7 +16,9 @@ #include <windows.h> #include <imm.h> #include <ddk/immdev.h> +#include <cguid.h> #include <msctf.h> +#include <ctffunc.h> #include <shlwapi.h> #include <strsafe.h>
1 year
1
0
0
0
[reactos] 01/01: [MSCTFIME] Add TLS::PeekTLS and use it
by Katayama Hirofumi MZ
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=dfd6d7f32a8073e2746d9…
commit dfd6d7f32a8073e2746d9005c303059e943a81df Author: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com> AuthorDate: Tue Dec 19 18:34:08 2023 +0900 Commit: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com> CommitDate: Tue Dec 19 18:34:08 2023 +0900 [MSCTFIME] Add TLS::PeekTLS and use it Refactoring. CORE-19360 --- dll/ime/msctfime/msctfime.cpp | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/dll/ime/msctfime/msctfime.cpp b/dll/ime/msctfime/msctfime.cpp index 79472cf2b88..8d1d17f364a 100644 --- a/dll/ime/msctfime/msctfime.cpp +++ b/dll/ime/msctfime/msctfime.cpp @@ -344,8 +344,17 @@ public: return InternalAllocateTLS(); } + /** + * @implemented + */ + static TLS* PeekTLS() + { + return (TLS*)::TlsGetValue(TLS::s_dwTlsIndex); + } + static TLS* InternalAllocateTLS(); static BOOL InternalDestroyTLS(); + }; DWORD TLS::s_dwTlsIndex = (DWORD)-1; @@ -355,7 +364,7 @@ DWORD TLS::s_dwTlsIndex = (DWORD)-1; */ TLS* TLS::InternalAllocateTLS() { - TLS *pTLS = (TLS *)::TlsGetValue(TLS::s_dwTlsIndex); + TLS *pTLS = TLS::PeekTLS(); if (pTLS) return pTLS; @@ -382,10 +391,7 @@ TLS* TLS::InternalAllocateTLS() */ BOOL TLS::InternalDestroyTLS() { - if (s_dwTlsIndex == (DWORD)-1) - return FALSE; - - TLS *pTLS = (TLS *)::TlsGetValue(s_dwTlsIndex); + TLS *pTLS = TLS::PeekTLS(); if (!pTLS) return FALSE; @@ -460,7 +466,7 @@ STDMETHODIMP_(ULONG) CicBridge::Release() */ CicBridge::~CicBridge() { - TLS *pTLS = (TLS *)TlsGetValue(TLS::s_dwTlsIndex); + TLS *pTLS = TLS::PeekTLS(); if (!pTLS || !pTLS->m_pThreadMgr) return; @@ -718,7 +724,7 @@ ImeDestroy( { TRACE("(%u)\n", uReserved); - TLS *pTLS = (TLS *)::TlsGetValue(TLS::s_dwTlsIndex); + TLS *pTLS = TLS::PeekTLS(); if (pTLS) return FALSE; @@ -1009,7 +1015,7 @@ CtfImeDestroyThreadMgr(VOID) { TRACE("()\n"); - TLS *pTLS = (TLS *)::TlsGetValue(TLS::s_dwTlsIndex); + TLS *pTLS = TLS::PeekTLS(); if (!pTLS) return E_OUTOFMEMORY; @@ -1051,7 +1057,7 @@ CtfImeDestroyInputContext( { TRACE("(%p)\n", hIMC); - TLS *pTLS = (TLS*)::TlsGetValue(TLS::s_dwTlsIndex); + TLS *pTLS = TLS::PeekTLS(); if (!pTLS || !pTLS->m_pBridge) return E_OUTOFMEMORY;
1 year
1
0
0
0
[reactos] 01/01: [MSCTFIME] Implement CtfImeDestroyInputContext
by Katayama Hirofumi MZ
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=e0eab48aee832aa9b4d65…
commit e0eab48aee832aa9b4d65eaad46f24cc9eafe6ff Author: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com> AuthorDate: Tue Dec 19 16:40:03 2023 +0900 Commit: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com> CommitDate: Tue Dec 19 16:40:03 2023 +0900 [MSCTFIME] Implement CtfImeDestroyInputContext CORE-19360 --- dll/ime/msctfime/msctfime.cpp | 128 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 125 insertions(+), 3 deletions(-) diff --git a/dll/ime/msctfime/msctfime.cpp b/dll/ime/msctfime/msctfime.cpp index 8550caa2209..79472cf2b88 100644 --- a/dll/ime/msctfime/msctfime.cpp +++ b/dll/ime/msctfime/msctfime.cpp @@ -82,16 +82,76 @@ IsInteractiveUserLogon(VOID) return bOK && IsMember; } -class CicInputContext +/* FIXME */ +class CicInputContext : public IUnknown { + LONG m_cRefs; public: + CicInputContext() + { + m_cRefs = 1; + } + virtual ~CicInputContext() + { + } + + STDMETHODIMP QueryInterface(REFIID riid, LPVOID* ppvObj) override; + STDMETHODIMP_(ULONG) AddRef() override; + STDMETHODIMP_(ULONG) Release() override; + HRESULT GetGuidAtom( _Inout_ IMCLock& imcLock, _In_ DWORD dwUnknown, _Out_opt_ LPDWORD pdwGuidAtom); + + HRESULT DestroyInputContext(); }; +/** + * @unimplemented + */ +STDMETHODIMP CicInputContext::QueryInterface(REFIID riid, LPVOID* ppvObj) +{ + *ppvObj = NULL; + + if (IsEqualIID(riid, IID_ITfContextOwnerCompositionSink)) + { + *ppvObj = (ITfContextOwnerCompositionSink*)this; + AddRef(); + return S_OK; + } + if (IsEqualIID(riid, IID_IUnknown)) + { + *ppvObj = this; + AddRef(); + return S_OK; + } + + return E_NOINTERFACE; +} + +/** + * @implemented + */ +STDMETHODIMP_(ULONG) CicInputContext::AddRef() +{ + return ::InterlockedIncrement(&m_cRefs); +} + +/** + * @implemented + */ +STDMETHODIMP_(ULONG) CicInputContext::Release() +{ + if (::InterlockedDecrement(&m_cRefs) == 0) + { + delete this; + return 0; + } + return m_cRefs; +} + /** * @unimplemented */ @@ -114,6 +174,16 @@ CicInputContext::GetGuidAtom( return hr; } +/** + * @unimplemented + */ +HRESULT +CicInputContext::DestroyInputContext() +{ + // FIXME + return E_NOTIMPL; +} + /** * @implemented */ @@ -220,6 +290,7 @@ public: BOOL UnInitIMMX(TLS *pTLS); HRESULT ActivateIMMX(TLS *pTLS, ITfThreadMgr *pThreadMgr); HRESULT DeactivateIMMX(TLS *pTLS, ITfThreadMgr *pThreadMgr); + HRESULT DestroyInputContext(TLS *pTLS, HIMC hIMC); }; /* FIXME */ @@ -397,6 +468,47 @@ CicBridge::~CicBridge() UnInitIMMX(pTLS); } +/** + * @implemented + */ +HRESULT CicBridge::DestroyInputContext(TLS *pTLS, HIMC hIMC) +{ + IMCLock imcLock(hIMC); + HRESULT hr = imcLock.m_hr; + if (!imcLock) + hr = E_FAIL; + if (FAILED(hr)) + return hr; + + hr = E_FAIL; + IMCCLock<CTFIMECONTEXT> imeContext(imcLock.get().hCtfImeContext); + if (imeContext) + hr = imeContext.m_hr; + + if (SUCCEEDED(hr) && !(imeContext.get().m_dwCicFlags & 1)) + { + imeContext.get().m_dwCicFlags |= 1; + + CicInputContext *pCicIC = imeContext.get().m_pCicIC; + if (pCicIC) + { + imeContext.get().m_pCicIC = NULL; + hr = pCicIC->DestroyInputContext(); + pCicIC->Release(); + imeContext.get().m_pCicIC = NULL; + } + } + + if (imcLock.get().hCtfImeContext) + { + ImmDestroyIMCC(imcLock.get().hCtfImeContext); + imcLock.get().hCtfImeContext = NULL; + hr = S_OK; + } + + return hr; +} + /** * @unimplemented */ @@ -928,12 +1040,22 @@ CtfImeCreateInputContext( return E_NOTIMPL; } +/*********************************************************************** + * CtfImeDestroyInputContext (MSCTFIME.@) + * + * @implemented + */ EXTERN_C HRESULT WINAPI CtfImeDestroyInputContext( _In_ HIMC hIMC) { - FIXME("stub:(%p)\n", hIMC); - return E_NOTIMPL; + TRACE("(%p)\n", hIMC); + + TLS *pTLS = (TLS*)::TlsGetValue(TLS::s_dwTlsIndex); + if (!pTLS || !pTLS->m_pBridge) + return E_OUTOFMEMORY; + + return pTLS->m_pBridge->DestroyInputContext(pTLS, hIMC); } EXTERN_C HRESULT WINAPI
1 year
1
0
0
0
[reactos] 01/01: [MSCTFIME] Refactor on IMC/IMCC locking
by Katayama Hirofumi MZ
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=5197d36839a1f8bd21885…
commit 5197d36839a1f8bd21885ac9dbdb7c28404a5846 Author: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com> AuthorDate: Tue Dec 19 16:12:12 2023 +0900 Commit: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com> CommitDate: Tue Dec 19 16:12:12 2023 +0900 [MSCTFIME] Refactor on IMC/IMCC locking - Rename _IMCCLock as IMCCLOCK. - Rename InternalIMCCLock as IMCCLock. - Rename _IMCLock as IMCLOCK. - Add get() pointer accessor of IMCCLock and IMCLOCK. - Protect the pointer of IMCCLOCK and IMCLOCK. CORE-19360 --- dll/ime/msctfime/msctfime.cpp | 10 ++++----- sdk/include/reactos/cicero/imclock.h | 42 +++++++++++++++++++++++------------- 2 files changed, 32 insertions(+), 20 deletions(-) diff --git a/dll/ime/msctfime/msctfime.cpp b/dll/ime/msctfime/msctfime.cpp index f6830f9dc62..8550caa2209 100644 --- a/dll/ime/msctfime/msctfime.cpp +++ b/dll/ime/msctfime/msctfime.cpp @@ -101,7 +101,7 @@ CicInputContext::GetGuidAtom( _In_ DWORD dwUnknown, _Out_opt_ LPDWORD pdwGuidAtom) { - InternalIMCCLock<CTFIMECONTEXT> imeContext(imcLock.m_pIC->hCompStr); + IMCCLock<CTFIMECONTEXT> imeContext(imcLock.get().hCompStr); HRESULT hr = imeContext.m_hr; if (!imeContext) @@ -809,17 +809,17 @@ CtfImeGetGuidAtom( if (FAILED(hr)) return hr; - InternalIMCCLock<CTFIMECONTEXT> imccLock(imcLock.m_pIC->hCtfImeContext); + IMCCLock<CTFIMECONTEXT> imccLock(imcLock.get().hCtfImeContext); hr = imccLock.m_hr; if (!imccLock) hr = E_FAIL; if (FAILED(hr)) return hr; - if (!imccLock.m_pIMCC->m_pCicIC) + if (!imccLock.get().m_pCicIC) return E_OUTOFMEMORY; - hr = imccLock.m_pIMCC->m_pCicIC->GetGuidAtom(imcLock, dwUnknown, pdwGuidAtom); + hr = imccLock.get().m_pCicIC->GetGuidAtom(imcLock, dwUnknown, pdwGuidAtom); return hr; } @@ -842,7 +842,7 @@ CtfImeIsGuidMapEnable( if (!imcLock) hr = E_FAIL; if (SUCCEEDED(hr)) - ret = !!(imcLock.m_pIC->fdwInit & INIT_GUIDMAP); + ret = !!(imcLock.get().fdwInit & INIT_GUIDMAP); return ret; } diff --git a/sdk/include/reactos/cicero/imclock.h b/sdk/include/reactos/cicero/imclock.h index 0a2ff2368a8..3392c9a1107 100644 --- a/sdk/include/reactos/cicero/imclock.h +++ b/sdk/include/reactos/cicero/imclock.h @@ -7,20 +7,22 @@ #pragma once -// class _IMCCLock<T_DATA>; -// class InternalIMCCLock<T_DATA>; +// class IMCCLOCK<T_DATA>; +// class IMCCLock<T_DATA>; // class _IMCLock; // class IMCLock; template <typename T_DATA> -class _IMCCLock +class IMCCLOCK { -public: +protected: T_DATA *m_pIMCC; + +public: HIMCC m_hIMCC; HRESULT m_hr; - _IMCCLock(HIMCC hIMCC) + IMCCLOCK(HIMCC hIMCC) { m_pIMCC = NULL; m_hr = S_OK; @@ -29,15 +31,15 @@ public: }; template <typename T_DATA> -class InternalIMCCLock : public _IMCCLock<T_DATA> +class IMCCLock : public IMCCLOCK<T_DATA> { public: - InternalIMCCLock(HIMCC hIMCC) : _IMCCLock<T_DATA>(hIMCC) + IMCCLock(HIMCC hIMCC) : IMCCLOCK<T_DATA>(hIMCC) { if (hIMCC) _LockIMCC(this->m_hIMCC, &this->m_pIMCC); } - ~InternalIMCCLock() + ~IMCCLock() { if (this->m_pIMCC) _UnlockIMCC(this->m_hIMCC); @@ -46,6 +48,10 @@ public: { return this->m_pIMCC; } + T_DATA& get() const + { + return *this->m_pIMCC; + } protected: HRESULT _LockIMCC(HIMCC hIMCC, T_DATA **pptr) @@ -63,15 +69,17 @@ protected: } }; -class _IMCLock +class IMCLOCK { -public: +protected: LPINPUTCONTEXTDX m_pIC; + +public: HIMC m_hIMC; HRESULT m_hr; DWORD m_dw3; - _IMCLock(HIMC hIMC) + IMCLOCK(HIMC hIMC) { m_pIC = NULL; m_hIMC = hIMC; @@ -85,10 +93,10 @@ public: } }; -class IMCLock : public _IMCLock +class IMCLock : public IMCLOCK { public: - IMCLock(HIMC hIMC) : _IMCLock(hIMC) + IMCLock(HIMC hIMC) : IMCLOCK(hIMC) { m_hr = _LockIMC(hIMC, &m_pIC); } @@ -111,11 +119,11 @@ public: if (ImmGetIMCCSize(m_pIC->hCompStr) < sizeof(COMPOSITIONSTRING)) return FALSE; - InternalIMCCLock<COMPOSITIONSTRING> imccLock(m_pIC->hCompStr); + IMCCLock<COMPOSITIONSTRING> imccLock(m_pIC->hCompStr); if (!imccLock) return FALSE; - return imccLock.m_pIMCC->dwCompStrLen > 0; + return imccLock.get().dwCompStrLen > 0; } BOOL UseVerticalCompWindow() const @@ -127,6 +135,10 @@ public: { return m_pIC; } + INPUTCONTEXTDX& get() const + { + return *m_pIC; + } protected: HRESULT _LockIMC(HIMC hIMC, LPINPUTCONTEXTDX *ppIC)
1 year
1
0
0
0
[reactos] 01/01: [MSCTFIME][SDK] Implement CtfImeGuidAtom (#6196)
by Katayama Hirofumi MZ
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=52bd0c0c18298fe68971a…
commit 52bd0c0c18298fe68971a301bae58ba28c72e396 Author: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com> AuthorDate: Tue Dec 19 15:46:13 2023 +0900 Commit: GitHub <noreply(a)github.com> CommitDate: Tue Dec 19 15:46:13 2023 +0900 [MSCTFIME][SDK] Implement CtfImeGuidAtom (#6196) - Add CTFIMECONTEXT structure. - Add CicInputContext class. - Rename INPUTCONTEXTDX.dwUnknown5 as hCtfImeContext and retype it as HIMCC. - Implement CtfImeGetGuidAtom by using them. CORE-19360 --- dll/ime/msctfime/msctfime.cpp | 61 +++++++++++++++++++++++++++++++++++++++++-- dll/ime/msctfime/msctfime.h | 8 ++++++ sdk/include/ddk/immdev.h | 2 +- 3 files changed, 68 insertions(+), 3 deletions(-) diff --git a/dll/ime/msctfime/msctfime.cpp b/dll/ime/msctfime/msctfime.cpp index 2b6404f4819..f6830f9dc62 100644 --- a/dll/ime/msctfime/msctfime.cpp +++ b/dll/ime/msctfime/msctfime.cpp @@ -82,6 +82,38 @@ IsInteractiveUserLogon(VOID) return bOK && IsMember; } +class CicInputContext +{ +public: + HRESULT + GetGuidAtom( + _Inout_ IMCLock& imcLock, + _In_ DWORD dwUnknown, + _Out_opt_ LPDWORD pdwGuidAtom); +}; + +/** + * @unimplemented + */ +HRESULT +CicInputContext::GetGuidAtom( + _Inout_ IMCLock& imcLock, + _In_ DWORD dwUnknown, + _Out_opt_ LPDWORD pdwGuidAtom) +{ + InternalIMCCLock<CTFIMECONTEXT> imeContext(imcLock.m_pIC->hCompStr); + + HRESULT hr = imeContext.m_hr; + if (!imeContext) + hr = E_FAIL; + + if (FAILED(hr)) + return hr; + + // FIXME + return hr; +} + /** * @implemented */ @@ -756,14 +788,39 @@ CtfImeEscapeEx( return 0; } +/*********************************************************************** + * CtfImeGetGuidAtom (MSCTFIME.@) + * + * @implemented + */ EXTERN_C HRESULT WINAPI CtfImeGetGuidAtom( _In_ HIMC hIMC, _In_ DWORD dwUnknown, _Out_opt_ LPDWORD pdwGuidAtom) { - FIXME("stub:(%p, 0x%lX, %p)\n", hIMC, dwUnknown, pdwGuidAtom); - return E_FAIL; + TRACE("(%p, 0x%lX, %p)\n", hIMC, dwUnknown, pdwGuidAtom); + + IMCLock imcLock(hIMC); + + HRESULT hr = imcLock.m_hr; + if (!imcLock) + hr = E_FAIL; + if (FAILED(hr)) + return hr; + + InternalIMCCLock<CTFIMECONTEXT> imccLock(imcLock.m_pIC->hCtfImeContext); + hr = imccLock.m_hr; + if (!imccLock) + hr = E_FAIL; + if (FAILED(hr)) + return hr; + + if (!imccLock.m_pIMCC->m_pCicIC) + return E_OUTOFMEMORY; + + hr = imccLock.m_pIMCC->m_pCicIC->GetGuidAtom(imcLock, dwUnknown, pdwGuidAtom); + return hr; } /*********************************************************************** diff --git a/dll/ime/msctfime/msctfime.h b/dll/ime/msctfime/msctfime.h index 987ccf46d76..9b962285029 100644 --- a/dll/ime/msctfime/msctfime.h +++ b/dll/ime/msctfime/msctfime.h @@ -25,6 +25,14 @@ #include <cicero/CModulePath.h> #include <cicero/imclock.h> +class CicInputContext; + +typedef struct tagCTFIMECONTEXT +{ + CicInputContext *m_pCicIC; + DWORD m_dwCicFlags; +} CTFIMECONTEXT, *PCTFIMECONTEXT; + #include <wine/debug.h> #include "resource.h" diff --git a/sdk/include/ddk/immdev.h b/sdk/include/ddk/immdev.h index 5dfb82f3763..2d955dd81c6 100644 --- a/sdk/include/ddk/immdev.h +++ b/sdk/include/ddk/immdev.h @@ -149,7 +149,7 @@ typedef struct INPUTCONTEXTDX DWORD dwUnknown2; struct IME_STATE *pState; // +0x154 DWORD dwChange; // +0x158 - DWORD dwUnknown5; + HIMCC hCtfImeContext; } INPUTCONTEXTDX, *PINPUTCONTEXTDX, *LPINPUTCONTEXTDX; // bits of fdwInit of INPUTCONTEXT
1 year
1
0
0
0
[reactos] 01/01: [MSCTFIME][SDK] Implement CtfImeIsGuidMapEnable (#6195)
by Katayama Hirofumi MZ
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=6d100d5b291ca1048ad24…
commit 6d100d5b291ca1048ad24accee603c718de6cce2 Author: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com> AuthorDate: Tue Dec 19 15:23:12 2023 +0900 Commit: GitHub <noreply(a)github.com> CommitDate: Tue Dec 19 15:23:12 2023 +0900 [MSCTFIME][SDK] Implement CtfImeIsGuidMapEnable (#6195) - Add link to imm32.dll. - Add <cicero/imclock.h>. - Add INIT_GUIDMAP constant to <immdev.h>. - Implement CtfImeIsGuidMapEnable by using them. CORE-19360 --- dll/ime/msctfime/CMakeLists.txt | 2 +- dll/ime/msctfime/msctfime.cpp | 21 ++++- dll/ime/msctfime/msctfime.h | 1 + sdk/include/ddk/immdev.h | 1 + sdk/include/reactos/cicero/imclock.h | 145 +++++++++++++++++++++++++++++++++++ 5 files changed, 166 insertions(+), 4 deletions(-) diff --git a/dll/ime/msctfime/CMakeLists.txt b/dll/ime/msctfime/CMakeLists.txt index 10f18eab2d0..3dea866e674 100644 --- a/dll/ime/msctfime/CMakeLists.txt +++ b/dll/ime/msctfime/CMakeLists.txt @@ -17,5 +17,5 @@ add_library(msctfime MODULE set_module_type(msctfime win32dll UNICODE) set_target_properties(msctfime PROPERTIES SUFFIX ".ime") target_link_libraries(msctfime wine uuid) -add_importlibs(msctfime user32 gdi32 advapi32 comctl32 msvcrt kernel32 ntdll) +add_importlibs(msctfime imm32 user32 gdi32 advapi32 comctl32 msvcrt kernel32 ntdll) add_cd_file(TARGET msctfime DESTINATION reactos/system32 FOR all) diff --git a/dll/ime/msctfime/msctfime.cpp b/dll/ime/msctfime/msctfime.cpp index 8bf27f62d61..2b6404f4819 100644 --- a/dll/ime/msctfime/msctfime.cpp +++ b/dll/ime/msctfime/msctfime.cpp @@ -766,14 +766,29 @@ CtfImeGetGuidAtom( return E_FAIL; } +/*********************************************************************** + * CtfImeIsGuidMapEnable (MSCTFIME.@) + * + * @implemented + */ EXTERN_C BOOL WINAPI CtfImeIsGuidMapEnable( _In_ HIMC hIMC) { - FIXME("stub:(%p)\n", hIMC); - return FALSE; -} + TRACE("(%p)\n", hIMC); + + BOOL ret = FALSE; + HRESULT hr; + IMCLock imcLock(hIMC); + hr = imcLock.m_hr; + if (!imcLock) + hr = E_FAIL; + if (SUCCEEDED(hr)) + ret = !!(imcLock.m_pIC->fdwInit & INIT_GUIDMAP); + + return ret; +} /*********************************************************************** * CtfImeCreateThreadMgr (MSCTFIME.@) diff --git a/dll/ime/msctfime/msctfime.h b/dll/ime/msctfime/msctfime.h index 9e492902348..987ccf46d76 100644 --- a/dll/ime/msctfime/msctfime.h +++ b/dll/ime/msctfime/msctfime.h @@ -23,6 +23,7 @@ #include <cicero/cicbase.h> #include <cicero/osinfo.h> #include <cicero/CModulePath.h> +#include <cicero/imclock.h> #include <wine/debug.h> diff --git a/sdk/include/ddk/immdev.h b/sdk/include/ddk/immdev.h index 5fb513da443..5dfb82f3763 100644 --- a/sdk/include/ddk/immdev.h +++ b/sdk/include/ddk/immdev.h @@ -159,6 +159,7 @@ typedef struct INPUTCONTEXTDX #define INIT_LOGFONT 0x00000008 #define INIT_COMPFORM 0x00000010 #define INIT_SOFTKBDPOS 0x00000020 +#define INIT_GUIDMAP 0x00000040 // bits for INPUTCONTEXTDX.dwChange #define INPUTCONTEXTDX_CHANGE_OPEN 0x1 diff --git a/sdk/include/reactos/cicero/imclock.h b/sdk/include/reactos/cicero/imclock.h new file mode 100644 index 00000000000..0a2ff2368a8 --- /dev/null +++ b/sdk/include/reactos/cicero/imclock.h @@ -0,0 +1,145 @@ +/* + * PROJECT: ReactOS Cicero + * LICENSE: LGPL-2.1-or-later (
https://spdx.org/licenses/LGPL-2.1-or-later
) + * PURPOSE: Locking and Unlocking IMC and IMCC handles + * COPYRIGHT: Copyright 2023 Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com> + */ + +#pragma once + +// class _IMCCLock<T_DATA>; +// class InternalIMCCLock<T_DATA>; +// class _IMCLock; +// class IMCLock; + +template <typename T_DATA> +class _IMCCLock +{ +public: + T_DATA *m_pIMCC; + HIMCC m_hIMCC; + HRESULT m_hr; + + _IMCCLock(HIMCC hIMCC) + { + m_pIMCC = NULL; + m_hr = S_OK; + m_hIMCC = hIMCC; + } +}; + +template <typename T_DATA> +class InternalIMCCLock : public _IMCCLock<T_DATA> +{ +public: + InternalIMCCLock(HIMCC hIMCC) : _IMCCLock<T_DATA>(hIMCC) + { + if (hIMCC) + _LockIMCC(this->m_hIMCC, &this->m_pIMCC); + } + ~InternalIMCCLock() + { + if (this->m_pIMCC) + _UnlockIMCC(this->m_hIMCC); + } + operator T_DATA*() const + { + return this->m_pIMCC; + } + +protected: + HRESULT _LockIMCC(HIMCC hIMCC, T_DATA **pptr) + { + if (!hIMCC) + return E_INVALIDARG; + *pptr = (T_DATA*)::ImmLockIMCC(hIMCC); + return (*pptr ? S_OK : E_FAIL); + } + HRESULT _UnlockIMCC(HIMCC hIMCC) + { + if (!::ImmUnlockIMCC(hIMCC)) + return (::GetLastError() ? E_FAIL : S_OK); + return S_OK; + } +}; + +class _IMCLock +{ +public: + LPINPUTCONTEXTDX m_pIC; + HIMC m_hIMC; + HRESULT m_hr; + DWORD m_dw3; + + _IMCLock(HIMC hIMC) + { + m_pIC = NULL; + m_hIMC = hIMC; + m_hr = S_OK; + m_dw3 = 0; + } + + BOOL Invalid() const + { + return (!m_pIC || m_hr != S_OK); + } +}; + +class IMCLock : public _IMCLock +{ +public: + IMCLock(HIMC hIMC) : _IMCLock(hIMC) + { + m_hr = _LockIMC(hIMC, &m_pIC); + } + ~IMCLock() + { + if (m_pIC) + _UnlockIMC(m_hIMC); + } + + void InitContext() + { + if (!(m_pIC->fdwInit & INIT_COMPFORM)) + m_pIC->cfCompForm.dwStyle = 0; + for (UINT i = 0; i < 4; ++i) + m_pIC->cfCandForm[i].dwStyle = 0; + } + + BOOL ValidCompositionString() + { + if (ImmGetIMCCSize(m_pIC->hCompStr) < sizeof(COMPOSITIONSTRING)) + return FALSE; + + InternalIMCCLock<COMPOSITIONSTRING> imccLock(m_pIC->hCompStr); + if (!imccLock) + return FALSE; + + return imccLock.m_pIMCC->dwCompStrLen > 0; + } + + BOOL UseVerticalCompWindow() const + { + return m_pIC->cfCompForm.dwStyle && ((m_pIC->lfFont.A.lfEscapement / 900) % 4 == 3); + } + + operator INPUTCONTEXTDX*() const + { + return m_pIC; + } + +protected: + HRESULT _LockIMC(HIMC hIMC, LPINPUTCONTEXTDX *ppIC) + { + if (!hIMC) + return E_INVALIDARG; + + LPINPUTCONTEXTDX pIC = (LPINPUTCONTEXTDX)ImmLockIMC(hIMC); + *ppIC = pIC; + return (pIC ? S_OK : E_FAIL); + } + HRESULT _UnlockIMC(HIMC hIMC) + { + return ::ImmUnlockIMC(hIMC) ? S_OK : E_FAIL; + } +};
1 year
1
0
0
0
← Newer
1
...
6
7
8
9
10
11
12
...
28
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
Results per page:
10
25
50
100
200