-
-
Notifications
You must be signed in to change notification settings - Fork 111
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
fix(core): reset on frame keys 🙀 #11172
Changes from 14 commits
c86ab58
c91095f
2298f11
f1b0d8c
628d13d
784a994
55483e4
a455c5b
11b0712
111a50c
51c93ac
3da900d
9ca4e99
d0ca92a
46239c6
bd10290
699d576
4f8c9eb
37530ac
5c04599
4f2ef49
8d35422
f77bbb2
331ff33
ba8dcad
f516538
cd867ba
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,7 +20,8 @@ | |
|
||
#include "processor.hpp" | ||
#include "state.hpp" | ||
|
||
#include "vkey_to_contextreset.hpp" | ||
#include "kmx_file.h" | ||
|
||
using namespace km::core; | ||
|
||
|
@@ -363,4 +364,32 @@ km_core_cp * km_core_state_context_debug( | |
result[s.size()] = 0; | ||
|
||
return result; | ||
} | ||
} | ||
|
||
static bool | ||
state_has_action_type(km_core_state *state, uint8_t type) { | ||
return std::any_of( | ||
state->actions().begin(), state->actions().end(), | ||
[type](const km::core::action &a) { return a.type == type; }); | ||
} | ||
|
||
bool | ||
state_should_invalidate_context(km_core_state *state, | ||
km_core_virtual_key vk, | ||
uint16_t modifier_state, | ||
uint8_t is_key_down, | ||
uint16_t _kmn_unused(event_flags)) { | ||
// if emit_keystroke is present, check if a context reset is needed | ||
if (state_has_action_type(state, KM_CORE_IT_EMIT_KEYSTROKE)) { | ||
if (vk == KM_CORE_VKEY_BKSP && state->context().empty()) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this test going to be before or after the context has been manipulated by the rule processor? That is, if we have a single char in context, then user presses backspace, could this result in a context reset when we don't want it? (Yes it may not cause trouble but I want us to be clear on our boundaries and order of execution) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. after There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. that suggests that bksp for the first character will delete that character and also pass it back to the app for a second deletion? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, that is correct, we can't rely on the state->context().empty(). I originally thought we could use
To inside
This puts the decision back on the processors though. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @srl295 I think we can keep the change suggest in option 1 for the future when the action list is deprecated. |
||
return true; // context is empty - so pass back | ||
} else if (is_key_down && | ||
// either a ctrl or alt modifier | ||
((modifier_state & (K_CTRLFLAG | K_ALTFLAG | LCTRLFLAG | RCTRLFLAG | LALTFLAG | RALTFLAG)) | ||
// or a frame key | ||
srl295 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|| vkey_to_contextreset[vk])) { | ||
return true; | ||
} | ||
} | ||
return false; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It'd be good to add some explanation of why we are doing this -- why do we need to add the invalidate context before emit keystroke, etc.