diff --git a/clients/keyboard.c b/clients/keyboard.c index f1035c223..91a3e176a 100644 --- a/clients/keyboard.c +++ b/clients/keyboard.c @@ -276,6 +276,7 @@ struct keyboard { enum keyboard_state state; uint32_t key_state[max_count]; + int32_t key_touch_event_id[max_count]; uint32_t key_margin; uint32_t key_radius; @@ -805,7 +806,7 @@ button_handler(struct widget *widget, } static void -touch_handler(struct input *input, uint32_t time, +touch_handler(struct input *input, uint32_t time, int32_t id, float x, float y, uint32_t state, void *data) { struct keyboard *keyboard = data; @@ -826,6 +827,7 @@ touch_handler(struct input *input, uint32_t time, for (i = 0; i < layout->count; ++i) { col -= layout->keys[i].width; if (col < 0) { + keyboard->key_touch_event_id[i] = id; keyboard_handle_key(keyboard, time, &layout->keys[i], i, input, state); break; @@ -840,7 +842,7 @@ touch_down_handler(struct widget *widget, struct input *input, uint32_t serial, uint32_t time, int32_t id, float x, float y, void *data) { - touch_handler(input, time, x, y, + touch_handler(input, time, id, x, y, WL_POINTER_BUTTON_STATE_PRESSED, data); } @@ -849,11 +851,21 @@ touch_up_handler(struct widget *widget, struct input *input, uint32_t serial, uint32_t time, int32_t id, void *data) { - float x, y; + struct keyboard *keyboard = data; - input_get_touch(input, id, &x, &y); + for (size_t i = 0; i < max_count; ++i) + { + if (id == keyboard->key_touch_event_id[i]) + { + keyboard->key_touch_event_id[i] = -1; + keyboard->key_state[i] = WL_KEYBOARD_KEY_STATE_RELEASED; + } + } - touch_handler(input, time, x, y, + float x, y; + input_get_touch(input, id, &x, &y); + + touch_handler(input, time, id, x, y, WL_POINTER_BUTTON_STATE_RELEASED, data); }