Abort hook functions on any result other than `OK`

Instead of only aborting hook functions if a handler returns `EVENT_CONSUMED`,
only continue abortable hooks if a handler returns `OK`. For existing core
plugins, this shouldn't make any difference because none of them use the `ERROR`
return value.

Also rename `shouldAbortOnConsumedEvent` to better match the new conditional.

Signed-off-by: Michael Richters <gedankenexperimenter@gmail.com>
f/keymap-cache-redesign
Michael Richters 4 years ago committed by Jesse Vincent
parent c9d6a04335
commit 62d0ec70ea
No known key found for this signature in database
GPG Key ID: 122F5DF7108E4046

@ -80,7 +80,7 @@
#define _REGISTER_EVENT_HANDLER( \ #define _REGISTER_EVENT_HANDLER( \
HOOK_NAME, HOOK_VERSION, DEPRECATION_TAG, \ HOOK_NAME, HOOK_VERSION, DEPRECATION_TAG, \
SHOULD_ABORT_ON_CONSUMED_EVENT, \ SHOULD_EXIT_IF_RESULT_NOT_OK, \
TMPL_PARAM_TYPE_LIST, TMPL_PARAM_LIST, TMPL_DUMMY_ARGS_LIST, \ TMPL_PARAM_TYPE_LIST, TMPL_PARAM_LIST, TMPL_DUMMY_ARGS_LIST, \
SIGNATURE, ARGS_LIST) __NL__ \ SIGNATURE, ARGS_LIST) __NL__ \
__NL__ \ __NL__ \
@ -116,8 +116,8 @@
MAKE_TEMPLATE_SIGNATURE(UNWRAP TMPL_PARAM_TYPE_LIST) __NL__ \ MAKE_TEMPLATE_SIGNATURE(UNWRAP TMPL_PARAM_TYPE_LIST) __NL__ \
struct _NAME4(EventHandler_, HOOK_NAME, _v, HOOK_VERSION) { __NL__ \ struct _NAME4(EventHandler_, HOOK_NAME, _v, HOOK_VERSION) { __NL__ \
__NL__ \ __NL__ \
static bool shouldAbortOnConsumedEvent() { __NL__ \ static bool shouldExitIfResultNotOk() { __NL__ \
return SHOULD_ABORT_ON_CONSUMED_EVENT; __NL__ \ return SHOULD_EXIT_IF_RESULT_NOT_OK; __NL__ \
} __NL__ \ } __NL__ \
__NL__ \ __NL__ \
template<typename Plugin__, __NL__ \ template<typename Plugin__, __NL__ \
@ -166,8 +166,8 @@
__NL__ \ __NL__ \
result = EventHandler__::call(PLUGIN, hook_args...); __NL__ \ result = EventHandler__::call(PLUGIN, hook_args...); __NL__ \
__NL__ \ __NL__ \
if (EventHandler__::shouldAbortOnConsumedEvent() && __NL__ \ if (EventHandler__::shouldExitIfResultNotOk() && __NL__ \
result == kaleidoscope::EventHandlerResult::EVENT_CONSUMED) { __NL__ \ result != kaleidoscope::EventHandlerResult::OK) { __NL__ \
return result; __NL__ \ return result; __NL__ \
} __NL__ } __NL__

Loading…
Cancel
Save