Fix the lag when committing with number keys.

This commit is contained in:
fanlusky committed 2026-07-05 17:56:00 +08:00
1 parent 0341d48c41
commit faa379faae
3 files changed
+47

No files matched your search

+28
View File
@@ -1001,6 +1001,34 @@ LRESULT CALLBACK CMetasequoiaIME_WindowProc(HWND hWnd, UINT message, WPARAM wPar
.c_str());
break;
}
case WM_AsyncNumberCandidateCommit: {
PerfTimer timer;
ITfDocumentMgr *pDocMgrFocus = nullptr;
ITfContext *pContext = nullptr;
if (SUCCEEDED(pIME->_GetThreadMgr()->GetFocus(&pDocMgrFocus)) && pDocMgrFocus)
{
if (SUCCEEDED(pDocMgrFocus->GetTop(&pContext)) && pContext)
{
_KEYSTROKE_STATE KeystrokeState;
KeystrokeState.Category = CATEGORY_CANDIDATE;
KeystrokeState.Function = FUNCTION_SELECT_BY_NUMBER;
OutputDebugString(fmt::format(
L"[msime-perf] WM_AsyncNumberCandidateCommit begin elapsed=0ms keycode={}",
static_cast<UINT>(wParam))
.c_str());
pIME->_InvokeKeyHandler(pContext, static_cast<UINT>(wParam), static_cast<WCHAR>(lParam), 0,
KeystrokeState);
pContext->Release();
}
pDocMgrFocus->Release();
}
OutputDebugString(fmt::format(
L"[msime-perf] WM_AsyncNumberCandidateCommit end elapsed={:.3f}ms keycode={}",
timer.ElapsedMs(), static_cast<UINT>(wParam))
.c_str());
break;
}
case WM_CleanupCandidatePresenter: {
pIME->_DrainPendingCandidatePresenterCleanup();
break;
+1
View File
@@ -25,6 +25,7 @@ const DWORD WM_CommitCandidate = WM_USER + 9;
const DWORD WM_CleanupCandidatePresenter = WM_USER + 10;
const DWORD WM_AsyncFinalizeCandidate = WM_USER + 11;
const DWORD WM_AsyncPunctuationCommit = WM_USER + 12;
const DWORD WM_AsyncNumberCandidateCommit = WM_USER + 13;
LRESULT CALLBACK CMetasequoiaIME_WindowProc(HWND wndHandle, UINT uMsg, WPARAM wParam, LPARAM lParam);
class CMetasequoiaIME : public ITfTextInputProcessorEx,
+18
View File
@@ -501,6 +501,24 @@ STDAPI CMetasequoiaIME::OnKeyDown(ITfContext *pContext, WPARAM wParam, LPARAM lP
.c_str());
return S_OK;
}
if (KeystrokeState.Function == FUNCTION_SELECT_BY_NUMBER && _msgWndHandle)
{
OutputDebugString(fmt::format(
L"[msime-perf] OnKeyDown post async select-by-number elapsed_from_begin={:.3f}ms keycode={} category={} function={}",
onKeyDownTimer.ElapsedMs(), code,
static_cast<int>(KeystrokeState.Category),
static_cast<int>(KeystrokeState.Function))
.c_str());
PostMessage(_msgWndHandle, WM_AsyncNumberCandidateCommit, code, static_cast<LPARAM>(wch));
OutputDebugString(fmt::format(
L"[msime-perf] OnKeyDown end total={:.3f}ms eaten={} keycode={} category={} function={} async_select_by_number=1",
onKeyDownTimer.ElapsedMs(), *pIsEaten, code,
static_cast<int>(KeystrokeState.Category),
static_cast<int>(KeystrokeState.Function))
.c_str());
return S_OK;
}
}
if (*pIsEaten)