From d9a660bff9e8fc0f1e163d1b3bd873658e4d8539 Mon Sep 17 00:00:00 2001 From: Derek Foreman Date: Wed, 13 Jul 2016 16:01:51 -0500 Subject: [PATCH] Make sure the same keyboard resource doesn't end up on the focus list twice This stops recent xdg_popup focus tracking changes from causing multiple key events to be sent to the focused client. --- src/bin/e_comp_wl.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/bin/e_comp_wl.c b/src/bin/e_comp_wl.c index 61debb2b8..7f2bef431 100644 --- a/src/bin/e_comp_wl.c +++ b/src/bin/e_comp_wl.c @@ -486,6 +486,19 @@ _e_comp_wl_evas_cb_focus_in_timer(E_Client *ec) return EINA_FALSE; } +static Eina_Bool +_keyboard_resource_add(struct wl_resource *newres) +{ + Eina_List *l; + struct wl_resource *res; + + EINA_LIST_FOREACH(e_comp_wl->kbd.focused, l, res) + if (res == newres) return EINA_FALSE; + + e_comp_wl->kbd.focused = eina_list_append(e_comp_wl->kbd.focused, newres); + return EINA_TRUE; +} + static void _e_comp_wl_evas_cb_focus_in(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED) { @@ -493,6 +506,7 @@ _e_comp_wl_evas_cb_focus_in(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj struct wl_resource *res; struct wl_client *wc; Eina_List *l; + int added = 0; if (!(ec = data)) return; if (e_object_is_del(E_OBJECT(ec))) return; @@ -508,8 +522,9 @@ _e_comp_wl_evas_cb_focus_in(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj wc = wl_resource_get_client(ec->comp_data->surface); EINA_LIST_FOREACH(e_comp_wl->kbd.resources, l, res) if (wl_resource_get_client(res) == wc) - e_comp_wl->kbd.focused = eina_list_append(e_comp_wl->kbd.focused, res); + added |= _keyboard_resource_add(res); if (!e_comp_wl->kbd.focused) return; + if (!added) return; e_comp_wl_input_keyboard_enter_send(ec); if (e_comp_util_kbd_grabbed()) return; e_comp_wl_data_device_keyboard_focus_set();