1 /* 2 * PROJECT: ReactOS msctfime.ime 3 * LICENSE: LGPL-2.1-or-later (https://spdx.org/licenses/LGPL-2.1-or-later) 4 * PURPOSE: The bridge of msctfime.ime 5 * COPYRIGHT: Copyright 2024 Katayama Hirofumi MZ <katayama.hirofumi.mz@gmail.com> 6 */ 7 8 #pragma once 9 10 #include "sinks.h" 11 #include "tls.h" 12 13 class CicBridge : public ITfSysHookSink 14 { 15 protected: 16 LONG m_cRefs; 17 BOOL m_bImmxInited; 18 BOOL m_bUnknown1; 19 BOOL m_bDeactivating; 20 DWORD m_cActivateLocks; 21 ITfKeystrokeMgr *m_pKeystrokeMgr; 22 ITfDocumentMgr *m_pDocMgr; 23 CThreadMgrEventSink *m_pThreadMgrEventSink; 24 TfClientId m_cliendId; 25 CIC_LIBTHREAD m_LibThread; 26 BOOL m_bUnknown2; 27 28 static BOOL CALLBACK EnumCreateInputContextCallback(HIMC hIMC, LPARAM lParam); 29 static BOOL CALLBACK EnumDestroyInputContextCallback(HIMC hIMC, LPARAM lParam); 30 31 LRESULT EscHanjaMode(TLS *pTLS, HIMC hIMC, LPVOID lpData); 32 33 public: 34 CicBridge(); 35 virtual ~CicBridge(); 36 37 // IUnknown interface 38 STDMETHODIMP QueryInterface(REFIID riid, LPVOID* ppvObj) override; 39 STDMETHODIMP_(ULONG) AddRef() override; 40 STDMETHODIMP_(ULONG) Release() override; 41 42 // ITfSysHookSink interface 43 STDMETHODIMP OnPreFocusDIM(HWND hwnd) override; 44 STDMETHODIMP OnSysKeyboardProc(UINT, LONG) override; 45 STDMETHODIMP OnSysShellProc(INT, UINT, LONG) override; 46 47 HRESULT InitIMMX(_Inout_ TLS *pTLS); 48 BOOL UnInitIMMX(_Inout_ TLS *pTLS); 49 HRESULT ActivateIMMX(_Inout_ TLS *pTLS, _Inout_ ITfThreadMgr_P *pThreadMgr); 50 HRESULT DeactivateIMMX(_Inout_ TLS *pTLS, _Inout_ ITfThreadMgr_P *pThreadMgr); 51 52 HRESULT CreateInputContext(TLS *pTLS, HIMC hIMC); 53 HRESULT DestroyInputContext(TLS *pTLS, HIMC hIMC); 54 ITfContext *GetInputContext(CicIMCCLock<CTFIMECONTEXT>& imeContext); 55 56 HRESULT SelectEx( 57 _Inout_ TLS *pTLS, 58 _Inout_ ITfThreadMgr_P *pThreadMgr, 59 _In_ HIMC hIMC, 60 _In_ BOOL fSelect, 61 _In_ HKL hKL); 62 HRESULT OnSetOpenStatus( 63 TLS *pTLS, 64 ITfThreadMgr_P *pThreadMgr, 65 CicIMCLock& imcLock, 66 CicInputContext *pCicIC); 67 68 void PostTransMsg(_In_ HWND hWnd, _In_ INT cTransMsgs, _In_ const TRANSMSG *pTransMsgs); 69 ITfDocumentMgr* GetDocumentManager(_Inout_ CicIMCCLock<CTFIMECONTEXT>& imeContext); 70 71 HRESULT 72 ConfigureGeneral(_Inout_ TLS* pTLS, 73 _In_ ITfThreadMgr *pThreadMgr, 74 _In_ HKL hKL, 75 _In_ HWND hWnd); 76 HRESULT ConfigureRegisterWord( 77 _Inout_ TLS* pTLS, 78 _In_ ITfThreadMgr *pThreadMgr, 79 _In_ HKL hKL, 80 _In_ HWND hWnd, 81 _Inout_opt_ LPVOID lpData); 82 83 HRESULT SetActiveContextAlways(TLS *pTLS, HIMC hIMC, BOOL fActive, HWND hWnd, HKL hKL); 84 85 void SetAssociate( 86 TLS *pTLS, 87 HWND hWnd, 88 HIMC hIMC, 89 ITfThreadMgr_P *pThreadMgr, 90 ITfDocumentMgr *pDocMgr); 91 92 HRESULT Notify( 93 TLS *pTLS, 94 ITfThreadMgr_P *pThreadMgr, 95 HIMC hIMC, 96 DWORD dwAction, 97 DWORD dwIndex, 98 DWORD_PTR dwValue); 99 100 BOOL ProcessKey( 101 TLS *pTLS, 102 ITfThreadMgr_P *pThreadMgr, 103 HIMC hIMC, 104 WPARAM wParam, 105 LPARAM lParam, 106 CONST LPBYTE lpbKeyState, 107 INT *pnUnknown60); 108 109 HRESULT ToAsciiEx( 110 TLS *pTLS, 111 ITfThreadMgr_P *pThreadMgr, 112 UINT uVirtKey, 113 UINT uScanCode, 114 CONST LPBYTE lpbKeyState, 115 LPTRANSMSGLIST lpTransBuf, 116 UINT fuState, 117 HIMC hIMC, 118 UINT *pResult); 119 120 BOOL SetCompositionString( 121 TLS *pTLS, 122 ITfThreadMgr_P *pThreadMgr, 123 HIMC hIMC, 124 DWORD dwIndex, 125 LPCVOID lpComp, 126 DWORD dwCompLen, 127 LPCVOID lpRead, 128 DWORD dwReadLen); 129 130 LRESULT EscapeKorean( 131 TLS *pTLS, 132 HIMC hIMC, 133 UINT uSubFunc, 134 LPVOID lpData); 135 136 static BOOL IsOwnDim(ITfDocumentMgr *pDocMgr); 137 138 BOOL 139 DoOpenCandidateHanja( 140 ITfThreadMgr_P *pThreadMgr, 141 CicIMCLock& imcLock, 142 CicInputContext *pCicIC); 143 144 HRESULT 145 OnSetConversionSentenceMode( 146 ITfThreadMgr_P *pThreadMgr, 147 CicIMCLock& imcLock, 148 CicInputContext *pCicIC, 149 DWORD dwValue, 150 LANGID LangID); 151 }; 152