fix(core): fix keydown/up handling for LDML keyboards #️⃣#15609
fix(core): fix keydown/up handling for LDML keyboards #️⃣#15609ermshiperete wants to merge 3 commits intorefactor/core/cleanupfrom
Conversation
User Test ResultsTest specification and instructions ✅ SUITE_BASICTEST:4 tests in 2 groups PASSED
🟥 SUITE_BUGSFIXED:Retesting TemplateTest Artifacts
|
f67f988 to
c0b6426
Compare
|
|
||
| if (!ldml_state.is_key_down()) { | ||
| if (!ldml_state.get_state()->backspace_handled_internally()) { | ||
| ldml_state.emit_passthrough_keystroke(); |
There was a problem hiding this comment.
I was trying to imagine if there was a scenario where we got a key-up for a Backspace without first getting a key-down. This would be considered bad input anyway. Passing the backspace to the app would probably be acceptable.
There was a problem hiding this comment.
I'm not sure I understand why this is needed only for LDML and not for KMN keyboards.
There was a problem hiding this comment.
We will need it for KMN keyboards as well. However, I didn't get to that yet. I thought I'd fix LDML keyboards first in this PR since we get crashes with LDML, and then in the next PR tackle KMN keyboards.
Test ResultsSUITE_BASICTEST:Test Specs
GROUP_X11: Test with Gnome Shell and X11
GROUP_WAYLAND: Test with Gnome Shell and WaylandTest Prerequisites
SUITE_BUGSFIXED:Test Specs
|
mcdurdin
left a comment
There was a problem hiding this comment.
I will need to continue review on this next week but had some questions to start with.
|
|
||
| if (!ldml_state.is_key_down()) { | ||
| if (!ldml_state.get_state()->backspace_handled_internally()) { | ||
| ldml_state.emit_passthrough_keystroke(); |
There was a problem hiding this comment.
I'm not sure I understand why this is needed only for LDML and not for KMN keyboards.
| // Look up the key | ||
| bool found = false; | ||
| const std::u16string key_str = keys.lookup(ldml_state.get_vk(), ldml_state.get_modifier_state(), found); | ||
|
|
||
| if (!found) { | ||
| ldml_state.emit_passthrough_keystroke(); | ||
| } |
There was a problem hiding this comment.
Does this match the logic in key_down?
There was a problem hiding this comment.
yes, that part is exactly the same.
core/src/ldml/ldml_processor.cpp
Outdated
| this->vk = v; | ||
| this->modifier_state = m; | ||
| this->is_key_down = i; | ||
| this->event_flags = e; | ||
| this->_vk = v; | ||
| this->_modifier_state = m; | ||
| this->_is_key_down = i; | ||
| this->_event_flags = e; |
There was a problem hiding this comment.
renaming like this should be in a separate refactor PR please -- it makes it harder to follow the logical changes here and introduces complexity for patching into other versions
There was a problem hiding this comment.
You're right, sorry. Do you want me to still split this PR?
There was a problem hiding this comment.
Yes please can you split the refactor/rename into a separate PR?
There was a problem hiding this comment.
Sorry, doing that required a force-push for this PR.
| this->keyboard = nullptr; | ||
| } | ||
| } | ||
| } |
There was a problem hiding this comment.
better to keep whitespace-only changes out of a change like this. OK if the whitespace is in an affected area but otherwise it doesn't belong and unnecessarily expands the scope of patches.
core/tests/unit/kmx/meson.build
Outdated
| input: kbd_src, | ||
| command: kmc_cmd + ['build', '--debug', '--no-compiler-version', '@INPUT@', '--out-file', kbd_obj] | ||
| ) | ||
| test('imx_list', imx_e, depends: kbd_log, args: [kbd_obj] ) |
There was a problem hiding this comment.
ditto on whitespace in this file
core/src/state.hpp
Outdated
| // This is used to track whether the backspace key was handled internally | ||
| // during the keydown event. This is needed so that we can return the same | ||
| // value from the keyup event. Only used when processing KM_CORE_VKEY_BKSP. |
There was a problem hiding this comment.
This should be a javadoc style comment. I still don't really understand why it needs to be handled separately in Core.
There was a problem hiding this comment.
Backspace is the only key that we sometimes handle internally (if we have enough context) and sometimes not. By the time we get the keyup event the context already got updated and so we have no way of knowing whether or not the keydown handled it internally. Therefore this flag.
Note that things do work without knowing because for backspace we always returned the right value for emit_keystroke, but it will cause the emit_keystroke values for keydown and keyup to be out of sync.
There was a problem hiding this comment.
Gotcha thanks! Perhaps we can capture some of that detail in the comment?
Comments addressed. Do you still want me to split out the whitespace and refactoring changes to a separate PR?
For LDML keyboards this change fixes the `emit_key` flag so that it has the same value for the KeyDown and the KeyUp event. This fixes some problems with stuck keys. Previously we would set `emit_key=TRUE` on KeyDown but `emit_key=FALSE` on KeyUp for frame keys. This caused Linux to never see the KeyUp event, resulting in a stuck key. Also add unit tests that verifies that the actions that we get after calling `km_core_process_event` are what we expect. Fixes: #15569 Fixes: #15550
Co-authored-by: Marc Durdin <marc@durdin.net>
7ec8297 to
9836070
Compare
For LDML keyboards this change fixes the
emit_keystrokeflag so that it always has the same value for the KeyDown and the KeyUp event. This fixes some problems with stuck keys. Previously we would setemit_keystroke=TRUEon KeyDown butemit_keystroke=FALSEon KeyUp for frame keys. This caused Linux to never see the KeyUp event, resulting in a stuck key.Also add unit tests that verifies that the actions that we get after calling
km_core_process_eventare what we expect.Follows: #15656
Fixes: #15569
Fixes: #15550
User Testing
Test on Linux
SUITE_BASICTEST
GROUP_X11 Test with Gnome Shell and X11
GROUP_WAYLAND Test with Gnome Shell and Wayland
TEST_ONEKEY_COMPLIANT:
Install ldmlonekey.kmp.zip keyboard (rename to
ldmlonekey.kmp). This defines a keyboard where only 1 will output anything.Open the text editor or gedit and type different keys with and without Shift, Control, and Alt/RAlt. Only the 1 key (without any modifier) should produce an output, all other (regular) keys shouldn't output anything. Enter should output a new line, and Backspace should work as well. The usual shortcut keys with Ctrl should also work: Ctrl-C copy, Ctrl-V paste, Ctrl-Backspace delete word, Ctrl-a select all text.
TEST_ONEKEY_NONCOMPLIANT: Try the same in Chromium, e.g. in the textbox of https://keymanweb.com/.
SUITE_BUGSFIXED
TEST_15569: verify that bug(linux): 'stuck' Enter key with ldml keyboards on Wayland #15569 is fixed
TEST_15550: verify that bug(linux): ldml keyboard desynchronizes and can crash when bksp is used in non-compliant app with decomposed cluster on Wayland #15550 is fixed
TEST_ADHOC: using the Khmer (or some other) LDML keyboard, verify that typing works as expected using Wayland.