e_input: remove keymap mutex 45/306245/1
authorJihoon Kim <jihoon48.kim@samsung.com>
Fri, 26 Jan 2024 08:06:23 +0000 (17:06 +0900)
committerTizen Window System <tizen.windowsystem@gmail.com>
Mon, 19 Feb 2024 06:32:41 +0000 (15:32 +0900)
Change-Id: I05fd2645cfc8d567aab43eff3e49cf2a929d65c1
Signed-off-by: Jihoon Kim <jihoon48.kim@samsung.com>
16 files changed:
src/bin/e_comp_screen.c
src/bin/e_comp_wl.c
src/bin/e_comp_wl_input.c
src/bin/e_comp_wl_input_intern.h
src/bin/e_devicemgr_input.c
src/bin/e_devicemgr_inputgen.c
src/bin/e_input_device.c
src/bin/e_input_evdev.c
src/bin/e_input_inputs.c
src/bin/e_input_intern.h
src/bin/e_keyrouter.c
src/bin/e_keyrouter_intern.h
src/bin/e_keyrouter_wl.c
src/bin/e_main.c
src/include/e_comp_wl.h
src/include/e_keyrouter.h

index ed5e07b..c483ea2 100644 (file)
@@ -38,9 +38,6 @@ static Eldbus_Service_Interface *e_comp_screen_iface;
 static Eina_List *event_handlers = NULL;
 static Eina_List *output_hooks = NULL;
 
-static Eina_Bool dont_set_e_input_keymap = EINA_FALSE;
-static Eina_Bool dont_use_xkb_cache = EINA_FALSE;
-
 EINTERN int E_EVENT_SCREEN_CHANGE = 0;
 
 enum
@@ -930,58 +927,6 @@ fail:
    return EINA_FALSE;
 }
 
