_e_comp_wl_client_focus(E_Client *ec)
{
struct wl_resource *res;
- struct wl_client *wc;
uint32_t serial, *k;
Eina_List *l;
if (!ec->comp_data->surface) return;
/* send keyboard_enter to all keyboard resources */
- wc = wl_resource_get_client(ec->comp_data->surface);
serial = wl_display_next_serial(e_comp->wl_comp_data->wl.disp);
- EINA_LIST_FOREACH(e_comp->wl_comp_data->kbd.resources, l, res)
+ EINA_LIST_FOREACH(e_comp->wl_comp_data->kbd.focused, l, res)
{
- if (wl_resource_get_client(res) != wc) continue;
wl_keyboard_send_enter(res, serial, ec->comp_data->surface,
&e_comp->wl_comp_data->kbd.keys);
ec->comp_data->focus_update = 0;
}
}
+static Eina_Bool
+_e_comp_wl_evas_cb_focus_in_timer(E_Client *ec)
+{
+ E_Comp_Data *cdata;
+ uint32_t serial, *k;
+ struct wl_resource *res;
+ Eina_List *l;
+ double t;
+
+ if (e_object_is_del(E_OBJECT(ec))) return EINA_FALSE;
+
+ ec->comp_data->on_focus_timer = NULL;
+ cdata = ec->comp->wl_comp_data;
+
+ if (!cdata->kbd.focused) return EINA_FALSE;
+ serial = wl_display_next_serial(cdata->wl.disp);
+ t = ecore_time_unix_get();
+ EINA_LIST_FOREACH(cdata->kbd.focused, l, res)
+ wl_array_for_each(k, &cdata->kbd.keys)
+ wl_keyboard_send_key(res, serial, t,
+ *k, WL_KEYBOARD_KEY_STATE_PRESSED);
+ return EINA_FALSE;
+}
+
static void
_e_comp_wl_evas_cb_focus_in(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
{
E_Client *ec, *focused;
+ E_Comp_Data *cdata;
+ struct wl_resource *res;
+ struct wl_client *wc;
+ Eina_List *l;
if (!(ec = data)) return;
if (e_object_is_del(E_OBJECT(ec))) return;
if (ec->iconic) return;
if (e_pixmap_type_get(ec->pixmap) != E_PIXMAP_TYPE_WL) return;
+ cdata = ec->comp->wl_comp_data;
+
/* block spurious focus events */
focused = e_client_focused_get();
if ((focused) && (ec != focused)) return;
/* raise client priority */
_e_comp_wl_client_priority_raise(ec);
+ wc = wl_resource_get_client(ec->comp_data->surface);
+ EINA_LIST_FOREACH(cdata->kbd.resources, l, res)
+ if (wl_resource_get_client(res) == wc)
+ cdata->kbd.focused = eina_list_append(cdata->kbd.focused, res);
+
_e_comp_wl_client_focus(ec);
+
+ ec->comp_data->on_focus_timer =
+ ecore_timer_add(((e_config->xkb.delay_held_key_input_to_focus)/1000),
+ (Ecore_Task_Cb)_e_comp_wl_evas_cb_focus_in_timer, ec);
}
static void
E_Client *ec;
E_Comp_Data *cdata;
struct wl_resource *res;
- struct wl_client *wc;
uint32_t serial, *k;
- Eina_List *l;
+ Eina_List *l, *ll;
+ double t;
if (!(ec = data)) return;
if (e_object_is_del(E_OBJECT(ec))) return;
if (e_pixmap_type_get(ec->pixmap) != E_PIXMAP_TYPE_WL) return;
+ E_FREE_FUNC(ec->comp_data->on_focus_timer, ecore_timer_del);
+
/* lower client priority */
_e_comp_wl_client_priority_normal(ec);
if (!ec->comp_data->surface) return;
- /* send keyboard_leave to all keyboard resources */
- wc = wl_resource_get_client(ec->comp_data->surface);
+ /* send key release and keyboard_leave to all focused resources */
serial = wl_display_next_serial(cdata->wl.disp);
- EINA_LIST_FOREACH(cdata->kbd.resources, l, res)
+ t = ecore_time_unix_get();
+ EINA_LIST_FOREACH_SAFE(cdata->kbd.focused, l, ll, res)
{
- if (wl_resource_get_client(res) != wc) continue;
+ wl_array_for_each(k, &cdata->kbd.keys)
+ wl_keyboard_send_key(res, serial, t,
+ *k, WL_KEYBOARD_KEY_STATE_RELEASED);
wl_keyboard_send_leave(res, serial, ec->comp_data->surface);
+ cdata->kbd.focused =
+ eina_list_remove_list(cdata->kbd.focused, l);
}
ec->comp_data->focus_update = 0;
}
{
if (ec->comp_data->surface)
{
- struct wl_client *wc;
struct wl_resource *res;
Eina_List *l;
- wc = wl_resource_get_client(ec->comp_data->surface);
serial = wl_display_next_serial(cdata->wl.disp);
- EINA_LIST_FOREACH(cdata->kbd.resources, l, res)
- {
- if (wl_resource_get_client(res) != wc) continue;
- wl_keyboard_send_key(res, serial, ev->timestamp,
- keycode, WL_KEYBOARD_KEY_STATE_PRESSED);
- }
+ EINA_LIST_FOREACH(cdata->kbd.focused, l, res)
+ wl_keyboard_send_key(res, serial, ev->timestamp,
+ keycode, WL_KEYBOARD_KEY_STATE_PRESSED);
/* A key only sent to clients is added to the list */
cdata->kbd.keys.size = (const char *)end - (const char *)cdata->kbd.keys.data;
static void
_e_comp_wl_cb_key_up(void *event)
{
- E_Client *ec;
E_Comp_Data *cdata;
Ecore_Event_Key *ev;
uint32_t serial, *end, *k, keycode;
/* If a key down event have been sent to clients, send a key up event to client for garantee key event sequence pair. (down/up) */
if (delivered_key || ((!e_client_action_get()) && (!e_comp->input_key_grabs) && (!e_menu_grab_window_get())))
{
- if ((ec = e_client_focused_get()))
- {
- if (ec->comp_data->surface)
- {
- struct wl_client *wc;
- struct wl_resource *res;
- Eina_List *l;
+ struct wl_resource *res;
+ Eina_List *l;
- wc = wl_resource_get_client(ec->comp_data->surface);
- serial = wl_display_next_serial(cdata->wl.disp);
- EINA_LIST_FOREACH(cdata->kbd.resources, l, res)
- {
- if (wl_resource_get_client(res) != wc) continue;
- wl_keyboard_send_key(res, serial, ev->timestamp,
- keycode, WL_KEYBOARD_KEY_STATE_RELEASED);
- }
- }
- }
+ serial = wl_display_next_serial(cdata->wl.disp);
+ EINA_LIST_FOREACH(cdata->kbd.focused, l, res)
+ wl_keyboard_send_key(res, serial, ev->timestamp,
+ keycode, WL_KEYBOARD_KEY_STATE_RELEASED);
}
if (cdata->kbd.mod_changed)