wayland compositor: Send keyboard enter events on get keyboard
authorDerek Foreman <derekf@osg.samsung.com>
Fri, 20 Mar 2015 19:21:39 +0000 (15:21 -0400)
committerMike Blumenkrantz <zmike@osg.samsung.com>
Fri, 20 Mar 2015 19:21:40 +0000 (15:21 -0400)
Summary:
Now when a client gets the keyboard global it will immediately be sent
a keyboard enter event if appropriate.

Reviewers: zmike, devilhorns

Subscribers: cedric

Differential Revision: https://phab.enlightenment.org/D2206

src/bin/e_comp_wl_input.c
src/bin/e_comp_wl_input.h

index 0cefac8..32f6cb5 100644 (file)
@@ -131,9 +131,40 @@ _e_comp_wl_input_cb_keyboard_unbind(struct wl_resource *resource)
    cdata->kbd.resources = eina_list_remove(cdata->kbd.resources, resource);
 }
 
+void
+e_comp_wl_input_keyboard_enter_send(E_Client *ec)
+{
+   struct wl_resource *res;
+   struct wl_client *wc;
+   Eina_List *l;
+   uint32_t serial;
+
+   if (!ec->comp_data->surface) return;
+
+   if (!eina_list_count(e_comp->wl_comp_data->kbd.resources)) return;
+
+   e_comp_wl_input_keyboard_modifiers_serialize(e_comp->wl_comp_data);
+
+   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)
+     {
+        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);
+        wl_keyboard_send_modifiers(res, serial,
+                                   e_comp->wl_comp_data->kbd.mod_depressed,
+                                   e_comp->wl_comp_data->kbd.mod_latched,
+                                   e_comp->wl_comp_data->kbd.mod_locked,
+                                   e_comp->wl_comp_data->kbd.mod_group);
+     }
+}
+
 static void
 _e_comp_wl_input_cb_keyboard_get(struct wl_client *client, struct wl_resource *resource, uint32_t id)
 {
+   E_Client *focused;
    E_Comp_Data *cdata;
    struct wl_resource *res;
 
@@ -157,6 +188,13 @@ _e_comp_wl_input_cb_keyboard_get(struct wl_client *client, struct wl_resource *r
    /* send current keymap */
    wl_keyboard_send_keymap(res, WL_KEYBOARD_KEYMAP_FORMAT_XKB_V1,
                            cdata->xkb.fd, cdata->xkb.size);
+
+   /* if the client owns the focused surface, we need to send an enter */
+   focused = e_client_focused_get();
+   if (!focused)
+     return;
+
+   e_comp_wl_input_keyboard_enter_send(focused);
 }
 
 static void
index 0392bdb..a0b3604 100644 (file)
@@ -11,6 +11,7 @@ EINTERN Eina_Bool e_comp_wl_input_keyboard_check(struct wl_resource *res);
 EINTERN void e_comp_wl_input_keyboard_modifiers_serialize(E_Comp_Data *cdata);
 EINTERN void e_comp_wl_input_keyboard_modifiers_update(E_Comp_Data *cdata);
 EINTERN void e_comp_wl_input_keyboard_state_update(E_Comp_Data *cdata, uint32_t keycode, Eina_Bool pressed);
+EINTERN void e_comp_wl_input_keyboard_enter_send(E_Client *client);
 
 EAPI void e_comp_wl_input_pointer_enabled_set(E_Comp_Data *cdata, Eina_Bool enabled);
 EAPI void e_comp_wl_input_keyboard_enabled_set(E_Comp_Data *cdata, Eina_Bool enabled);