Skip to content

Commit

Permalink
移除ThreadFocusSink
Browse files Browse the repository at this point in the history
  • Loading branch information
Techince committed Nov 14, 2023
1 parent a31ffa0 commit c2ade87
Show file tree
Hide file tree
Showing 10 changed files with 22 additions and 48 deletions.
7 changes: 2 additions & 5 deletions WeaselTSF/CompartmentTSF.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,13 +165,10 @@ HRESULT WeaselTSF::_HandleCompartment(REFGUID guidCompartment)
#endif // TEST
}
else if (IsEqualGUID(guidCompartment, GUID_COMPARTMENT_KEYBOARD_INPUTMODE_CONVERSION))
{
/*weasel::ResponseParser parser(nullptr, nullptr, &_status, nullptr, &_cand->style());
bool ok = m_client.GetResponseData(std::ref(parser));
_UpdateLanguageBar(_status);*/
{
#ifdef TEST
DWORD flag;
_pCompartmentConversion->_GetCompartmentDWORD(flag);
#ifdef TEST
LOG(INFO) << std::format("From WeaselTSF::_HandleCompartment. GUID_COMPARTMENT_KEYBOARD_INPUTMODE_CONVERSION, flag = 0x{:X}", (unsigned)flag);
#endif // TEST
}
Expand Down
15 changes: 3 additions & 12 deletions WeaselTSF/Composition.ixx
Original file line number Diff line number Diff line change
Expand Up @@ -151,13 +151,8 @@ STDAPI CStartCompositionEditSession::DoEditSession(TfEditCookie ec)
tfSelection.style.fInterimChar = FALSE;
hr = _pContext->SetSelection(ec, 1, &tfSelection);
}

com_ptr<ITfProperty> pProperty;
_pContext->GetProperty(GUID_PROP_COMPOSING, &pProperty);
VARIANT var;
pProperty->GetValue(ec, pRangeComposition, &var);
#ifdef TEST
LOG(INFO) << std::format("From CStartCompositionEditSession::DoEditSession. hr = {:#x}, property = {:s}", (unsigned)hr, (bool)var.boolVal);
LOG(INFO) << std::format("From CStartCompositionEditSession::DoEditSession. hr = {:#x}", (unsigned)hr);
#endif // TEST

return hr;
Expand Down Expand Up @@ -204,15 +199,11 @@ STDAPI CGetTextExtentEditSession::DoEditSession(TfEditCookie ec)
// note: selection.range is always an empty range
hr = _pContext->GetEnd(ec, &pRangeComposition);
}
com_ptr<ITfProperty> pProperty;
_pContext->GetProperty(GUID_PROP_COMPOSING, &pProperty);
VARIANT var;
pProperty->GetValue(ec, pRangeComposition, &var);

hr = _pContextView->GetTextExt(ec, pRangeComposition, &rc, &fClipped);
#ifdef TEST
LOG(INFO) << std::format("From CGetTextExtentEditSession::DoEditSession. rc.left = {}, rc.top = {}, hr = {:#x}, fClipped = {:s}, property = {:s}",
rc.left, rc.top, (unsigned)hr, (bool)fClipped, (bool)var.boolVal);
LOG(INFO) << std::format("From CGetTextExtentEditSession::DoEditSession. rc.left = {}, rc.top = {}, hr = {:#x}, fClipped = {:s}",
rc.left, rc.top, (unsigned)hr, (bool)fClipped);
#endif // TEST
if (hr == 0x80040057)
{
Expand Down
28 changes: 17 additions & 11 deletions WeaselTSF/ThreadFocusSink.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,15 @@ STDMETHODIMP WeaselTSF::OnSetThreadFocus()
#ifdef TEST
LOG(INFO) << std::format("From WeaselTSF::OnSetThreadFocus. _pComposition ? {:s}", (bool)_IsComposing());
#endif // TEST
com_ptr<ITfDocumentMgr> pCandidateListDocumentMgr;
if (SUCCEEDED(_pTextEditSinkContext->GetDocumentMgr(&pCandidateListDocumentMgr)))
if (_pComposition)
{
if (pCandidateListDocumentMgr == _pDocMgrLastFocused)
com_ptr<ITfDocumentMgr> pCandidateListDocumentMgr;
if (SUCCEEDED(_pTextEditSinkContext->GetDocumentMgr(&pCandidateListDocumentMgr)))
{
_cand->SetThreadFocus();
if (pCandidateListDocumentMgr == _pDocMgrLastFocused)
{
_cand->SetThreadFocus();
}
}
}
return S_OK;
Expand All @@ -28,17 +31,20 @@ STDMETHODIMP WeaselTSF::OnKillThreadFocus()
#ifdef TEST
LOG(INFO) << std::format("From WeaselTSF::OnKillThreadFocus. _pComposition ? {:s}", (bool)_IsComposing());
#endif // TEST
com_ptr<ITfDocumentMgr> pCandidateListDocumentMgr;

if (SUCCEEDED(_pTextEditSinkContext->GetDocumentMgr(&pCandidateListDocumentMgr)))
if (_pComposition)
{
if (_pDocMgrLastFocused)
com_ptr<ITfDocumentMgr> pCandidateListDocumentMgr;

if (SUCCEEDED(_pTextEditSinkContext->GetDocumentMgr(&pCandidateListDocumentMgr)))
{
_pDocMgrLastFocused.Release();
if (_pDocMgrLastFocused)
{
_pDocMgrLastFocused.Release();
}
_pDocMgrLastFocused = pCandidateListDocumentMgr;
}
_pDocMgrLastFocused = pCandidateListDocumentMgr;
_cand->KillThreadFocus();
}
_cand->KillThreadFocus();
return S_OK;
}

