From ee1f972b134cecf5f07af282add5483778465f78 Mon Sep 17 00:00:00 2001 From: Marc Durdin Date: Thu, 23 Nov 2023 10:49:58 +1000 Subject: [PATCH] chore(windows): remove wm_keymandebug messages and functions Fixes #10050. Removes the following unused identifiers: * ::wm_kmdebug * ::wm_keymandebug * AppInt::DebugControlled() * AITIP::WM_KEYMANDEBUG_CANDEBUG * AITIP::WM_KEYMANDEBUG_GETUNICODESTATUS * AITIP::WM_KEYMANDEBUG_GETCONTEXT * AITIP::WM_KEYMANDEBUG_ACTION * AITIP::WM_KEYMANDEBUG_RULEMATCH * AITIP::DebugControlled() * AITIP::IsDebugControlWindow() * AITIP::GetDebugControlWindow() * AITIP::Debug_FillContextBuffer() * AIDEBUGINFO struct * ::FillStoreOffsets() * AIDEBUGKEYINFO struct Removes overloads which are now no-ops: * AITIP::HandleWindow() * AITIP::IsWindowHandled() * AITIP::QueueAction() --- windows/src/engine/keyman32/appint/aiTIP.cpp | 144 ------------------ windows/src/engine/keyman32/appint/aiTIP.h | 25 --- windows/src/engine/keyman32/globals.h | 2 - windows/src/engine/keyman32/k32_globals.cpp | 1 - .../src/engine/keyman32/kmhook_getmessage.cpp | 5 - windows/src/engine/keyman32/kmprocess.cpp | 20 --- 6 files changed, 197 deletions(-) diff --git a/windows/src/engine/keyman32/appint/aiTIP.cpp b/windows/src/engine/keyman32/appint/aiTIP.cpp index b6f591845b5..a7faa7170fe 100644 --- a/windows/src/engine/keyman32/appint/aiTIP.cpp +++ b/windows/src/engine/keyman32/appint/aiTIP.cpp @@ -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() { @@ -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; } @@ -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; @@ -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; @@ -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; -} diff --git a/windows/src/engine/keyman32/appint/aiTIP.h b/windows/src/engine/keyman32/appint/aiTIP.h index 3c6fd9b6980..93c9acd4ab5 100644 --- a/windows/src/engine/keyman32/appint/aiTIP.h +++ b/windows/src/engine/keyman32/appint/aiTIP.h @@ -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; @@ -69,8 +50,6 @@ class AITIP : public AIWin2000Unicode AITIP(); ~AITIP(); - BOOL DebugControlled(); - /** * Copy the member context * @@ -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 */ diff --git a/windows/src/engine/keyman32/globals.h b/windows/src/engine/keyman32/globals.h index 320ef811de4..22a0e437e97 100644 --- a/windows/src/engine/keyman32/globals.h +++ b/windows/src/engine/keyman32/globals.h @@ -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, diff --git a/windows/src/engine/keyman32/k32_globals.cpp b/windows/src/engine/keyman32/k32_globals.cpp index 989a787f959..bc500e763d1 100644 --- a/windows/src/engine/keyman32/k32_globals.cpp +++ b/windows/src/engine/keyman32/k32_globals.cpp @@ -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, diff --git a/windows/src/engine/keyman32/kmhook_getmessage.cpp b/windows/src/engine/keyman32/kmhook_getmessage.cpp index e129a0b8da3..d4d1177ced3 100644 --- a/windows/src/engine/keyman32/kmhook_getmessage.cpp +++ b/windows/src/engine/keyman32/kmhook_getmessage.cpp @@ -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); } diff --git a/windows/src/engine/keyman32/kmprocess.cpp b/windows/src/engine/keyman32/kmprocess.cpp index 5772836de2a..7e5e8070567 100644 --- a/windows/src/engine/keyman32/kmprocess.cpp +++ b/windows/src/engine/keyman32/kmprocess.cpp @@ -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 @@ -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());