-E_API void
-e_comp_screen_keymap_set(struct xkb_context **ctx, struct xkb_keymap **map)
-{
-   char *keymap_path = NULL;
-   struct xkb_context *context;
-   struct xkb_keymap *keymap;
-   struct xkb_rule_names names = {0,};
-   const char* default_rules, *default_model, *default_layout, *default_variant, *default_options;
-
-   TRACE_INPUT_BEGIN(e_comp_screen_keymap_set);
-
-   context = xkb_context_new(0);
-   EINA_SAFETY_ON_NULL_RETURN(context);
-
-   /* assemble xkb_rule_names so we can fetch keymap */
-   memset(&names, 0, sizeof(names));
-
-   default_rules = e_comp_wl_input_keymap_default_rules_get();
-   default_model = e_comp_wl_input_keymap_default_model_get();
-   default_layout = e_comp_wl_input_keymap_default_layout_get();
-   default_variant = e_comp_wl_input_keymap_default_variant_get();
-   default_options = e_comp_wl_input_keymap_default_options_get();
-
-   names.rules = strdup(default_rules);
-   names.model = strdup(default_model);
-   names.layout = strdup(default_layout);
-   if (default_variant) names.variant = strdup(default_variant);
-   if (default_options) names.options = strdup(default_options);
-
-   keymap = e_comp_wl_input_keymap_compile(context, names, &keymap_path);
-   eina_stringshare_del(keymap_path);
-   EINA_SAFETY_ON_NULL_GOTO(keymap, cleanup);
-
-   *ctx = context;
-   *map = keymap;
-
-   if (dont_set_e_input_keymap == EINA_FALSE)
-     {
-        e_input_device_keyboard_cached_context_set(*ctx);
-        e_input_device_keyboard_cached_keymap_set(*map);
-     }
-
-cleanup:
-   free((char *)names.rules);
-   free((char *)names.model);
-   free((char *)names.layout);
-   if (names.variant) free((char *)names.variant);
-   if (names.options) free((char *)names.options);
-
-   TRACE_INPUT_END();
-}
-
 static void
 _e_comp_screen_e_screen_free(E_Screen *scr)
 {
@@ -1183,23 +1128,10 @@ e_comp_screen_init()
 {
    E_Comp *comp;
    int w, h, ptr_x = 0, ptr_y = 0;
-   struct xkb_context *ctx = NULL;
-   struct xkb_keymap *map = NULL;
 
    if (!(comp = e_comp))
      EINA_SAFETY_ON_NULL_RETURN_VAL(comp, EINA_FALSE);
 
-   /* keymap */
-   dont_set_e_input_keymap = getenv("NO_E_INPUT_KEYMAP_CACHE") ? EINA_TRUE : EINA_FALSE;
-   dont_use_xkb_cache = getenv("NO_KEYMAP_CACHE") ? EINA_TRUE : EINA_FALSE;
-
-   if (e_config->xkb.use_cache && !dont_use_xkb_cache)
-     {
-        e_main_ts_begin("\tDRM Keymap Init");
-        e_comp_screen_keymap_set(&ctx, &map);
-        e_main_ts_end("\tDRM Keymap Init Done");
-     }
-
    e_main_ts_begin("\tE_Comp_Screen_Engine Init");
    if (!_e_comp_screen_engine_init())
      {
@@ -1273,14 +1205,13 @@ e_comp_screen_init()
 
    /* FIXME: This is just for testing at the moment....
     * happens to jive with what drm does */
-   e_main_ts_begin("\tE_Comp_WL Keymap Init");
-   e_comp_wl_input_keymap_set(e_comp_wl_input_keymap_default_rules_get(),
-                              e_comp_wl_input_keymap_default_model_get(),
-                              e_comp_wl_input_keymap_default_layout_get(),
-                              e_comp_wl_input_keymap_default_variant_get(),
-                              e_comp_wl_input_keymap_default_options_get(),
-                              ctx, map);
-   e_main_ts_end("\tE_Comp_WL Keymap Init Done");
+
+   if (!e_input_thread_mode_get())
+     {
+        e_main_ts_begin("\tE_Comp_WL Keymap Init");
+        e_comp_wl_input_keymap_init();
+        e_main_ts_begin("\tE_Comp_WL Keymap Init Done");
+     }
 
    /* try to add tizen_video to wayland globals */
    if (!wl_global_create(e_comp_wl->wl.disp, &tizen_screen_rotation_interface, 1,
@@ -1354,8 +1285,6 @@ e_comp_screen_shutdown()
    e_client_hook_del(tzsr_client_hook_del);
    tzsr_client_hook_del = NULL;
 
-   dont_set_e_input_keymap = EINA_FALSE;
-   dont_use_xkb_cache = EINA_FALSE;
    E_FREE_LIST(event_handlers, ecore_event_handler_del);
 
    /* delete e_comp_sreen */
index 0232c7b..df04d30 100644 (file)
@@ -4723,9 +4723,7 @@ e_comp_wl_key_cancel(E_Client *ec, int keycode, Ecore_Device *dev, uint32_t time
    EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
    EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
 
-   g_mutex_lock(&e_comp_wl->xkb.keymap_mutex);
    keymap = e_comp_wl->xkb.keymap;
-   g_mutex_unlock(&e_comp_wl->xkb.keymap_mutex);
    EINA_SAFETY_ON_NULL_RETURN_VAL(keymap, EINA_FALSE);
 
    struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
index 352c0a6..0018173 100644 (file)
@@ -1300,19 +1300,15 @@ _e_comp_wl_input_keymap_update(struct xkb_keymap *keymap, const char *keymap_pat
    Eina_List *l;
 
    /* unreference any existing keymap */
-   g_mutex_lock(&e_comp_wl->xkb.keymap_mutex);
    if (e_comp_wl->xkb.keymap)
      xkb_map_unref(e_comp_wl->xkb.keymap);
 
-   g_mutex_unlock(&e_comp_wl->xkb.keymap_mutex);
-
    /* unmap any existing keyboard area */
    if (e_comp_wl->xkb.area)
      munmap(e_comp_wl->xkb.area, e_comp_wl->xkb.size);
    if (e_comp_wl->xkb.fd >= 0) close(e_comp_wl->xkb.fd);
 
    /* unreference any existing keyboard state */
-   g_mutex_lock(&e_comp_wl->xkb.state_mutex);
    if (e_comp_wl->xkb.state)
      {
         latched =
@@ -1332,7 +1328,6 @@ _e_comp_wl_input_keymap_update(struct xkb_keymap *keymap, const char *keymap_pat
 
    if (!e_comp_wl->xkb.state)
      {
-        g_mutex_unlock(&e_comp_wl->xkb.state_mutex);
         return;
      }
 
@@ -1340,12 +1335,8 @@ _e_comp_wl_input_keymap_update(struct xkb_keymap *keymap, const char *keymap_pat
      xkb_state_update_mask(e_comp_wl->xkb.state, 0,
                            latched, locked, 0, 0, group);
 
-   g_mutex_unlock(&e_comp_wl->xkb.state_mutex);
-
    /* increment keymap reference */
-   g_mutex_lock(&e_comp_wl->xkb.keymap_mutex);
    e_comp_wl->xkb.keymap = keymap;
-   g_mutex_unlock(&e_comp_wl->xkb.keymap_mutex);
 
    /* fetch updated modifiers */
    e_comp_wl->kbd.mod_shift =
@@ -1421,9 +1412,6 @@ e_comp_wl_input_init(void)
    g_mutex_init(&e_comp_wl->kbd.repeat_delay_mutex);
    g_mutex_init(&e_comp_wl->kbd.repeat_rate_mutex);
 
-   g_mutex_init(&e_comp_wl->xkb.keymap_mutex);
-   g_mutex_init(&e_comp_wl->xkb.state_mutex);
-
    /* get default keyboard repeat delay from configuration */
    atomic_store(&e_comp_wl->kbd.repeat_delay, e_config->keyboard.repeat_delay);
    /* check for valid repeat_delay */
@@ -1563,17 +1551,12 @@ e_comp_wl_input_shutdown(void)
    if (e_comp_wl->xkb.fd >= 0) close(e_comp_wl->xkb.fd);
 
    /* unreference any existing keyboard state */
-   g_mutex_lock(&e_comp_wl->xkb.state_mutex);
    if (e_comp_wl->xkb.state)
      xkb_state_unref(e_comp_wl->xkb.state);
 
-   g_mutex_unlock(&e_comp_wl->xkb.state_mutex);
-
    /* unreference any existing keymap */
-   g_mutex_lock(&e_comp_wl->xkb.keymap_mutex);
    if (e_comp_wl->xkb.keymap)
      xkb_map_unref(e_comp_wl->xkb.keymap);
-   g_mutex_unlock(&e_comp_wl->xkb.keymap_mutex);
 
    /* unreference any existing context */
    if (e_comp_wl->xkb.context)
@@ -1597,9 +1580,6 @@ e_comp_wl_input_shutdown(void)
    dont_set_e_input_keymap = EINA_FALSE;
    dont_use_xkb_cache = EINA_FALSE;
 
-   g_mutex_clear(&e_comp_wl->xkb.keymap_mutex);
-   g_mutex_clear(&e_comp_wl->xkb.state_mutex);
-
    g_mutex_clear(&e_comp_wl->kbd.keys_mutex);
    g_mutex_clear(&e_comp_wl->kbd.repeat_delay_mutex);
    g_mutex_clear(&e_comp_wl->kbd.repeat_rate_mutex);
@@ -1636,8 +1616,6 @@ e_comp_wl_input_keyboard_modifiers_serialize(void)
    xkb_mod_mask_t mod_depressed, mod_latched, mod_locked;
    xkb_layout_index_t mod_group;
 
-   g_mutex_lock(&e_comp_wl->xkb.state_mutex);
-
    mod = xkb_state_serialize_mods(e_comp_wl->xkb.state,
                               XKB_STATE_DEPRESSED);
    mod_depressed = atomic_load(&e_comp_wl->kbd.mod_depressed);
@@ -1663,8 +1641,6 @@ e_comp_wl_input_keyboard_modifiers_serialize(void)
    changed |= grp != mod_group;
    atomic_store(&e_comp_wl->kbd.mod_group, grp);
 
-   g_mutex_unlock(&e_comp_wl->xkb.state_mutex);
-
    return changed;
 }
 
@@ -1701,10 +1677,8 @@ e_comp_wl_input_keyboard_state_update(uint32_t keycode, Eina_Bool pressed)
 {
    enum xkb_key_direction dir;
 
-   g_mutex_lock(&e_comp_wl->xkb.state_mutex);
    if (!e_comp_wl->xkb.state)
      {
-        g_mutex_unlock(&e_comp_wl->xkb.state_mutex);
         return;
      }
 
@@ -1713,8 +1687,6 @@ e_comp_wl_input_keyboard_state_update(uint32_t keycode, Eina_Bool pressed)
 
    atomic_store(&e_comp_wl->kbd.mod_changed, xkb_state_update_key(e_comp_wl->xkb.state, keycode + 8, dir));
 
-   g_mutex_unlock(&e_comp_wl->xkb.state_mutex);
-
    e_comp_wl_input_keyboard_modifiers_update();
 }
 
@@ -2085,9 +2057,7 @@ e_comp_wl_input_keymap_keyname_to_keycode(const char * name)
    EINA_SAFETY_ON_NULL_RETURN_VAL(name, 0);
    EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, 0);
 
-   g_mutex_lock(&e_comp_wl->xkb.keymap_mutex);
    keymap = e_comp_wl->xkb.keymap;
-   g_mutex_unlock(&e_comp_wl->xkb.keymap_mutex);
    EINA_SAFETY_ON_NULL_GOTO(keymap, finish);
 
    keysym = xkb_keysym_from_name(name, XKB_KEYSYM_NO_FLAGS);
@@ -2124,17 +2094,14 @@ e_comp_wl_input_keymap_keycode_to_keyname(int keycode)
 
    EINA_SAFETY_ON_FALSE_RETURN_VAL(8 <= keycode, NULL);
    EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, NULL);
-   g_mutex_lock(&e_comp_wl->xkb.state_mutex);
    if (!e_comp_wl->xkb.state)
      {
-        g_mutex_unlock(&e_comp_wl->xkb.state_mutex);
         return NULL;
      }
 
    state = e_comp_wl->xkb.state;
 
    sym = xkb_state_key_get_one_sym(state, keycode);
-   g_mutex_unlock(&e_comp_wl->xkb.state_mutex);
 
    if (sym == XKB_KEY_NoSymbol)
      {
@@ -2146,8 +2113,83 @@ e_comp_wl_input_keymap_keycode_to_keyname(int keycode)
    return strdup(name);
 }
 
+static void
+_e_comp_wl_input_keymap_set(struct xkb_context **ctx, struct xkb_keymap **map)
+{
+   char *keymap_path = NULL;
+   struct xkb_context *context;
+   struct xkb_keymap *keymap;
+   struct xkb_rule_names names = {0,};
+   const char* default_rules, *default_model, *default_layout, *default_variant, *default_options;
+
+   TRACE_INPUT_BEGIN(_e_comp_wl_input_keymap_set);
+
+   context = xkb_context_new(0);
+   EINA_SAFETY_ON_NULL_RETURN(context);
+
+   /* assemble xkb_rule_names so we can fetch keymap */
+   memset(&names, 0, sizeof(names));
+
+   default_rules = e_comp_wl_input_keymap_default_rules_get();
+   default_model = e_comp_wl_input_keymap_default_model_get();
+   default_layout = e_comp_wl_input_keymap_default_layout_get();
+   default_variant = e_comp_wl_input_keymap_default_variant_get();
+   default_options = e_comp_wl_input_keymap_default_options_get();
+
+   names.rules = strdup(default_rules);
+   names.model = strdup(default_model);
+   names.layout = strdup(default_layout);
+   if (default_variant) names.variant = strdup(default_variant);
+   if (default_options) names.options = strdup(default_options);
+
+   keymap = e_comp_wl_input_keymap_compile(context, names, &keymap_path);
+   eina_stringshare_del(keymap_path);
+   EINA_SAFETY_ON_NULL_GOTO(keymap, cleanup);
+
+   *ctx = context;
+   *map = keymap;
+
+   if (dont_set_e_input_keymap == EINA_FALSE)
+     {
+        e_input_device_keyboard_cached_context_set(*ctx);
+        e_input_device_keyboard_cached_keymap_set(*map);
+     }
+
+cleanup:
+   free((char *)names.rules);
+   free((char *)names.model);
+   free((char *)names.layout);
+   if (names.variant) free((char *)names.variant);
+   if (names.options) free((char *)names.options);
+
+   TRACE_INPUT_END();
+}
+
 E_API Eina_Bool
 e_comp_wl_input_pointer_constraint_activated_get(void)
 {
    return e_comp_wl->ptr_constraints.activated;
 }
+
+EINTERN void
+e_comp_wl_input_keymap_init(void)
+{
+   struct xkb_context *ctx = NULL;
+   struct xkb_keymap *map = NULL;
+
+   /* keymap */
+   dont_set_e_input_keymap = getenv("NO_E_INPUT_KEYMAP_CACHE") ? EINA_TRUE : EINA_FALSE;
+   dont_use_xkb_cache = getenv("NO_KEYMAP_CACHE") ? EINA_TRUE : EINA_FALSE;
+
+   if (e_config->xkb.use_cache && !dont_use_xkb_cache)
+     {
+        _e_comp_wl_input_keymap_set(&ctx, &map);
+     }
+
+   e_comp_wl_input_keymap_set(e_comp_wl_input_keymap_default_rules_get(),
+                              e_comp_wl_input_keymap_default_model_get(),
+                              e_comp_wl_input_keymap_default_layout_get(),
+                              e_comp_wl_input_keymap_default_variant_get(),
+                              e_comp_wl_input_keymap_default_options_get(),
+                              ctx, map);
+}
\ No newline at end of file
index 8f362f7..2449594 100644 (file)
@@ -31,4 +31,5 @@ EINTERN const char        *e_comp_wl_input_keymap_default_variant_get(void);
 EINTERN const char        *e_comp_wl_input_keymap_default_options_get(void);
 EINTERN char              *e_comp_wl_input_keymap_keycode_to_keyname(int keycode);
 
+EINTERN void e_comp_wl_input_keymap_init(void);
 #endif
index 06ff2dc..538e5d1 100644 (file)
@@ -162,9 +162,7 @@ _e_devicemgr_input_mouse_button_remap(Ecore_Event_Mouse_Button *ev, Eina_Bool pr
    E_Keyrouter_Event_Data *key_data;
    struct xkb_keymap *keymap = NULL;
 
-   g_mutex_lock(&e_comp_wl->xkb.keymap_mutex);
    keymap = e_comp_wl->xkb.keymap;
-   g_mutex_unlock(&e_comp_wl->xkb.keymap_mutex);
 
    EINA_SAFETY_ON_NULL_RETURN_VAL(keymap, ECORE_CALLBACK_PASS_ON);
    EINA_SAFETY_ON_NULL_RETURN_VAL(ev, ECORE_CALLBACK_PASS_ON);
index a8252ed..deb5fb1 100644 (file)
@@ -1085,14 +1085,11 @@ e_devicemgr_inputgen_generate_key(struct wl_client *client, struct wl_resource *
         return TIZEN_INPUT_DEVICE_MANAGER_ERROR_INVALID_PARAMETER;
      }
 
-   g_mutex_lock(&e_comp_wl->xkb.keymap_mutex);
    if (!e_comp_wl->xkb.keymap)
      {
         DMWRN("keymap is not ready\n");
-        g_mutex_unlock(&e_comp_wl->xkb.keymap_mutex);
         return TIZEN_INPUT_DEVICE_MANAGER_ERROR_INVALID_PARAMETER;
      }
-   g_mutex_unlock(&e_comp_wl->xkb.keymap_mutex);
 
    EINA_LIST_FOREACH(e_devicemgr->inputgen.kbd_list, l, ddata)
      {
index 3437673..df1e0f5 100644 (file)
@@ -120,15 +120,11 @@ _e_input_device_cached_keymap_update(struct xkb_keymap *map)
      EINA_LIST_FOREACH(dev->seats, l2, seat)
        EINA_LIST_FOREACH(e_input_seat_evdev_list_get(seat), l3, edev)
          {
-            g_mutex_lock(&edev->xkb.keymap_mutex);
             xkb_keymap_unref(edev->xkb.keymap);
             edev->xkb.keymap = xkb_keymap_ref(map);
-            g_mutex_unlock(&edev->xkb.keymap_mutex);
 
-            g_mutex_lock(&edev->xkb.state_mutex);
             xkb_state_unref(edev->xkb.state);
             edev->xkb.state = xkb_state_new(map);
-            g_mutex_unlock(&edev->xkb.state_mutex);
          }
 }
 
@@ -900,7 +896,7 @@ e_input_device_input_create_libinput_udev(E_Input_Device *dev)
 
    if (e_input_thread_mode_get())
      {
-        e_input_thread_run(input);
+        e_input_thread_input_backend_set(input);
         return EINA_TRUE;
      }
 
index b313af1..51ac5cc 100644 (file)
@@ -218,31 +218,21 @@ _device_keyboard_setup(E_Input_Evdev *edev)
    if (!(input = edev->seat->input)) return;
    if (!input->dev->xkb_ctx) return;
 
-   g_mutex_init(&edev->xkb.keymap_mutex);
-
    /* create keymap from xkb context */
-   g_mutex_lock(&edev->xkb.keymap_mutex);
    edev->xkb.keymap = _e_input_device_cached_keymap_get(input->dev->xkb_ctx, NULL, 0);
    if (!edev->xkb.keymap)
      {
-        g_mutex_unlock(&edev->xkb.keymap_mutex);
         ERR("Failed to create keymap: %m");
         return;
      }
 
-   g_mutex_lock(&edev->xkb.state_mutex);
-
    /* create xkb state */
    if (!(edev->xkb.state = xkb_state_new(edev->xkb.keymap)))
      {
-        g_mutex_unlock(&edev->xkb.state_mutex);
-        g_mutex_unlock(&edev->xkb.keymap_mutex);
         ERR("Failed to create xkb state: %m");
         return;
      }
 
-   g_mutex_unlock(&edev->xkb.state_mutex);
-
    xkb_idx = xkb_map_mod_get_index(edev->xkb.keymap, XKB_MOD_NAME_CTRL);
    if (xkb_idx != XKB_MOD_INVALID)
      edev->xkb.ctrl_mask = 1 << xkb_idx;
@@ -290,8 +280,6 @@ _device_keyboard_setup(E_Input_Evdev *edev)
      edev->xkb.altgr_mask = 1 << xkb_idx;
    else
      edev->xkb.altgr_mask = 0;
-
-   g_mutex_unlock(&edev->xkb.keymap_mutex);
 }
 
 static int
@@ -343,8 +331,6 @@ _device_modifiers_update_device(E_Input_Evdev *edev, E_Input_Evdev *from)
 {
    xkb_mod_mask_t mask;
 
-   g_mutex_lock(&from->xkb.state_mutex);
-
    edev->xkb.depressed =
      xkb_state_serialize_mods(from->xkb.state, XKB_STATE_DEPRESSED);
    edev->xkb.latched =
@@ -354,8 +340,6 @@ _device_modifiers_update_device(E_Input_Evdev *edev, E_Input_Evdev *from)
    edev->xkb.group =
      xkb_state_serialize_mods(from->xkb.state, XKB_STATE_EFFECTIVE);
 
-   g_mutex_unlock(&from->xkb.state_mutex);
-
    mask = (edev->xkb.depressed | edev->xkb.latched);
 
    if (mask & from->xkb.ctrl_mask)
@@ -704,13 +688,11 @@ _device_handle_key(struct libinput_device *device, struct libinput_event_keyboar
           }
      }
 
-   g_mutex_lock(&edev->xkb.state_mutex);
    xkb_state_update_key(edev->xkb.state, code,
                         (state ? XKB_KEY_DOWN : XKB_KEY_UP));
 
    /* get the keysym for this code */
    nsyms = xkb_key_get_syms(edev->xkb.state, code, &syms);
-   g_mutex_unlock(&edev->xkb.state_mutex);
 
    if (nsyms == 1) sym = syms[0];
 
@@ -734,8 +716,6 @@ _device_handle_key(struct libinput_device *device, struct libinput_event_keyboar
      }
 
    /* if shift is active, we need to transform the key to lower */
-   g_mutex_lock(&edev->xkb.keymap_mutex);
-   g_mutex_lock(&edev->xkb.state_mutex);
    if (xkb_state_mod_index_is_active(edev->xkb.state,
                                      xkb_map_mod_get_index(edev->xkb.keymap,
                                      XKB_MOD_NAME_SHIFT),
@@ -744,8 +724,6 @@ _device_handle_key(struct libinput_device *device, struct libinput_event_keyboar
         if (keyname[0] != '\0')
           keyname[0] = tolower(keyname[0]);
      }
-   g_mutex_unlock(&edev->xkb.keymap_mutex);
-   g_mutex_unlock(&edev->xkb.state_mutex);
 
    if (_device_keysym_translate(sym, edev->xkb.modifiers,
                                 compose_buffer, sizeof(compose_buffer)))
@@ -2376,13 +2354,9 @@ _e_input_evdev_device_destroy(E_Input_Evdev *edev)
 
    if (edev->caps & E_INPUT_SEAT_KEYBOARD)
      {
-        g_mutex_lock(&edev->xkb.state_mutex);
         if (edev->xkb.state) xkb_state_unref(edev->xkb.state);
-        g_mutex_unlock(&edev->xkb.state_mutex);
 
-        g_mutex_lock(&edev->xkb.keymap_mutex);
         if (edev->xkb.keymap) xkb_map_unref(edev->xkb.keymap);
-        g_mutex_unlock(&edev->xkb.keymap_mutex);
      }
 
    if (edev->ecore_dev) ecore_device_del(edev->ecore_dev);
index 4d742ec..7e73090 100644 (file)
@@ -6,12 +6,14 @@
 #include "e_comp_wl_intern.h"
 #include "e_config_intern.h"
 #include "e_device_intern.h"
+#include "e_comp_wl_input_intern.h"
 
 #include <glib.h>
 
 static gboolean input_dispatch(GSource *source, GSourceFunc callback, gpointer user_data);
 static gboolean input_thread_prepare(GSource *source, gint *time);
 
+static E_Input_Backend *g_input_backend = NULL;
 static E_Input_Event_Source *g_input_event_source = NULL;
 static GList *_key_event_list = NULL;
 
@@ -816,6 +818,9 @@ input_thread_start(void *data, Ecore_Thread *th)
    g_source_set_callback(&input_event_source->gsource, NULL, input, NULL);
    g_source_attach(&input_event_source->gsource, context);
 
+   e_comp_wl_input_keymap_init();
+   e_keyrouter_query_tizen_key_table();
+
    e_keyrouter_input_handler_add();
 
    e_input_thread_id_set(gettid());
@@ -986,7 +991,14 @@ e_input_create_event_source(E_Input_Backend *input)
    g_input_event_source = input->event_source;
 }
 
-EINTERN void e_input_thread_run(E_Input_Backend *input)
+EINTERN void e_input_thread_start()
+{
+   EINA_SAFETY_ON_NULL_RETURN(g_input_backend);
+
+   g_input_backend->input_thread = ecore_thread_feedback_run(input_thread_start, input_thread_feedback, input_thread_end, input_thread_cancel, g_input_backend, EINA_FALSE);
+}
+
+EINTERN void e_input_thread_input_backend_set(E_Input_Backend *input)
 {
-   input->input_thread = ecore_thread_feedback_run(input_thread_start, input_thread_feedback, input_thread_end, input_thread_cancel, input, EINA_FALSE);
+   g_input_backend = input;
 }
index 9383782..13ff66b 100644 (file)
@@ -111,8 +111,8 @@ struct _E_Input_Evdev
         unsigned int depressed, latched, locked, group;
 
         Eina_List *pressed_keys;
-        GMutex keymap_mutex;
-        GMutex state_mutex;
+        EINA_DEPRECATED GMutex keymap_mutex;
+        EINA_DEPRECATED GMutex state_mutex;
      } xkb;
 
      Eina_Hash *key_remap_hash;
@@ -213,7 +213,8 @@ EINTERN void e_input_boost_lock(GMutex *mutex);
 EINTERN void e_input_boost_unlock(GMutex *mutex);
 
 EINTERN void e_input_thread_id_set(pid_t tid);
-EINTERN void e_input_thread_run(E_Input_Backend *input);
+EINTERN void e_input_thread_start();
+EINTERN void e_input_thread_input_backend_set(E_Input_Backend *input);
 
 EINTERN void e_input_device_output_changed(E_Input_Device *dev);
 
index a8a55b8..c60ab38 100644 (file)
@@ -382,8 +382,6 @@ _e_keyrouter_deinit_handlers(void)
         input_event_source = e_input_event_source_get();
         if (input_event_source)
           {
-             g_mutex_clear(&krt->event_handler_mutex);
-
              if (krt->_key_down_handler)
                e_input_event_handler_del(input_event_source, krt->_key_down_handler);
 
@@ -399,8 +397,8 @@ _e_keyrouter_deinit_handlers(void)
    e_info_server_hook_set("keygrab", NULL, NULL);
 }
 
-static Eina_Bool
-_e_keyrouter_query_tizen_key_table(void)
+EINTERN Eina_Bool
+e_keyrouter_query_tizen_key_table(void)
 {
    E_Keyrouter_Conf_Edd *kconf = krt->conf->conf;
    Eina_List *l;
@@ -440,9 +438,7 @@ _e_keyrouter_query_tizen_key_table(void)
           {
              if (krt->HardKeys[data->keycode].repeat == EINA_FALSE)
                {
-                  g_mutex_lock(&e_comp_wl->xkb.keymap_mutex);
                   res = xkb_keymap_key_set_repeats(e_comp_wl->xkb.keymap, data->keycode, 0);
-                  g_mutex_unlock(&e_comp_wl->xkb.keymap_mutex);
                   if (!res)
                     {
                        KLWRN("Failed to set repeat key(%d), value(%d)", data->keycode, 0);
@@ -458,9 +454,7 @@ _e_keyrouter_query_tizen_key_table(void)
         KLINF("Server create a new cache file: %s", e_comp_wl_input_keymap_path_get(names));
         res = unlink(e_comp_wl_input_keymap_path_get(names));
 
-        g_mutex_lock(&e_comp_wl->xkb.keymap_mutex);
         e_comp_wl_input_keymap_set(NULL, NULL, NULL, NULL, NULL, xkb_context_ref(e_comp_wl->xkb.context), xkb_keymap_ref(e_comp_wl->xkb.keymap));
-        g_mutex_unlock(&e_comp_wl->xkb.keymap_mutex);
      }
    else
      KLINF("Currently cache file is exist. Do not change it.");
@@ -639,15 +633,11 @@ e_keyrouter_input_handler_add(void)
          return;
       }
 
-   g_mutex_lock(&krt->event_handler_mutex);
-
    if (!krt->_key_down_handler)
      krt->_key_down_handler = e_input_event_handler_add(input_event_source, ECORE_EVENT_KEY_DOWN, _e_keyrouter_cb_key_down, NULL);
 
    if (!krt->_key_up_handler)
      krt->_key_up_handler = e_input_event_handler_add(input_event_source, ECORE_EVENT_KEY_UP, _e_keyrouter_cb_key_up, NULL);
-
-   g_mutex_unlock(&krt->event_handler_mutex);
 }
 
 EINTERN int
@@ -667,9 +657,6 @@ e_keyrouter_init(void)
    krt = E_NEW(E_Keyrouter, 1);
    EINA_SAFETY_ON_NULL_GOTO(krt, err);
 
-   if (e_input_thread_mode_get())
-     g_mutex_init(&krt->event_handler_mutex);
-
    g_rec_mutex_init(&krt->grab_key_mutex);
 
    kconfig = E_NEW(E_Keyrouter_Config_Data, 1);
@@ -686,8 +673,11 @@ e_keyrouter_init(void)
    EINA_SAFETY_ON_FALSE_GOTO(res, err);
 
    /* Get keyname and keycode pair from Tizen Key Layout file */
-   res = _e_keyrouter_query_tizen_key_table();
-   EINA_SAFETY_ON_FALSE_GOTO(res, err);
+   if (!e_input_thread_mode_get())
+     {
+        res = e_keyrouter_query_tizen_key_table();
+        EINA_SAFETY_ON_FALSE_GOTO(res, err);
+     }
 
    //ecore handler add for power callback registration
 //   if (!krt->pictureoff_disabled)
index 8335b77..553e858 100644 (file)
@@ -28,4 +28,6 @@ EINTERN void e_keyrouter_event_surface_send(E_Client *ec, int key);
 
 EINTERN void e_keyrouter_input_handler_add(void);
 
+EINTERN Eina_Bool e_keyrouter_query_tizen_key_table(void);
+
 #endif
index 26f5786..e0cd239 100644 (file)
@@ -655,6 +655,7 @@ e_keyrouter_wl_init(void)
    int ret;
 
    EINA_SAFETY_ON_NULL_RETURN_VAL(krt, EINA_FALSE);
+   EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp, EINA_FALSE);
 
    krt->global = wl_global_create(e_comp_wl->wl.disp, &tizen_keyrouter_interface, 2, krt, _e_keyrouter_cb_bind);
    EINA_SAFETY_ON_NULL_RETURN_VAL(krt->global, EINA_FALSE);
index a458831..c55f7dd 100644 (file)
@@ -33,6 +33,7 @@
 #include "e_desk_intern.h"
 #include "e_zone_intern.h"
 #include "e_eom_intern.h"
+#include "e_input_intern.h"
 
 #include <Eio.h>
 
@@ -682,6 +683,9 @@ main(int argc, char **argv)
    TSE("E_Keyrouter Init Done");
    _e_main_shutdown_push(e_keyrouter_shutdown);
 
+   if (e_input_thread_mode_get())
+     e_input_thread_start();
+
    if (e_config->eom_enable)
      {
         TSB("Eom Init");
index c09212f..d875bb5 100644 (file)
@@ -352,8 +352,8 @@ struct _E_Comp_Wl_Data
         int fd;
         size_t size;
         char *area;
-        GMutex keymap_mutex;
-        GMutex state_mutex;
+        EINA_DEPRECATED GMutex keymap_mutex;
+        EINA_DEPRECATED GMutex state_mutex;
      } xkb;
 
    struct
index e148590..b62a762 100644 (file)
@@ -106,7 +106,7 @@ struct _E_Keyrouter
 
    E_Input_Event_Handler *_key_down_handler;
    E_Input_Event_Handler *_key_up_handler;
-   GMutex event_handler_mutex;
+   EINA_DEPRECATED GMutex event_handler_mutex;
    GRecMutex grab_key_mutex;
 };