Skip to content

Commit

Permalink
allow non uiless mode
Browse files Browse the repository at this point in the history
  • Loading branch information
Windmill-City committed Dec 29, 2023
1 parent 2761dfe commit 3abb727
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 32 deletions.
2 changes: 1 addition & 1 deletion IngameIME-Common
6 changes: 4 additions & 2 deletions include/imm/ImmInputContextImpl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
5 changes: 3 additions & 2 deletions include/tf/TfInputContextImpl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
33 changes: 17 additions & 16 deletions src/ImmInputContextImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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());
Expand All @@ -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);
Expand Down
6 changes: 3 additions & 3 deletions src/IngameIMEImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
14 changes: 8 additions & 6 deletions src/TfCompositionHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,15 @@ namespace IngameIME::tf
CompositionHandler::CompositionHandler(InputContextImpl* inputCtx)
: inputCtx(inputCtx)
{
eleMgr = inputCtx->threadMgr;

COM_HR_BEGIN(S_OK);

ComQIPtr<ITfUIElementMgr> eleMgr(IID_ITfUIElementMgr, inputCtx->threadMgr);
ComQIPtr<ITfSource> source(IID_ITfSource, eleMgr);
CHECK_HR(source->AdviseSink(IID_ITfUIElementSink, static_cast<ITfUIElementSink*>(this), &cookieEleSink));
if (inputCtx->uiLess)
{
eleMgr = inputCtx->threadMgr;
ComQIPtr<ITfUIElementMgr> eleMgr(IID_ITfUIElementMgr, inputCtx->threadMgr);
ComQIPtr<ITfSource> source(IID_ITfSource, eleMgr);
CHECK_HR(source->AdviseSink(IID_ITfUIElementSink, static_cast<ITfUIElementSink*>(this), &cookieEleSink));
}

// This EditCookie is useless
TfEditCookie ec;
Expand All @@ -27,7 +29,7 @@ CompositionHandler::CompositionHandler(InputContextImpl* inputCtx)
&inputCtx->ctx,
&ec));

source = inputCtx->ctx;
ComQIPtr<ITfSource> source(IID_ITfSource, inputCtx->ctx);
CHECK_HR(source->AdviseSink(IID_ITfTextEditSink, static_cast<ITfTextEditSink*>(this), &cookieEditSink));

COM_HR_END();
Expand Down
12 changes: 10 additions & 2 deletions src/TfInputContextImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -15,7 +16,14 @@ InputContextImpl::InputContextImpl(const HWND hWnd)
CHECK_HR(getThreadMgr(&threadMgr));

ComQIPtr<ITfThreadMgrEx> 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));
Expand Down

0 comments on commit 3abb727

Please sign in to comment.