e_input: remove kbd.focused, resources, and keys mutex
authorJihoon Kim <jihoon48.kim@samsung.com>
Wed, 13 Mar 2024 02:27:53 +0000 (11:27 +0900)
committerSooChan Lim <sc1.lim@samsung.com>
Tue, 9 Apr 2024 01:52:31 +0000 (10:52 +0900)
Change-Id: Ideab71511cb568c68a1d35dde83f0059c69ddc21
Signed-off-by: Jihoon Kim <jihoon48.kim@samsung.com>
src/bin/e_comp_wl.c
src/bin/e_comp_wl_input.c
src/bin/e_comp_wl_input_intern.h
src/bin/e_input_intern.h
src/bin/e_keyrouter_wl.c

index 77d751c5177a4b2b7cbb72cf09e115b105fe753c..b4574585adbbe7836a3d98d0b648ac032d50d4c3 100644 (file)
@@ -1998,8 +1998,8 @@ _e_comp_wl_client_priority_normal(E_Client *ec)
                                      EINA_FALSE, EINA_TRUE, EINA_FALSE);
 }
 
-static Eina_Bool
-_e_comp_wl_evas_cb_focus_in_timer(E_Client *ec)
+static void
+_e_comp_wl_input_thread_send_keys()
 {
    uint32_t serial;
    E_Comp_Wl_Key_Data *k;
@@ -2007,24 +2007,14 @@ _e_comp_wl_evas_cb_focus_in_timer(E_Client *ec)
    Eina_List *l;
    double t;
 
-   if (!ec) return EINA_FALSE;
-   if (e_object_is_del(E_OBJECT(ec))) return EINA_FALSE;
-   if (!ec->comp_data) return EINA_FALSE;
-
-   ec->comp_data->on_focus_timer = NULL;
-   g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
    if (!e_comp_wl->kbd.focused)
      {
-        g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
-        return EINA_FALSE;
+        return;
      }
-   g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
 
    serial = wl_display_next_serial(e_comp_wl->wl.disp);
    t = ecore_time_unix_get();
 
-   g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
-   g_mutex_lock(&e_comp_wl->kbd.keys_mutex);
    EINA_LIST_FOREACH(e_comp_wl->kbd.focused, l, res)
      {
         wl_array_for_each(k, &e_comp_wl->kbd.keys)
@@ -2034,62 +2024,78 @@ _e_comp_wl_evas_cb_focus_in_timer(E_Client *ec)
                                   k->key, WL_KEYBOARD_KEY_STATE_PRESSED);
           }
      }
-   g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
-   g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
+}
+
+static Eina_Bool
+_e_comp_wl_evas_cb_focus_in_timer(E_Client *ec)
+{
+   if (!ec) return EINA_FALSE;
+   if (e_object_is_del(E_OBJECT(ec))) return EINA_FALSE;
+   if (!ec->comp_data) return EINA_FALSE;
+
+   ec->comp_data->on_focus_timer = NULL;
+
+   e_input_thread_safe_call(_e_comp_wl_input_thread_send_keys, NULL, 0);
+
    return EINA_FALSE;
 }
 
