From 613f5c72efbf02d63d8921b35e5296c33eaa9fb8 Mon Sep 17 00:00:00 2001 From: Ross Date: Wed, 17 Aug 2022 11:39:16 +1000 Subject: [PATCH] fix: remove saving and restoring context kbd options Remove the saving of context and keyboard options on the non updateable call to process hook. The windows Text Input Processor calls twice one call is not updateable. With the core integeration we run the processor only once, preserving the actions and context to be applied on the updatable call. --- windows/src/engine/keyman32/appint/aiTIP.cpp | 26 ++++++-------------- 1 file changed, 7 insertions(+), 19 deletions(-) diff --git a/windows/src/engine/keyman32/appint/aiTIP.cpp b/windows/src/engine/keyman32/appint/aiTIP.cpp index 9043c9ece1..23240b2a06 100644 --- a/windows/src/engine/keyman32/appint/aiTIP.cpp +++ b/windows/src/engine/keyman32/appint/aiTIP.cpp @@ -258,15 +258,12 @@ extern "C" __declspec(dllexport) BOOL WINAPI TIPProcessKey(WPARAM wParam, LPARAM _td->TIPGetContext = ctfunc; AppContextWithStores *savedContext = NULL; // I4370 // I4978 - AppContext *savedContextUsingCore = NULL; // used for common core - km_kbp_option_item *SavedKBDOptions = NULL; // used for common core + if (!Updateable) { - if (isUsingCoreProcessor) { - savedContextUsingCore = new AppContext(); - _td->app->CopyContext(savedContextUsingCore); - SavedKBDOptions = SaveKeyboardOptionsCore(_td->lpActiveKeyboard); - } else { // I4370 - savedContext = new AppContextWithStores(_td->lpActiveKeyboard->Keyboard->cxStoreArray); // I4978 + // The core processor km_kbp_process_event is only called once per key stroke + // therefore there is no need to preserve context and keyboard actions + if (!isUsingCoreProcessor) { + savedContext = new AppContextWithStores(_td->lpActiveKeyboard->Keyboard->cxStoreArray); // I4370 // I4978 _td->app->SaveContext(savedContext); } } @@ -274,17 +271,8 @@ extern "C" __declspec(dllexport) BOOL WINAPI TIPProcessKey(WPARAM wParam, LPARAM BOOL res = ProcessHook(); if (!Updateable) { - if (isUsingCoreProcessor) { - if (res) { - // Reset the context if match found - _td->app->RestoreContextOnly(savedContextUsingCore); - RestoreKeyboardOptionsCore(_td->lpActiveKeyboard->lpCoreKeyboardState, SavedKBDOptions); - DisposeKeyboardOptionsCore(&SavedKBDOptions); - delete savedContextUsingCore; - savedContextUsingCore = NULL; - } - } else { // I4370 - if (res) { // I4585 + if (!isUsingCoreProcessor) { + if (res) { // I4585 // I4370 // Reset the context if match found _td->app->RestoreContext(savedContext); delete savedContext;