fix(linux): Fix lost context after pressing K_SHIFT

This fixes typing `n>` with sil_ipa keyboard which no longer output
the expected `ŋ` because pressing the shift key reset the context.

For modifier key presses we now exit `KMX_ProcessEvent::ProcessEvent`
early.

This change also removes a redundant line from engine.c. Clearing
the context happens in `reset_context()` again if necessary.

Fixes #5591.
This commit is contained in:
Eberhard Beilharz 2021-08-18 19:26:45 +02:00
parent 2937c0c5b6
commit f0c3280517
No known key found for this signature in database
GPG key ID: 64A39A9E98B53105
6 changed files with 20 additions and 11 deletions

View file

@ -119,7 +119,10 @@ KMX_BOOL KMX_ProcessEvent::ProcessEvent(
break;
case KM_KBP_VKEY_SHIFT:
KeyShiftPress(modifiers, isKeyDown);
break;
return TRUE;
case KM_KBP_VKEY_CONTROL:
case KM_KBP_VKEY_ALT:
return TRUE;
}
if (!isKeyDown) {
@ -293,7 +296,6 @@ KMX_BOOL KMX_ProcessEvent::ProcessGroup(LPGROUP gp, KMX_BOOL *pOutputKeystroke)
m_actions.QueueAction(QIT_BACK, BK_DEADKEY); // side effect: also removes last char from context
pdeletecontext = m_context.Buf(1);
}
} else { // I4024 // I4128 // I4287 // I4290
DebugLog(" ... IsLegacy = FALSE; IsTIP = TRUE"); // I4128
m_actions.QueueAction(QIT_INVALIDATECONTEXT, 0);
@ -313,7 +315,7 @@ KMX_BOOL KMX_ProcessEvent::ProcessGroup(LPGROUP gp, KMX_BOOL *pOutputKeystroke)
PostString(gp->dpNoMatch, m_keyboard.Keyboard, NULL, pOutputKeystroke);
if(m_debug_items) {
m_debug_items->push_nomatch_exit(m_actions.Length(), gp);
}
}
}
else if (m_state.charCode != 0 && m_state.charCode != 0xFFFF && gp->fUsingKeys)
{

View file

@ -1,14 +1,14 @@
c Description: Tests a simple deadkey rule in Unicode
c keys: [SHIFT K_6][K_A]
c expected: \u00E2
c context:
c keys: [SHIFT K_6][K_A][SHIFT K_6][K_SHIFT][K_A][SHIFT K_6][RALT K_B][K_A][SHIFT K_6][K_CAPS][K_A]
c expected: pass.pass.pass.pass.
c context:
store(&VERSION) '9.0'
begin unicode > use(main)
group(main) using keys
group(main) using keys
+ '^' > deadkey(1)
dk(1) + 'a' > U+00E2
dk(1) + [K_A] > 'pass.'

View file

@ -1,6 +1,6 @@
c Description: Tests Caps Lock
c keys: [K_1][SHIFT K_2][SHIFT K_3][K_A][SHIFT K_B]
c expected: pass.pass.pass.pass.pass.
c keys: [K_1][SHIFT K_2][SHIFT K_3][K_A][SHIFT K_B][K_C][K_CAPS][K_D]
c expected: pass.pass.pass.pass.pass.pass.pass.
c capsLock: 1
c context:
@ -24,3 +24,11 @@ group(Main) using keys
+ 'b' > 'pass.'
+ 'B' > 'fail.'
c Caps is on. The virtual key should match.
+ [SHIFT K_C] > 'fail.'
+ [K_C] > 'pass.'
c Caps was pressed and released, so Caps is now off. The virtual key should still match.
+ [SHIFT K_D] > 'fail.'
+ [K_D] > 'pass.'

View file

@ -754,7 +754,6 @@ static gboolean process_emit_keystroke_action(IBusKeymanEngine *keyman) {
static gboolean process_invalidate_context_action(IBusEngine *engine) {
IBusKeymanEngine *keyman = (IBusKeymanEngine *)engine;
km_kbp_context_clear(km_kbp_state_context(keyman->state));
reset_context(engine);
return TRUE;
}