From 3abb727915dcc6337140eed9a3c64e71b7fad173 Mon Sep 17 00:00:00 2001 From: Windmill_City <1449182174@qq.com> Date: Fri, 29 Dec 2023 08:53:09 +0800 Subject: [PATCH] allow non uiless mode --- IngameIME-Common | 2 +- include/imm/ImmInputContextImpl.hpp | 6 ++++-- include/tf/TfInputContextImpl.hpp | 5 +++-- src/ImmInputContextImpl.cpp | 33 +++++++++++++++-------------- src/IngameIMEImpl.cpp | 6 +++--- src/TfCompositionHandler.cpp | 14 ++++++------ src/TfInputContextImpl.cpp | 12 +++++++++-- 7 files changed, 46 insertions(+), 32 deletions(-) diff --git a/IngameIME-Common b/IngameIME-Common index cb68c8b..d4b0c36 160000 --- a/IngameIME-Common +++ b/IngameIME-Common @@ -1 +1 @@ -Subproject commit cb68c8b01162379fa91e6cb7b524a9088be6736f +Subproject commit d4b0c36add0584c47fe3b8f1d75d72e9b4be9a09 diff --git a/include/imm/ImmInputContextImpl.hpp b/include/imm/ImmInputContextImpl.hpp index 14d0006..f94ee49 100644 --- a/include/imm/ImmInputContextImpl.hpp +++ b/include/imm/ImmInputContextImpl.hpp @@ -21,11 +21,13 @@ class InputContextImpl : public InputContext HIMC ctx; - bool activated{false}; PreEditRect rect; + bool activated = false; + bool uiLess = false; + public: - InputContextImpl(const HWND hWnd); + InputContextImpl(const HWND hWnd, const bool uiLess); ~InputContextImpl(); protected: diff --git a/include/tf/TfInputContextImpl.hpp b/include/tf/TfInputContextImpl.hpp index 01d37a3..baae019 100644 --- a/include/tf/TfInputContextImpl.hpp +++ b/include/tf/TfInputContextImpl.hpp @@ -35,10 +35,11 @@ class InputContextImpl : public InputContext PreEditRect rect; - bool activated{false}; + bool activated = false; + bool uiLess = false; public: - InputContextImpl(const HWND hWnd); + InputContextImpl(const HWND hWnd, const bool uiLess); ~InputContextImpl(); public: diff --git a/src/ImmInputContextImpl.cpp b/src/ImmInputContextImpl.cpp index b8fabb8..082639e 100644 --- a/src/ImmInputContextImpl.cpp +++ b/src/ImmInputContextImpl.cpp @@ -25,7 +25,7 @@ LRESULT InputContextImpl::WndProc(HWND hWnd, UINT msg, WPARAM wparam, LPARAM lpa // PreEditCallback work lparam &= ~ISC_SHOWUICOMPOSITIONWINDOW; // Hide Candidate Window - lparam &= ~ISC_SHOWUICANDIDATEWINDOW; + if (inputCtx->uiLess) lparam &= ~ISC_SHOWUICANDIDATEWINDOW; break; case WM_IME_STARTCOMPOSITION: inputCtx->PreEditCallbackHolder::runCallback(CompositionState::Begin, nullptr); @@ -39,20 +39,20 @@ LRESULT InputContextImpl::WndProc(HWND hWnd, UINT msg, WPARAM wparam, LPARAM lpa inputCtx->CandidateListCallbackHolder::runCallback(CandidateListState::End, nullptr); return true; case WM_IME_NOTIFY: - switch (wparam) - { - case IMN_OPENCANDIDATE: - inputCtx->CandidateListCallbackHolder::runCallback(CandidateListState::Begin, nullptr); - return true; - case IMN_CHANGECANDIDATE: - inputCtx->procCand(); - return true; - case IMN_CLOSECANDIDATE: - inputCtx->CandidateListCallbackHolder::runCallback(CandidateListState::End, nullptr); - return true; - default: - break; - } + if (inputCtx->uiLess) switch (wparam) + { + case IMN_OPENCANDIDATE: + inputCtx->CandidateListCallbackHolder::runCallback(CandidateListState::Begin, nullptr); + return true; + case IMN_CHANGECANDIDATE: + inputCtx->procCand(); + return true; + case IMN_CLOSECANDIDATE: + inputCtx->CandidateListCallbackHolder::runCallback(CandidateListState::End, nullptr); + return true; + default: + break; + } if (wparam == IMN_SETCONVERSIONMODE) { inputCtx->InputModeCallbackHolder::runCallback(inputCtx->getInputMode()); @@ -68,8 +68,9 @@ LRESULT InputContextImpl::WndProc(HWND hWnd, UINT msg, WPARAM wparam, LPARAM lpa return DefWindowProcW(hWnd, msg, wparam, lparam); } -IngameIME::imm::InputContextImpl::InputContextImpl(const HWND hWnd) +IngameIME::imm::InputContextImpl::InputContextImpl(const HWND hWnd, const bool uiLess) : hWnd(hWnd) + , uiLess(uiLess) { // Reset to default context ImmAssociateContextEx(hWnd, NULL, IACE_DEFAULT); diff --git a/src/IngameIMEImpl.cpp b/src/IngameIMEImpl.cpp index 84e20b2..caabf36 100644 --- a/src/IngameIMEImpl.cpp +++ b/src/IngameIMEImpl.cpp @@ -5,11 +5,11 @@ namespace IngameIME { -InputContext* CreateInputContextWin32(HWND hWnd, API api) +InputContext* CreateInputContextWin32(const HWND hWnd, const API api, const bool uiLess) { if (api == API::TextServiceFramework) - return new tf::InputContextImpl(hWnd); + return new tf::InputContextImpl(hWnd, uiLess); else - return new imm::InputContextImpl(hWnd); + return new imm::InputContextImpl(hWnd, uiLess); } } // namespace IngameIME \ No newline at end of file diff --git a/src/TfCompositionHandler.cpp b/src/TfCompositionHandler.cpp index f4dbfcf..b131671 100644 --- a/src/TfCompositionHandler.cpp +++ b/src/TfCompositionHandler.cpp @@ -11,13 +11,15 @@ namespace IngameIME::tf CompositionHandler::CompositionHandler(InputContextImpl* inputCtx) : inputCtx(inputCtx) { - eleMgr = inputCtx->threadMgr; - COM_HR_BEGIN(S_OK); - ComQIPtr eleMgr(IID_ITfUIElementMgr, inputCtx->threadMgr); - ComQIPtr source(IID_ITfSource, eleMgr); - CHECK_HR(source->AdviseSink(IID_ITfUIElementSink, static_cast(this), &cookieEleSink)); + if (inputCtx->uiLess) + { + eleMgr = inputCtx->threadMgr; + ComQIPtr eleMgr(IID_ITfUIElementMgr, inputCtx->threadMgr); + ComQIPtr source(IID_ITfSource, eleMgr); + CHECK_HR(source->AdviseSink(IID_ITfUIElementSink, static_cast(this), &cookieEleSink)); + } // This EditCookie is useless TfEditCookie ec; @@ -27,7 +29,7 @@ CompositionHandler::CompositionHandler(InputContextImpl* inputCtx) &inputCtx->ctx, &ec)); - source = inputCtx->ctx; + ComQIPtr source(IID_ITfSource, inputCtx->ctx); CHECK_HR(source->AdviseSink(IID_ITfTextEditSink, static_cast(this), &cookieEditSink)); COM_HR_END(); diff --git a/src/TfInputContextImpl.cpp b/src/TfInputContextImpl.cpp index 0b43bdb..0a2a13a 100644 --- a/src/TfInputContextImpl.cpp +++ b/src/TfInputContextImpl.cpp @@ -5,8 +5,9 @@ namespace IngameIME::tf { -InputContextImpl::InputContextImpl(const HWND hWnd) +InputContextImpl::InputContextImpl(const HWND hWnd, const bool uiLess) : hWnd(hWnd) + , uiLess(uiLess) { COM_HR_BEGIN(S_OK); @@ -15,7 +16,14 @@ InputContextImpl::InputContextImpl(const HWND hWnd) CHECK_HR(getThreadMgr(&threadMgr)); ComQIPtr threadMgrEx(IID_ITfThreadMgrEx, threadMgr); - CHECK_HR(threadMgrEx->ActivateEx(&clientId, TF_TMAE_UIELEMENTENABLEDONLY)); + if (uiLess) + { + CHECK_HR(threadMgrEx->ActivateEx(&clientId, TF_TMAE_UIELEMENTENABLEDONLY)); + } + else + { + CHECK_HR(threadMgrEx->Activate(&clientId)); + } CHECK_HR(threadMgr->CreateDocumentMgr(&emptyDocMgr)); CHECK_HR(threadMgr->CreateDocumentMgr(&docMgr));