uterm: uxkb: fix correctly resetting input state

We currently have a very subtle bug when modifiers are pressed while
leaving a terminal but released while entering. The internal state will
not be updated and as xkbcommon does not fix this up, we need to recreate
the state when re-entering the terminal.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
This commit is contained in:
David Herrmann 2012-08-14 22:47:34 +02:00
parent b697fcd43c
commit 5aade75f3d

View File

@ -153,7 +153,20 @@ static void uxkb_dev_reset(struct kbd_dev *kbd, const unsigned long *ledbits)
if (!kbd)
return;
state = kbd->uxkb.state;
/* TODO: Urghs, while the input device was closed we might have missed
* some events that affect internal state. As xkbcommon does not provide
* a way to reset the internal state, we simply recreate the state. This
* should have the same effect.
* It also has a bug that if the CTRL-Release event is skipped, then
* every further release will never perform a _real_ release. Kind of
* buggy so we should fix it upstream. */
state = xkb_state_new(kbd->desc->uxkb.keymap);
if (!state) {
log_warning("cannot recreate xkb-state");
return;
}
xkb_state_unref(kbd->uxkb.state);
kbd->uxkb.state = state;
for (i = 0; i < sizeof(led_names) / sizeof(*led_names); i++) {
if (!input_bit_is_set(ledbits, led_names[i].led))
@ -166,8 +179,6 @@ static void uxkb_dev_reset(struct kbd_dev *kbd, const unsigned long *ledbits)
* xkb_state_led_name_set_active(state, led_names[i].led);
*/
}
(void)state;
}
static int uxkb_desc_init(struct kbd_desc **out,