Expand Down
7 changes: 0 additions & 7 deletions WeaselTSF/WeaselTSF.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ WeaselTSF::WeaselTSF()
_cRef = 1;

_dwThreadMgrEventSinkCookie = TF_INVALID_COOKIE;
_dwThreadFocusSinkCookie = TF_INVALID_COOKIE;
_dwTextEditSinkCookie = TF_INVALID_COOKIE;
_dwTextLayoutSinkCookie = TF_INVALID_COOKIE;
_activeLanguageProfileNotifySinkCookie = TF_INVALID_COOKIE;
Expand Down Expand Up @@ -123,8 +122,6 @@ STDAPI WeaselTSF::QueryInterface(REFIID riid, void **ppvObject)
*ppvObject = (ITfCompositionSink*)this;
else if (IsEqualIID(riid, IID_ITfEditSession))
*ppvObject = (ITfEditSession*)this;
else if (IsEqualIID(riid, IID_ITfThreadFocusSink))
*ppvObject = (ITfThreadFocusSink*)this;
else if (IsEqualIID(riid, IID_ITfDisplayAttributeProvider))
*ppvObject = (ITfDisplayAttributeProvider*)this;

Expand Down Expand Up @@ -166,7 +163,6 @@ STDAPI WeaselTSF::Deactivate()

_UninitActiveLanguageProfileNotifySink();

_UninitThreadFocusSink();
_UninitThreadMgrEventSink();

_UninitKeyEventSink();
Expand Down Expand Up @@ -202,9 +198,6 @@ STDAPI WeaselTSF::ActivateEx(ITfThreadMgr *pThreadMgr, TfClientId tfClientId, DW
_InitTextEditSink(pDocMgrFocus);
}

if (!_InitThreadFocusSink())
goto ExitError;

if (!_InitKeyEventSink())
goto ExitError;

Expand Down
9 changes: 0 additions & 9 deletions WeaselTSF/WeaselTSF.ixx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ export
public ITfTextLayoutSink,
public ITfKeyEventSink,
public ITfCompositionSink,
public ITfThreadFocusSink,
public ITfActiveLanguageProfileNotifySink,
public ITfEditSession,
public ITfDisplayAttributeProvider,
Expand Down Expand Up @@ -65,10 +64,6 @@ export
STDMETHODIMP OnKeyUp(ITfContext* pContext, WPARAM wParam, LPARAM lParam, BOOL* pfEaten);
STDMETHODIMP OnPreservedKey(ITfContext* pContext, REFGUID rguid, BOOL* pfEaten);

// ITfThreadFocusSink
STDMETHODIMP OnSetThreadFocus();
STDMETHODIMP OnKillThreadFocus();

/* ITfCompositionSink */
STDMETHODIMP OnCompositionTerminated(TfEditCookie ecWrite, ITfComposition* pComposition);

Expand Down Expand Up @@ -182,9 +177,6 @@ export
void _UninitCompartment();
HRESULT _HandleCompartment(REFGUID guidCompartment);

BOOL _InitThreadFocusSink();
void _UninitThreadFocusSink();

BOOL _InitStatusSink();
void _UninitStatusSink();

Expand All @@ -195,7 +187,6 @@ export
com_ptr<ITfThreadMgr> _pThreadMgr;
TfClientId _tfClientId;
DWORD _dwThreadMgrEventSinkCookie;
DWORD _dwThreadFocusSinkCookie;

com_ptr<ITfContext> _pTextEditSinkContext;
DWORD _dwTextEditSinkCookie, _dwTextLayoutSinkCookie;
Expand Down
1 change: 0 additions & 1 deletion WeaselTSF/WeaselTSF.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,6 @@
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
</ClCompile>
<ClCompile Include="TextEditSink.cpp" />
<ClCompile Include="ThreadFocusSink.cpp" />
<ClCompile Include="ThreadMgrEventSink.cpp" />
<ClCompile Include="WeaselTSF.cpp" />
<ClCompile Include="WeaselTSF.ixx" />
Expand Down
3 changes: 0 additions & 3 deletions WeaselTSF/WeaselTSF.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,6 @@
<ClCompile Include="WeaselTSF.ixx">
<Filter>Module Files</Filter>
</ClCompile>
<ClCompile Include="ThreadFocusSink.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="StatusSink.cpp">
<Filter>Source Files</Filter>
</ClCompile>
Expand Down
Binary file modified lib/rime.lib
Binary file not shown.
Binary file modified lib/rime.pdb
Binary file not shown.
Binary file modified output/rime.dll
Binary file not shown.

0 comments on commit c2ade87

Please sign in to comment.