send wl keyboard enter during commit
authorMike Blumenkrantz <zmike@osg.samsung.com>
Wed, 11 Feb 2015 00:17:50 +0000 (19:17 -0500)
committerMike Blumenkrantz <zmike@osg.samsung.com>
Wed, 11 Feb 2015 00:17:50 +0000 (19:17 -0500)
in some cases this was happening before the kbd resource was available; this guarantees that it will be

src/bin/e_comp_wl.c
src/bin/e_comp_wl.h

index 0404800675695905447b522ac77faaa4c2388180..795991d99a960e11be5ec093fdb45678d0ecf537 100644 (file)
@@ -507,11 +507,6 @@ 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;
-   uint32_t serial, *k;
-   Eina_List *l;
 
    if (!(ec = data)) return;
    if (e_object_is_del(E_OBJECT(ec))) return;
@@ -525,24 +520,7 @@ _e_comp_wl_evas_cb_focus_in(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj
 
    /* raise client priority */
    _e_comp_wl_client_priority_raise(ec);
-
-   cdata = ec->comp->wl_comp_data;
-
-   /* update keyboard modifier state */
-   wl_array_for_each(k, &cdata->kbd.keys)
-     e_comp_wl_input_keyboard_state_update(cdata, *k, EINA_TRUE);
-
-   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(cdata->wl.disp);
-   EINA_LIST_FOREACH(cdata->kbd.resources, l, res)
-     {
-        if (wl_resource_get_client(res) != wc) continue;
-        wl_keyboard_send_enter(res, serial, ec->comp_data->surface, 
-                               &cdata->kbd.keys);
-     }
+   ec->comp_data->focus_update = 1;
 }
 
 static void 
@@ -579,6 +557,7 @@ _e_comp_wl_evas_cb_focus_out(void *data, Evas *evas EINA_UNUSED, Evas_Object *ob
         if (wl_resource_get_client(res) != wc) continue;
         wl_keyboard_send_leave(res, serial, ec->comp_data->surface);
      }
+   ec->comp_data->focus_update = 0;
 }
 
 static void 
@@ -2546,6 +2525,28 @@ e_comp_wl_surface_commit(E_Client *ec)
 
    if (!(ep = ec->pixmap)) return EINA_FALSE;
    _e_comp_wl_client_evas_init(ec);
+   if (ec->focused && ec->comp_data->focus_update)
+     {
+        struct wl_resource *res;
+        struct wl_client *wc;
+        uint32_t serial, *k;
+        Eina_List *l;
+
+        /* update keyboard modifier state */
+        wl_array_for_each(k, &e_comp->wl_comp_data->kbd.keys)
+          e_comp_wl_input_keyboard_state_update(e_comp->wl_comp_data, *k, EINA_TRUE);
+
+        /* 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)
+          {
+             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;
+     }
 
    /* mark the pixmap as usable or not */
    e_pixmap_usable_set(ep, (ec->comp_data->pending.buffer != NULL));
index 9d29c3b0494112f29c0acb0270a98f0b1fbca7b7..ba0713444f32c3c7ddd7b10e11b46ef606700f54 100644 (file)
@@ -263,6 +263,7 @@ struct _E_Comp_Wl_Client_Data
    Eina_Bool first_damage : 1;
    Eina_Bool set_win_type : 1;
    Eina_Bool frame_update : 1;
+   Eina_Bool focus_update : 1;
 };
 
 EAPI Eina_Bool e_comp_wl_init(void);