Skip to content

Commit

Permalink
Merge branch 'fix/core/10582-km_core_state_get_actions-idempotency' i…
Browse files Browse the repository at this point in the history
…nto fix/core/10605-app-context-copy-strip-markers
  • Loading branch information
mcdurdin authored Feb 5, 2024
2 parents 49eb6f4 + e69bfe7 commit 5f4aeb6
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 34 deletions.
2 changes: 0 additions & 2 deletions windows/src/engine/keyman32/globals.h
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,6 @@ typedef struct tagKEYMAN64THREADDATA
BOOL TIPFUpdateable, TIPFPreserved; // I4290

BOOL CoreProcessEventRun; // True if core process event has been run
// TODO: #10583 remove core_actions cache
km_core_actions const *core_actions;

BOOL FInRefreshKeyboards;
BOOL RefreshRequired;
Expand Down
47 changes: 15 additions & 32 deletions windows/src/engine/keyman32/kmprocessactions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,31 +103,23 @@ BOOL ProcessActions(BOOL* emitKeyStroke)
{
PKEYMAN64THREADDATA _td = ThreadGlobals();
if (!_td) return FALSE;
// TODO: #10583 Remove caching action_struct
if (!_td->core_actions) {
SendDebugMessageFormat(0, sdmGlobal, 0, "ProcessActions: core_actions not set");
_td->core_actions = km_core_state_get_actions(_td->lpActiveKeyboard->lpCoreKeyboardState);
}

_td->CoreProcessEventRun = FALSE;

km_core_actions const* core_actions = km_core_state_get_actions(_td->lpActiveKeyboard->lpCoreKeyboardState);

_td->CoreProcessEventRun = FALSE;

processBack(_td->app, _td->core_actions->code_points_to_delete, _td->core_actions->deleted_context);
processUnicodeChar(_td->app, _td->core_actions->output);
if (_td->core_actions->persist_options != NULL) {
processPersistOpt(_td->core_actions, _td->lpActiveKeyboard);
processBack(_td->app, core_actions->code_points_to_delete, core_actions->deleted_context);
processUnicodeChar(_td->app, core_actions->output);
if (core_actions->persist_options != NULL) {
processPersistOpt(core_actions, _td->lpActiveKeyboard);
}
if (_td->core_actions->do_alert) {
if (core_actions->do_alert) {
processAlert(_td->app);
}
if (_td->core_actions->emit_keystroke) {
if (core_actions->emit_keystroke) {
*emitKeyStroke = TRUE;
}
processCapsLock(_td->core_actions->new_caps_lock_state, !_td->state.isDown, _td->TIPFUpdateable, FALSE);
// TODO: #10583 remove dispose
km_core_actions_dispose(_td->core_actions);
_td->core_actions = nullptr;
processCapsLock(core_actions->new_caps_lock_state, !_td->state.isDown, _td->TIPFUpdateable, FALSE);

return TRUE;
}
Expand All @@ -143,16 +135,11 @@ ProcessActionsNonUpdatableParse(BOOL* emitKeyStroke) {
return FALSE;
}
_td->CoreProcessEventRun = TRUE;
// TODO: #10583 remove dispose
if (_td->core_actions) {
km_core_actions_dispose(_td->core_actions);
_td->core_actions = nullptr;
}

_td->core_actions = km_core_state_get_actions(_td->lpActiveKeyboard->lpCoreKeyboardState);
SendDebugMessageFormat(0, sdmGlobal, 0, "ProcessActionsNonUpdatableParse: km_core_state_get_actions");
processCapsLock(_td->core_actions->new_caps_lock_state, !_td->state.isDown, _td->TIPFUpdateable, FALSE);
if (_td->core_actions->emit_keystroke) {
km_core_actions const* core_actions = km_core_state_get_actions(_td->lpActiveKeyboard->lpCoreKeyboardState);

processCapsLock(core_actions->new_caps_lock_state, !_td->state.isDown, _td->TIPFUpdateable, FALSE);
if (core_actions->emit_keystroke) {
*emitKeyStroke = TRUE;
SendDebugMessageFormat(0, sdmGlobal, 0, "ProcessActionsNonUpdatableParse EMIT_KEYSTROKE");
_td->CoreProcessEventRun = FALSE; // If we emit the key stroke on this parse we don't need the second parse
Expand All @@ -166,11 +153,7 @@ ProcessActionsExternalEvent() {
if (!_td) {
return FALSE;
}
if (!_td->core_actions) { // when ideponent we will not need this
return FALSE;
}
// TODO: #10583 remove and call get actions here directly
//km_core_actions const* acts = km_core_state_get_actions(_td->lpActiveKeyboard->lpCoreKeyboardState);
processCapsLock(_td->core_actions->new_caps_lock_state, !_td->state.isDown, FALSE, TRUE);
km_core_actions const* core_actions = km_core_state_get_actions(_td->lpActiveKeyboard->lpCoreKeyboardState);
processCapsLock(core_actions->new_caps_lock_state, !_td->state.isDown, FALSE, TRUE);
return TRUE;
}

0 comments on commit 5f4aeb6

Please sign in to comment.