-/* It is called in the following cases:
- *  When a normal ec->frame has focus.
- *  Or launching image ec is replaced to the real ec.
- */
-EINTERN void
-e_comp_wl_feed_focus_in(E_Client *ec)
+static void
+_e_comp_wl_input_thread_focus_in(void *data)
 {
-   E_Client *focused;
+   struct wl_resource *surface = NULL;
+   memcpy(&surface, data, sizeof(struct wl_resource *));
    struct wl_resource *res;
    struct wl_client *wc;
    Eina_List *l;
 
-   if (!ec) return;
-   if (e_object_is_del(E_OBJECT(ec))) return;
-   if (ec->iconic) return;
-
-   /* block spurious focus events */
-   focused = e_client_focused_get();
-   if ((focused) && (ec != focused)) return;
-
-   /* raise client priority */
-   _e_comp_wl_client_priority_raise(ec);
-   struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
-   if (!surface) return;
-
    wc = wl_resource_get_client(surface);
 
-   g_mutex_lock(&e_comp_wl->kbd.resource_mutex);
    EINA_LIST_FOREACH(e_comp_wl->kbd.resources, l, res)
      {
         if (wl_resource_get_client(res) == wc)
           {
-             g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
              if (!eina_list_data_find(e_comp_wl->kbd.focused, res))
                e_comp_wl->kbd.focused = eina_list_append(e_comp_wl->kbd.focused, res);
-             g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
           }
      }
-   g_mutex_unlock(&e_comp_wl->kbd.resource_mutex);
 
-   g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
    if (!e_comp_wl->kbd.focused)
      {
-        g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
         return;
      }
-   g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
 
    e_comp_wl->kbd.focus = surface;
-   e_comp_wl_input_keyboard_enter_send(ec);
+   e_comp_wl_input_keyboard_enter_send(surface);
    e_comp_wl_data_device_keyboard_focus_set();
+}
+
+/* It is called in the following cases:
+ *  When a normal ec->frame has focus.
+ *  Or launching image ec is replaced to the real ec.
+ */
+EINTERN void
+e_comp_wl_feed_focus_in(E_Client *ec)
+{
+   E_Client *focused;
+
+   if (!ec) return;
+   if (e_object_is_del(E_OBJECT(ec))) return;
+   if (ec->iconic) return;
+
+   /* block spurious focus events */
+   focused = e_client_focused_get();
+   if ((focused) && (ec != focused)) return;
+
+   /* raise client priority */
+   _e_comp_wl_client_priority_raise(ec);
+
+   struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
+   if (!surface) return;
+
+   INF("send focus in request to input thread. resource %p\n", surface);
+   e_input_thread_safe_call(_e_comp_wl_input_thread_focus_in, (void *)&surface, sizeof(struct wl_resource *));
+
    ec->comp_data->on_focus_timer =
       ecore_timer_add(((e_config->xkb.delay_held_key_input_to_focus)/1000.0),
                       (Ecore_Task_Cb)_e_comp_wl_evas_cb_focus_in_timer, ec);
@@ -2106,51 +2112,32 @@ _e_comp_wl_evas_cb_focus_in(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj
 }
 
 static void
-_e_comp_wl_evas_cb_focus_out(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
+_e_comp_wl_input_thread_focus_out(void *data)
 {
-   E_Client *ec;
+   struct wl_resource *surface = NULL;
    struct wl_resource *res;
    uint32_t serial;
    E_Comp_Wl_Key_Data *k;
    Eina_List *l, *ll;
    double t;
 
-   if (!(ec = data)) return;
-
-   if (!ec->comp_data) return;
-
-   E_FREE_FUNC(ec->comp_data->on_focus_timer, ecore_timer_del);
-
-   /* lower client priority */
-   if (!e_object_is_del(data))
-     _e_comp_wl_client_priority_normal(ec);
-
+   memcpy(&surface, data, sizeof(struct wl_resource *));
 
    /* update keyboard modifier state */
-   g_mutex_lock(&e_comp_wl->kbd.keys_mutex);
    wl_array_for_each(k, &e_comp_wl->kbd.keys)
       e_comp_wl_input_keyboard_state_update(k->key, EINA_FALSE);
 
-   g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
-
-   struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
    if (!surface) return;
 
-   g_mutex_lock(&e_comp_wl->kbd.resource_mutex);
    if (!eina_list_count(e_comp_wl->kbd.resources))
      {
-        g_mutex_unlock(&e_comp_wl->kbd.resource_mutex);
         return;
      }
 
-   g_mutex_unlock(&e_comp_wl->kbd.resource_mutex);
-
    /* send keyboard_leave to all keyboard resources */
    serial = wl_display_next_serial(e_comp_wl->wl.disp);
    t = ecore_time_unix_get();
 
-   g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
-   g_mutex_lock(&e_comp_wl->kbd.keys_mutex);
    EINA_LIST_FOREACH_SAFE(e_comp_wl->kbd.focused, l, ll, res)
      {
         wl_array_for_each(k, &e_comp_wl->kbd.keys)
@@ -2163,8 +2150,25 @@ _e_comp_wl_evas_cb_focus_out(void *data, Evas *evas EINA_UNUSED, Evas_Object *ob
         e_comp_wl->kbd.focused =
            eina_list_remove_list(e_comp_wl->kbd.focused, l);
      }
-   g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
-   g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
+}
+
+static void
+_e_comp_wl_evas_cb_focus_out(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
+{
+   E_Client *ec;
+   if (!(ec = data)) return;
+
+   if (!ec->comp_data) return;
+
+   E_FREE_FUNC(ec->comp_data->on_focus_timer, ecore_timer_del);
+
+   /* lower client priority */
+   if (!e_object_is_del(data))
+     _e_comp_wl_client_priority_normal(ec);
+
+   struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
+   INF("send focus out request to input thread. resource %p\n", surface);
+   e_input_thread_safe_call(_e_comp_wl_input_thread_focus_out, (void *)&surface, sizeof(struct wl_resource *));
 }
 
 static void
@@ -3263,17 +3267,13 @@ e_comp_wl_client_surface_finish(E_Client *ec)
    if (surface_client &&
        (ec == e_client_focused_get()))
      {
-        g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
         EINA_LIST_FOREACH_SAFE(e_comp_wl->kbd.focused, l, ll, res)
           {
              if (wl_resource_get_client(res) ==
                  surface_client)
                e_comp_wl->kbd.focused =
                   eina_list_remove_list(e_comp_wl->kbd.focused, l);
-
           }
-
-        g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
      }
 
    e_comp_wl_client_surface_set(ec, NULL);
@@ -4312,8 +4312,6 @@ e_comp_wl_key_down(Ecore_Event_Key *ev, E_Device *dev)
      }
 #endif
 
-   g_mutex_lock(&e_comp_wl->kbd.keys_mutex);
-
    end = (E_Comp_Wl_Key_Data *)e_comp_wl->kbd.keys.data + (e_comp_wl->kbd.keys.size / sizeof(*k));
 
    for (k = e_comp_wl->kbd.keys.data; k < end; k++)
@@ -4321,40 +4319,31 @@ e_comp_wl_key_down(Ecore_Event_Key *ev, E_Device *dev)
         /* ignore server-generated key repeats */
         if (k->key == keycode)
           {
-             g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
              return EINA_FALSE;
           }
      }
 
-   g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
-
    if ((!e_client_action_get()) && (!e_comp->input_key_grabs))
      {
         ec = e_client_focused_get();
         struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
         if (ec && ec->comp_data && surface)
           {
-             g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
              if (e_comp_wl->kbd.focused)
                {
                   _e_comp_wl_key_send(ev, dev, WL_KEYBOARD_KEY_STATE_PRESSED, e_comp_wl->kbd.focused, ec);
 
                   /* A key only sent to clients is added to the list */
-                  g_mutex_lock(&e_comp_wl->kbd.keys_mutex);
                   e_comp_wl->kbd.keys.size = (const char *)end - (const char *)e_comp_wl->kbd.keys.data;
 
                   if (!(k = wl_array_add(&e_comp_wl->kbd.keys, sizeof(*k))))
                     {
                        DBG("wl_array_add: Out of memory\n");
-                       g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
-                       g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
                        return EINA_FALSE;
                     }
-                  g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
                   k->key = keycode;
                   k->dev = ev->dev;
                }
-             g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
           }
      }
 
@@ -4383,8 +4372,6 @@ e_comp_wl_key_up(Ecore_Event_Key *ev, E_Device *dev)
         return EINA_FALSE;
      }
 
-   g_mutex_lock(&e_comp_wl->kbd.keys_mutex);
-
    end = (E_Comp_Wl_Key_Data *)e_comp_wl->kbd.keys.data + (e_comp_wl->kbd.keys.size / sizeof(*k));
    for (k = e_comp_wl->kbd.keys.data; k < end; k++)
      {
@@ -4398,20 +4385,16 @@ e_comp_wl_key_up(Ecore_Event_Key *ev, E_Device *dev)
    e_comp_wl->kbd.keys.size =
      (const char *)end - (const char *)e_comp_wl->kbd.keys.data;
 
-   g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
-
    /* 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)))
      {
         ec = e_client_focused_get();
 
-        g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
         if (e_comp_wl->kbd.focused)
           {
              _e_comp_wl_key_send(ev, dev, WL_KEYBOARD_KEY_STATE_RELEASED, e_comp_wl->kbd.focused, ec);
           }
-        g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
      }
 
    /* update modifier state */
@@ -4672,7 +4655,6 @@ e_comp_wl_key_send(E_Client *ec, int keycode, Eina_Bool pressed, void *dev, uint
         ELOGF("INPUT", "wl_keyboard_send_key:%s:%d|B|", NULL, (state ? "PRESS" : "RELEASE"), keycode);
      }
 
-   g_mutex_lock(&e_comp_wl->kbd.resource_mutex);
    EINA_LIST_FOREACH(e_comp_wl->kbd.resources, l, res)
      {
         if (wl_resource_get_client(res) != wc) continue;
@@ -4704,7 +4686,6 @@ e_comp_wl_key_send(E_Client *ec, int keycode, Eina_Bool pressed, void *dev, uint
         wl_keyboard_send_key(res, serial, time,
                              wl_keycode, state);
      }
-   g_mutex_unlock(&e_comp_wl->kbd.resource_mutex);
 
    if (e_config->key_input_ttrace_enable)
      {
@@ -4756,7 +4737,6 @@ e_comp_wl_key_cancel(E_Client *ec, int keycode, Ecore_Device *dev, uint32_t time
    comp_conf = e_comp_config_get();
    e_keyrouter_event_surface_send(ec, keycode);
 
-   g_mutex_lock(&e_comp_wl->kbd.resource_mutex);
    EINA_LIST_FOREACH(e_comp_wl->kbd.resources, l, res)
      {
         if (wl_resource_get_client(res) != wc) continue;
@@ -4772,7 +4752,6 @@ e_comp_wl_key_cancel(E_Client *ec, int keycode, Ecore_Device *dev, uint32_t time
         wl_keyboard_send_key(res, serial, time,
                              cancel_keycode, WL_KEYBOARD_KEY_STATE_RELEASED);
      }
-   g_mutex_unlock(&e_comp_wl->kbd.resource_mutex);
 
    return EINA_TRUE;
 }
index 2ac0a599f5ddd55d0a904fd13a66a1df4b502cd4..275efa27e55b2d7c91b2bbe809ceb3621aa6d968 100644 (file)
@@ -312,30 +312,32 @@ _e_comp_wl_input_cb_pointer_get(struct wl_client *client, struct wl_resource *re
 }
 
 static void
-_e_comp_wl_input_cb_keyboard_unbind(struct wl_resource *resource)
+_e_comp_wl_input_thread_cb_keyboard_unbind(void *data)
 {
    Eina_List *l, *ll;
    struct wl_resource *res;
+   struct wl_resource *resource;
 
-   g_mutex_lock(&e_comp_wl->kbd.resource_mutex);
+   memcpy(&resource, data, sizeof(struct wl_resource *));
 
    e_comp_wl->kbd.resources =
      eina_list_remove(e_comp_wl->kbd.resources, resource);
 
-   g_mutex_unlock(&e_comp_wl->kbd.resource_mutex);
-
-   g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
-
    EINA_LIST_FOREACH_SAFE(e_comp_wl->kbd.focused, l, ll, res)
      if (res == resource)
        e_comp_wl->kbd.focused =
          eina_list_remove_list(e_comp_wl->kbd.focused, l);
+}
 
-   g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
+static void
+_e_comp_wl_input_cb_keyboard_unbind(struct wl_resource *resource)
+{
+   INF("[keyboard unbind] resource %p\n", resource);
+   e_input_thread_safe_call(_e_comp_wl_input_thread_cb_keyboard_unbind, &resource, sizeof(struct wl_resource *));
 }
 
 void
-e_comp_wl_input_keyboard_enter_send(E_Client *ec)
+e_comp_wl_input_keyboard_enter_send(struct wl_resource *surface)
 {
    struct wl_resource *res;
    Eina_List *l;
@@ -343,26 +345,15 @@ e_comp_wl_input_keyboard_enter_send(E_Client *ec)
    xkb_mod_mask_t mod_depressed, mod_latched, mod_locked;
    xkb_layout_index_t mod_group;
 
-   struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
-   if (!surface) return;
-
-   g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
-
    if (!e_comp_wl->kbd.focused)
      {
-        g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
         return;
      }
 
-   g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
-
    e_comp_wl_input_keyboard_modifiers_serialize();
 
    serial = wl_display_next_serial(e_comp_wl->wl.disp);
 
-   g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
-   g_mutex_lock(&e_comp_wl->kbd.keys_mutex);
-
    mod_depressed = atomic_load(&e_comp_wl->kbd.mod_depressed);
    mod_latched = atomic_load(&e_comp_wl->kbd.mod_latched);
    mod_locked = atomic_load(&e_comp_wl->kbd.mod_locked);
@@ -380,31 +371,22 @@ e_comp_wl_input_keyboard_enter_send(E_Client *ec)
                                    mod_locked,
                                    mod_group);
      }
-   g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
-   g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
 }
 
 static void
-_e_comp_wl_input_cb_keyboard_get(struct wl_client *client, struct wl_resource *resource, uint32_t id)
+_e_comp_wl_input_thread_cb_keyboard_get(void *data)
 {
    E_Client *focused;
    struct wl_resource *res;
 
-   /* try to create keyboard resource */
-   res = wl_resource_create(client, &wl_keyboard_interface,
-                            wl_resource_get_version(resource), id);
-   if (!res)
-     {
-        ERR("Could not create keyboard on seat %s: %m",
-            e_comp_wl->seat.name);
-        wl_client_post_no_memory(client);
-        return;
-     }
+   E_Input_Thread_Request_Keyboard_Get_Data keyboard_get_data;
+   memcpy(&keyboard_get_data, data, sizeof(E_Input_Thread_Request_Keyboard_Get_Data));
+
+   res = keyboard_get_data.resource;
 
-   g_mutex_lock(&e_comp_wl->kbd.resource_mutex);
    e_comp_wl->kbd.resources =
      eina_list_append(e_comp_wl->kbd.resources, res);
-   g_mutex_unlock(&e_comp_wl->kbd.resource_mutex);
+
    wl_resource_set_implementation(res, &_e_keyboard_interface,
                                   e_comp->wl_comp_data,
                                   _e_comp_wl_input_cb_keyboard_unbind);
@@ -415,13 +397,6 @@ _e_comp_wl_input_cb_keyboard_get(struct wl_client *client, struct wl_resource *r
         wl_keyboard_send_repeat_info(res, e_comp_wl->kbd.repeat_rate, e_comp_wl->kbd.repeat_delay);
      }
 
-   /* send current keymap */
-   TRACE_INPUT_BEGIN(wl_keyboard_send_keymap);
-   wl_keyboard_send_keymap(res, WL_KEYBOARD_KEYMAP_FORMAT_XKB_V1,
-                           e_comp_input_key->xkb.fd,
-                           e_comp_input_key->xkb.size);
-   TRACE_INPUT_END();
-
    /* if the client owns the focused surface, we need to send an enter */
    focused = e_client_focused_get();
    if ((!focused) || (e_object_is_del(E_OBJECT(focused))) ||
@@ -430,12 +405,41 @@ _e_comp_wl_input_cb_keyboard_get(struct wl_client *client, struct wl_resource *r
    struct wl_resource *surface = e_comp_wl_client_surface_get(focused);
    if (!surface) return;
 
-   if (client != wl_resource_get_client(surface)) return;
-   g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
+   if (keyboard_get_data.client != wl_resource_get_client(surface)) return;
    e_comp_wl->kbd.focused = eina_list_append(e_comp_wl->kbd.focused, res);
-   g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
 
-   e_comp_wl_input_keyboard_enter_send(focused);
+   e_comp_wl_input_keyboard_enter_send(surface);
+}
+
+static void
+_e_comp_wl_input_cb_keyboard_get(struct wl_client *client, struct wl_resource *resource, uint32_t id)
+{
+   struct wl_resource *res;
+   E_Input_Thread_Request_Keyboard_Get_Data keyboard_get_data;
+
+   /* try to create keyboard resource */
+   res = wl_resource_create(client, &wl_keyboard_interface,
+                            wl_resource_get_version(resource), id);
+   if (!res)
+     {
+        ERR("Could not create keyboard on seat %s: %m",
+            e_comp_wl->seat.name);
+        wl_client_post_no_memory(client);
+        return;
+     }
+
+   /* send current keymap */
+   TRACE_INPUT_BEGIN(wl_keyboard_send_keymap);
+   wl_keyboard_send_keymap(res, WL_KEYBOARD_KEYMAP_FORMAT_XKB_V1,
+                           e_comp_input_key->xkb.fd,
+                           e_comp_input_key->xkb.size);
+   TRACE_INPUT_END();
+
+   keyboard_get_data.resource = res;
+   keyboard_get_data.client = client;
+
+   INF("[keyboard_get] resource: %p, client : %p\n", keyboard_get_data.resource, keyboard_get_data.client);
+   e_input_thread_safe_call(_e_comp_wl_input_thread_cb_keyboard_get, &keyboard_get_data, sizeof(E_Input_Thread_Request_Keyboard_Get_Data));
 }
 
 static void
@@ -1509,12 +1513,10 @@ _e_comp_wl_input_keymap_update(struct xkb_keymap *keymap, const char *keymap_pat
 
    /* send updated keymap */
    TRACE_INPUT_BEGIN(wl_keyboard_send_keymap_update);
-   g_mutex_lock(&e_comp_wl->kbd.resource_mutex);
    EINA_LIST_FOREACH(e_comp_wl->kbd.resources, l, res)
      wl_keyboard_send_keymap(res, WL_KEYBOARD_KEYMAP_FORMAT_XKB_V1,
                              e_comp_input_key->xkb.fd,
                              e_comp_input_key->xkb.size);
-   g_mutex_unlock(&e_comp_wl->kbd.resource_mutex);
    TRACE_INPUT_END();
 
    /* update modifiers */
@@ -1602,10 +1604,7 @@ e_comp_wl_input_init(void)
                                              _e_comp_wl_input_cb_surface_commit,
                                              NULL);
 
-   g_mutex_lock(&e_comp_wl->kbd.keys_mutex);
    wl_array_init(&e_comp_wl->kbd.keys);
-   g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
-
    wl_array_init(&e_comp_wl->kbd.routed_keys);
 
    E_EVENT_TEXT_INPUT_PANEL_VISIBILITY_CHANGE = ecore_event_type_new();
@@ -1656,11 +1655,9 @@ e_comp_wl_input_shutdown(void)
      wl_resource_destroy(res);
 
    /* destroy keyboard resources */
-   g_mutex_lock(&e_comp_wl->kbd.resource_mutex);
    EINA_LIST_FREE(e_comp_wl->kbd.resources, res)
      wl_resource_destroy(res);
    e_comp_wl->kbd.resources = eina_list_free(e_comp_wl->kbd.resources);
-   g_mutex_unlock(&e_comp_wl->kbd.resource_mutex);
 
    g_mutex_clear(&e_comp_wl->kbd.resource_mutex);
    g_mutex_clear(&e_comp_wl->kbd.focused_mutex);
@@ -1670,9 +1667,7 @@ e_comp_wl_input_shutdown(void)
      wl_resource_destroy(res);
 
    /* destroy e_comp_wl->kbd.keys array */
-   g_mutex_lock(&e_comp_wl->kbd.keys_mutex);
    wl_array_release(&e_comp_wl->kbd.keys);
-   g_mutex_unlock(&e_comp_wl->kbd.keys_mutex);
 
    wl_array_release(&e_comp_wl->kbd.routed_keys);
 
@@ -1788,24 +1783,18 @@ e_comp_wl_input_keyboard_modifiers_update(void)
    Eina_List *l;
 
    if (!e_comp_wl_input_keyboard_modifiers_serialize()) return;
-   g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
    if (!e_comp_wl->kbd.focused)
      {
-       g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
        return;
      }
 
-   g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
-
    serial = wl_display_next_serial(e_comp_wl->wl.disp);
-   g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
    EINA_LIST_FOREACH(e_comp_wl->kbd.focused, l, res)
      wl_keyboard_send_modifiers(res, serial,
                                 e_comp_wl->kbd.mod_depressed,
                                 e_comp_wl->kbd.mod_latched,
                                 e_comp_wl->kbd.mod_locked,
                                 e_comp_wl->kbd.mod_group);
-   g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
 }
 
 EINTERN void
@@ -2138,15 +2127,12 @@ e_comp_wl_input_keyboard_repeat_set(int delay, int rate)
    atomic_store(&e_comp_wl->kbd.repeat_delay, delay);
    atomic_store(&e_comp_wl->kbd.repeat_rate, rate);
 
-   g_mutex_lock(&e_comp_wl->kbd.resource_mutex);
    EINA_LIST_FOREACH(e_comp_wl->kbd.resources, l, res)
      {
         if (wl_resource_get_version(res) >= WL_KEYBOARD_REPEAT_INFO_SINCE_VERSION)
           wl_keyboard_send_repeat_info(res, e_comp_wl->kbd.repeat_rate,
                                        e_comp_wl->kbd.repeat_delay);
      }
-
-   g_mutex_unlock(&e_comp_wl->kbd.resource_mutex);
 }
 
 typedef struct _keycode_map{
index 244959498665a163ecbb0b73796cd1013cecad3c..ec1fbe0bc4b8f671995fccd1e112e657f34b8ec1 100644 (file)
@@ -20,7 +20,7 @@ EINTERN Eina_Bool e_comp_wl_input_keyboard_check(struct wl_resource *res);
 EINTERN Eina_Bool e_comp_wl_input_keyboard_modifiers_serialize(void);
 EINTERN void      e_comp_wl_input_keyboard_modifiers_update(void);
 EINTERN void      e_comp_wl_input_keyboard_state_update(uint32_t keycode, Eina_Bool pressed);
-EINTERN void      e_comp_wl_input_keyboard_enter_send(E_Client *client);
+EINTERN void      e_comp_wl_input_keyboard_enter_send(struct wl_resource *surface);
 EINTERN void      e_comp_wl_input_keyboard_enabled_set(Eina_Bool enabled);
 
 EINTERN struct xkb_keymap *e_comp_wl_input_keymap_compile(struct xkb_context *ctx, struct xkb_rule_names names, char **keymap_path);
index 8b8039bea564555df5f8bdf464d36da06659644d..d2e42ac4584a8607e0a42f5ed2f95d33a543614b 100644 (file)
@@ -40,6 +40,12 @@ typedef struct
   uint32_t mode;
 } E_Input_Thread_Request_Keygrab_Data;
 
+typedef struct
+{
+   struct wl_client *client;
+   struct wl_resource *resource;
+} E_Input_Thread_Request_Keyboard_Get_Data;
+
 struct _E_Input_Seat
 {
    const char *name;
index 2a5b07eabad1a20d96ef41fdb94643d4ef5c66a0..aa2998aca56432f461954900b1ab826982009098 100644 (file)
@@ -70,11 +70,6 @@ _e_keyrouter_wl_key_send(Ecore_Event_Key *ev, E_Device *dev, enum wl_keyboard_ke
         ELOGF("INPUT", "wl_keyboard_send_key:%s:%s|B|", NULL, (state ? "PRESS" : "RELEASE"), ev->keyname);
      }
 
-   if (focused)
-     g_mutex_lock(&e_comp_wl->kbd.focused_mutex);
-   else
-     g_mutex_lock(&e_comp_wl->kbd.resource_mutex);
-
    EINA_LIST_FOREACH(key_list, l, res)
      {
         wc = wl_resource_get_client(res);
@@ -98,11 +93,6 @@ _e_keyrouter_wl_key_send(Ecore_Event_Key *ev, E_Device *dev, enum wl_keyboard_ke
         TRACE_INPUT_END();
      }
 
-   if (focused)
-     g_mutex_unlock(&e_comp_wl->kbd.focused_mutex);
-   else
-     g_mutex_unlock(&e_comp_wl->kbd.resource_mutex);
-
    if (e_config->key_input_ttrace_enable)
      {
         TRACE_INPUT_END();