[feat]: Do not eat keys when IME is unavailable in Chrome, Edge, etc.
This commit is contained in:
1 parent
9e8ab84692
commit
72e9809b4c
2 files changed
+32
No files matched your search
@@ -1,3 +1,4 @@
|
||||
#include "FanyUtils.h"
|
||||
#include "Private.h"
|
||||
#include "Globals.h"
|
||||
#include "SampleIME.h"
|
||||
@@ -8,6 +9,9 @@
|
||||
#include "SampleIMEBaseStructure.h"
|
||||
#include "fmt/format.h"
|
||||
#include "fmt/xchar.h"
|
||||
#include <atlbase.h>
|
||||
#include <string>
|
||||
#include <boost/lexical_cast.hpp>
|
||||
|
||||
// 0xF003, 0xF004 are the keys that the touch keyboard sends for next/previous
|
||||
#define THIRDPARTY_NEXTPAGE static_cast<WORD>(0xF003)
|
||||
@@ -345,6 +349,24 @@ STDAPI CSampleIME::OnKeyDown(ITfContext *pContext, WPARAM wParam, LPARAM lParam,
|
||||
|
||||
if (needInvokeKeyHandler)
|
||||
{
|
||||
TF_STATUS tfStatus;
|
||||
if (SUCCEEDED(pContext->GetStatus(&tfStatus)))
|
||||
{
|
||||
if (tfStatus.dwDynamicFlags & TF_SD_READONLY)
|
||||
{
|
||||
FanyUtuils::SendKeys(boost::lexical_cast<std::wstring>(wch));
|
||||
#ifdef FANY_DEBUG
|
||||
Global::LogMessageW(L"pContext is read-only");
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef FANY_DEBUG
|
||||
Global::LogMessageW(L"pContext is editable");
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
_InvokeKeyHandler(pContext, code, wch, (DWORD)lParam, KeystrokeState);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,8 @@
|
||||
#include "SampleIMEBaseStructure.h"
|
||||
#include <string>
|
||||
#include "Utils/FanyUtils.h"
|
||||
#include "fmt/format.h"
|
||||
#include "fmt/xchar.h"
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
@@ -661,8 +663,10 @@ HRESULT CSampleIME::_InvokeKeyHandler(_In_ ITfContext *pContext, UINT code, WCHA
|
||||
|
||||
// we'll insert a char ourselves in place of this keystroke
|
||||
pEditSession = new (std::nothrow) CKeyHandlerEditSession(this, pContext, code, wch, keyState);
|
||||
Global::LogMessageW(L"fanyfull01 _InvokeKeyHandler");
|
||||
if (pEditSession == nullptr)
|
||||
{
|
||||
Global::LogMessageW(L"fanyfull02 _InvokeKeyHandler");
|
||||
goto Exit;
|
||||
}
|
||||
|
||||
@@ -672,6 +676,12 @@ HRESULT CSampleIME::_InvokeKeyHandler(_In_ ITfContext *pContext, UINT code, WCHA
|
||||
// Do not specify TF_ES_SYNC so edit session is not invoked on WinWord
|
||||
//
|
||||
hr = pContext->RequestEditSession(_tfClientId, pEditSession, TF_ES_ASYNCDONTCARE | TF_ES_READWRITE, &hr);
|
||||
if (FAILED(hr))
|
||||
{
|
||||
Global::LogMessageW(L"fanyfull03 _InvokeKeyHandler");
|
||||
}
|
||||
|
||||
Global::LogMessageW(fmt::format(L"fanyfull04 _InvokeKeyHandler hr: {}", hr).c_str());
|
||||
|
||||
pEditSession->Release();
|
||||
|
||||
|
||||
Reference in new issue
Block a user