seat: only pass on sent keys on surface-focus

Key events associated with keybindings (both pressed and released) are not
sent to clients. When using wlr_seat_keyboard_notify_enter() it it
therefore important not to send the keycodes of _all_ pressed keys, but
only those that were actually _sent_ to clients (that is, those that were
not bound).

This approach is consistent with sway's implementation in input/seat.c
cffb006feb/sway/input/seat.c (L173-L175)

Fixes issue #510
This commit is contained in:
Johan Malm 2022-09-20 20:46:39 +01:00
parent 4108313f96
commit de99a8ba33
4 changed files with 53 additions and 7 deletions

View file

@ -10,7 +10,7 @@ struct key_array {
int nr_keys;
};
static struct key_array pressed, bound;
static struct key_array pressed, bound, pressed_sent;
static void
remove_key(struct key_array *array, uint32_t keycode)
@ -35,6 +35,25 @@ add_key(struct key_array *array, uint32_t keycode)
array->keys[array->nr_keys++] = keycode;
}
uint32_t *
key_state_pressed_sent_keycodes(void)
{
/* pressed_sent = pressed - bound */
memcpy(pressed_sent.keys, pressed.keys,
MAX_PRESSED_KEYS * sizeof(uint32_t));
pressed_sent.nr_keys = pressed.nr_keys;
for (int i = 0; i < bound.nr_keys; ++i) {
remove_key(&pressed_sent, bound.keys[i]);
}
return pressed_sent.keys;
}
int
key_state_nr_pressed_sent_keycodes(void)
{
return pressed_sent.nr_keys;
}
void
key_state_set_pressed(uint32_t keycode, bool ispressed)
{