From a4f64d6fcb3de6ff650e9a09b09c69edbb862146 Mon Sep 17 00:00:00 2001 From: Derek Foreman Date: Thu, 9 Jun 2016 12:43:50 -0500 Subject: [PATCH] ecore_wl2: Fix keyboard repeat handling Recent timer changes broke keyboard repeat under wayland - while that will probably be fixed shortly, this should be more robust and more accurate anyway. --- src/lib/ecore_wl2/ecore_wl2_input.c | 13 +++++++++---- src/lib/ecore_wl2/ecore_wl2_private.h | 1 + 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/lib/ecore_wl2/ecore_wl2_input.c b/src/lib/ecore_wl2/ecore_wl2_input.c index 2b4a804..4761672 100644 --- a/src/lib/ecore_wl2/ecore_wl2_input.c +++ b/src/lib/ecore_wl2/ecore_wl2_input.c @@ -780,6 +780,11 @@ _keyboard_cb_repeat(void *data) _ecore_wl2_input_key_send(input, input->focus.keyboard, input->repeat.sym, input->repeat.key + 8, WL_KEYBOARD_KEY_STATE_PRESSED, input->repeat.time); + if (!input->repeat.repeating) + { + ecore_timer_interval_set(input->repeat.timer, input->repeat.rate); + input->repeat.repeating = EINA_TRUE; + } return ECORE_CALLBACK_RENEW; out: @@ -841,9 +846,9 @@ _keyboard_cb_key(void *data, struct wl_keyboard *keyboard EINA_UNUSED, unsigned if (!input->repeat.timer) { + input->repeat.repeating = EINA_FALSE; input->repeat.timer = - ecore_timer_add(input->repeat.rate, _keyboard_cb_repeat, input); - ecore_timer_delay(input->repeat.timer, input->repeat.delay); + ecore_timer_add(input->repeat.delay, _keyboard_cb_repeat, input); } } } @@ -903,8 +908,8 @@ _keyboard_cb_repeat_setup(void *data, struct wl_keyboard *keyboard EINA_UNUSED, } input->repeat.enabled = EINA_TRUE; - input->repeat.rate = (rate / 10000); - input->repeat.delay = (delay / 1000); + input->repeat.rate = (1.0 / rate); + input->repeat.delay = (delay / 1000.0); } static const struct wl_keyboard_listener _keyboard_listener = diff --git a/src/lib/ecore_wl2/ecore_wl2_private.h b/src/lib/ecore_wl2/ecore_wl2_private.h index 680214a..fce1245 100644 --- a/src/lib/ecore_wl2/ecore_wl2_private.h +++ b/src/lib/ecore_wl2/ecore_wl2_private.h @@ -404,6 +404,7 @@ struct _Ecore_Wl2_Input unsigned int sym, key, time; double rate, delay; Eina_Bool enabled : 1; + Eina_Bool repeating : 1; } repeat; struct -- 2.7.4