Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(windows): remove wm_keymandebug messages and functions #10055

Merged
merged 1 commit into from
Nov 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
144 changes: 0 additions & 144 deletions windows/src/engine/keyman32/appint/aiTIP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -234,14 +234,7 @@ extern "C" __declspec(dllexport) BOOL WINAPI TIPProcessKey(WPARAM wParam, LPARAM
AITIP::AITIP() {
::AIWin2000Unicode(); // I3574

FIsDebugControlWindow = FALSE;
useLegacy = FALSE;

WM_KEYMANDEBUG_CANDEBUG = RegisterWindowMessage("WM_KEYMANDEBUG_CANDEBUG");
WM_KEYMANDEBUG_GETUNICODESTATUS = RegisterWindowMessage("WM_KEYMANDEBUG_GETUNICODESTATUS");
WM_KEYMANDEBUG_GETCONTEXT = RegisterWindowMessage("WM_KEYMANDEBUG_GETCONTEXT");
WM_KEYMANDEBUG_ACTION = RegisterWindowMessage("WM_KEYMANDEBUG_ACTION");
WM_KEYMANDEBUG_RULEMATCH = RegisterWindowMessage("WM_KEYMANDEBUG_RULEMATCH");
}

AITIP::~AITIP() {
Expand All @@ -254,15 +247,6 @@ BOOL AITIP::CanHandleWindow(HWND ahwnd) {
return TRUE; // I3574
}

BOOL AITIP::HandleWindow(HWND ahwnd) {
FIsDebugControlWindow = IsDebugControlWindow(ahwnd);
return AIWin2000Unicode::HandleWindow(ahwnd); // I3574
}

BOOL AITIP::IsWindowHandled(HWND ahwnd) {
return AIWin2000Unicode::IsWindowHandled(ahwnd); // I3574
}

BOOL AITIP::IsUnicode() {
return TRUE;
}
Expand Down Expand Up @@ -335,11 +319,6 @@ void AITIP::MergeContextWithCache(PWSTR buf, AppContext *local_context) { // I
}

void AITIP::ReadContext() {
if(DebugControlled()) {
Debug_FillContextBuffer();
return;
}

WCHAR buf[MAXCONTEXT];
PKEYMAN64THREADDATA _td = ThreadGlobals();
if(!_td) return;
Expand Down Expand Up @@ -376,44 +355,7 @@ void AITIP::RestoreContextOnly(AppContext *savedContext) {

/* Output actions */

BOOL AITIP::QueueAction(int ItemType, DWORD dwData) {
if(DebugControlled()) {
switch(ItemType) {
case QIT_VKEYDOWN:
if((dwData & QVK_KEYMASK) <= VK__MAX && VKContextReset[(BYTE) dwData]) context->Reset(); // I3438 // I4370
break;

case QIT_DEADKEY:
context->Add(UC_SENTINEL); // I4370
context->Add(CODE_DEADKEY); // I4370
context->Add((WORD) dwData); // I4370
break;

case QIT_CHAR:
context->Add((WORD) dwData); // I4370
break;

case QIT_BACK:
if(dwData & BK_BACKSPACE)
while(context->CharIsDeadkey()) context->Delete(); // I4370
context->Delete(); // I4370
if(dwData & BK_BACKSPACE)
while(context->CharIsDeadkey()) context->Delete(); // I4370
break;
}

SendMessage(GetDebugControlWindow(), WM_KEYMANDEBUG_ACTION, ItemType, dwData);
return TRUE;
}

return AIWin2000Unicode::QueueAction(ItemType, dwData); // I3575
}

BOOL AITIP::SendActions() { // I4196
if(DebugControlled()) {
return TRUE;
}

PKEYMAN64THREADDATA _td = ThreadGlobals();
if(!_td) return FALSE;

Expand Down Expand Up @@ -504,89 +446,3 @@ DWORD TSFShiftToShift(LPARAM shift) // I3588
if(shift & TF_MOD_RCONTROL) res |= RCTRLFLAG;
return res;
}

/* Debug Integration */

BOOL AITIP::IsDebugControlWindow(HWND hwnd)
{
static int WM_KEYMANDEBUG_CANDEBUG = RegisterWindowMessage("WM_KEYMANDEBUG_CANDEBUG");
DWORD_PTR dwResult;
SendMessageTimeout(hwnd, WM_KEYMANDEBUG_CANDEBUG, 0, 0, SMTO_BLOCK, 50, &dwResult);
return dwResult != 0;
}

HWND AITIP::GetDebugControlWindow()
{
if(!FIsDebugControlWindow) return NULL;
return hwnd;
}

BOOL AITIP::DebugControlled()
{
return FIsDebugControlWindow;
}

void AITIP::Debug_FillContextBuffer()
{
WCHAR buf[MAXCONTEXT];
if(DebugControlled() &&
SendMessage(GetDebugControlWindow(), WM_KEYMANDEBUG_GETCONTEXT, MAXCONTEXT, (LPARAM) buf))
{
context->Set(buf); // I4370
SendDebugMessageFormat(0, sdmKeyboard, 0, "AIDebugger::FillContextBuffer(%ls)", buf);
}
else
{
context->Reset(); // I4370
SendDebugMessageFormat(0, sdmKeyboard, 0, "AIDebugger::FillContextBuffer()-Reset");
}
}

#define MAXSTOREOFFSETS 20

struct AIDEBUGINFO
{
int cbSize;
int ItemType;
PWSTR Context, Output;
LPKEY Rule;
LPGROUP Group;
DWORD_PTR Flags;
WORD StoreOffsets[MAXSTOREOFFSETS*2+1]; // pairs--store, char position, terminated by 0xFFFF
};

void FillStoreOffsets(AIDEBUGINFO *di)
{
int i, n;
PWSTR p;

PKEYMAN64THREADDATA _td = ThreadGlobals();
if(!_td) return;

for(i = n = 0, p = di->Rule->dpContext; *p; p = incxstr(p), i++)
{
if(*p == UC_SENTINEL && (*(p+1) == CODE_ANY || *(p+1) == CODE_NOTANY))
{
di->StoreOffsets[n++] = *(p+2) - 1;
di->StoreOffsets[n++] = _td->IndexStack[i];
}
if(*p == UC_SENTINEL && *(p+1) == CODE_INDEX)
{
di->StoreOffsets[n++] = *(p+2) - 1;
di->StoreOffsets[n++] = _td->IndexStack[*(p+3) - 1];
}
if(n == MAXSTOREOFFSETS*2) break;
}

if(n < MAXSTOREOFFSETS*2 - 1)
for(p = di->Rule->dpOutput; *p; p = incxstr(p))
{
if(*p == UC_SENTINEL && *(p+1) == CODE_INDEX)
{
di->StoreOffsets[n++] = *(p+2) - 1;
di->StoreOffsets[n++] = _td->IndexStack[*(p+3) - 1];
}
if(n == MAXSTOREOFFSETS*2) break;
}
di->StoreOffsets[n] = 0xFFFF;
}
25 changes: 0 additions & 25 deletions windows/src/engine/keyman32/appint/aiTIP.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,30 +35,11 @@
// This can be customised with HKLM\Software\Keyman\Keyman Engine\zap virtual key code
#define _VK_PREFIX_DEFAULT 0x0E

struct AIDEBUGKEYINFO
{
UINT VirtualKey;
DWORD shiftFlags;
WCHAR Character, DeadKeyCharacter;
BOOL IsUp;
};

class AITIP : public AIWin2000Unicode
{
private:
int WM_KEYMANDEBUG_CANDEBUG,
WM_KEYMANDEBUG_GETUNICODESTATUS,
WM_KEYMANDEBUG_GETCONTEXT,
WM_KEYMANDEBUG_ACTION,
WM_KEYMANDEBUG_RULEMATCH;

BOOL FIsDebugControlWindow;
HWND GetDebugControlWindow();
void Debug_FillContextBuffer();
void MergeContextWithCache(PWSTR buf, AppContext *context); // I4262

static BOOL IsDebugControlWindow(HWND hwnd);

private:
BOOL useLegacy;

Expand All @@ -69,8 +50,6 @@ class AITIP : public AIWin2000Unicode
AITIP();
~AITIP();

BOOL DebugControlled();

/**
* Copy the member context
*
Expand All @@ -85,13 +64,9 @@ class AITIP : public AIWin2000Unicode
*/
void RestoreContextOnly(AppContext *savedContext);

virtual BOOL QueueAction(int ItemType, DWORD dwData);

/* Information functions */

virtual BOOL CanHandleWindow(HWND ahwnd);
virtual BOOL IsWindowHandled(HWND ahwnd);
virtual BOOL HandleWindow(HWND ahwnd);
virtual BOOL IsUnicode();

/* Context functions */
Expand Down
2 changes: 0 additions & 2 deletions windows/src/engine/keyman32/globals.h
Original file line number Diff line number Diff line change
Expand Up @@ -263,12 +263,10 @@ typedef struct tagKEYMAN64THREADDATA

extern UINT
wm_keyman, // user message - ignore msg
wm_kmdebug, // " " " " - debugging
wm_keyman_control, // messages to main Keyman window - replaces WM_USER+*
wm_keyman_control_internal, // messages to all windows to notify of changes to Keyman // I4412
wm_keymankeydown,
wm_keymankeyup,
wm_keymandebug,
wm_keyman_grabwindowproc,
wm_keyman_refresh,
wm_kmgetactivekeymanid,
Expand Down
1 change: 0 additions & 1 deletion windows/src/engine/keyman32/k32_globals.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@
UINT
//TODO: consolidate these messages -- they are probably not all required now
wm_keyman = 0, // user message - ignore msg // I3594
wm_kmdebug = 0, // " " " " - debugging

wm_keymankeydown = 0,
wm_keymankeyup = 0,
Expand Down
5 changes: 0 additions & 5 deletions windows/src/engine/keyman32/kmhook_getmessage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -266,11 +266,6 @@ LRESULT _kmnGetMessageProc(int nCode, WPARAM wParam, LPARAM lParam)
SendDebugMessageFormat(0, sdmInternat, 0, "GetMessage: wm_keymanshift %x %x", mp->wParam, mp->lParam);
SelectApplicationIntegration();
if(!_td->app->IsWindowHandled(mp->hwnd)) _td->app->HandleWindow(mp->hwnd);
if(_td->app->DebugControlled())
{
if(mp->wParam == 1) *Globals::ShiftState() = (DWORD) mp->lParam;
else *Globals::ShiftState() = 0;
}
return CallNextHookEx(Globals::get_hhookGetMessage(), nCode, wParam, lParam);
}

Expand Down
20 changes: 0 additions & 20 deletions windows/src/engine/keyman32/kmprocess.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,16 +138,7 @@ BOOL ProcessHook()
if(!_td) return FALSE;

fOutputKeystroke = FALSE; // TODO: 5442 no longer needs to be global once we use core processor
//
// If we are running in the debugger, don't do a second run through
//

if(_td->app->DebugControlled() && !_td->TIPFUpdateable) { // I4287
if(_td->state.vkey == VK_ESCAPE || (_td->state.vkey >= VK_PRIOR && _td->state.vkey <= VK_DOWN) || (_td->state.vkey == VK_DELETE)) return FALSE; // I4033 // I4826 // I4845
else return TRUE;
}

//app->NoSetShift = FALSE;
_td->app->ReadContext();

if(_td->state.msg.message == wm_keymankeydown) { // I4827
Expand Down Expand Up @@ -216,17 +207,6 @@ BOOL ProcessHook()
}
}

if (fOutputKeystroke && _td->app->DebugControlled()) {
// The debug memo does not receive default key events because
// we capture them all here. So we synthesize the key event for
// the debugger.
_td->app->QueueAction(QIT_VSHIFTDOWN, Globals::get_ShiftState());
_td->app->QueueAction(QIT_VKEYDOWN, _td->state.vkey);
_td->app->QueueAction(QIT_VKEYUP, _td->state.vkey);
_td->app->QueueAction(QIT_VSHIFTUP, Globals::get_ShiftState());
fOutputKeystroke = FALSE;
}

if(*Globals::hwndIM() == 0 || *Globals::hwndIMAlways())
{
_td->app->SetCurrentShiftState(Globals::get_ShiftState());
Expand Down