diff --git a/src/bin/e_comp_wl_input.c b/src/bin/e_comp_wl_input.c index 3ff60996a..4b2807e54 100644 --- a/src/bin/e_comp_wl_input.c +++ b/src/bin/e_comp_wl_input.c @@ -8,6 +8,13 @@ E_API int E_EVENT_TEXT_INPUT_PANEL_VISIBILITY_CHANGE = -1; static xkb_keycode_t (*_xkb_keymap_key_by_name)(void *, const char *); +static void _e_comp_wl_input_context_keymap_set(struct xkb_keymap *keymap, struct xkb_context *context); + + +//the following two fields are just set by e_comp_wl_input_keymap_set if it is called before e_comp_wl is valid. +//when then later init is called those two fields are used in the keymap of the e_comp_wl struct +static struct xkb_context *cached_context; +static struct xkb_keymap *cached_keymap; static void _e_comp_wl_input_update_seat_caps(void) @@ -448,6 +455,8 @@ e_comp_wl_input_init(void) _xkb_keymap_key_by_name = dlsym(NULL, "xkb_keymap_key_by_name"); + _e_comp_wl_input_context_keymap_set(cached_keymap, cached_context); + return EINA_TRUE; } @@ -604,10 +613,40 @@ e_comp_wl_input_keyboard_enabled_set(Eina_Bool enabled) _e_comp_wl_input_update_seat_caps(); } +static void +_e_comp_wl_input_context_keymap_set(struct xkb_keymap *keymap, struct xkb_context *context) +{ + if (e_comp_wl) + { + //we have a initializied and running compositor here + if (e_comp_wl->xkb.context) + xkb_context_unref(e_comp_wl->xkb.context); + e_comp_wl->xkb.context = context; + + /* update compositor keymap */ + _e_comp_wl_input_keymap_update(keymap); + } + else + { + //we dont have a running compositor here, cache the values, init will pick them + cached_context = context; + cached_keymap = keymap; + } + +//set the values to the drm devices +#ifdef HAVE_WL_DRM + if (e_config->xkb.use_cache) + ecore_drm_device_keyboard_cached_context_set(context); + if (e_config->xkb.use_cache) + ecore_drm_device_keyboard_cached_keymap_set(keymap); +#endif +} + E_API void e_comp_wl_input_keymap_set(const char *rules, const char *model, const char *layout, const char *variant, const char *options) { struct xkb_keymap *keymap; + struct xkb_context *context; struct xkb_rule_names names; /* DBG("COMP_WL: Keymap Set: %s %s %s", rules, model, layout); */ @@ -630,21 +669,11 @@ e_comp_wl_input_keymap_set(const char *rules, const char *model, const char *lay if (options) names.options = options; else names.options = NULL; - /* unreference any existing context */ - if (e_comp_wl->xkb.context) - xkb_context_unref(e_comp_wl->xkb.context); - - /* create a new xkb context */ - e_comp_wl->xkb.context = xkb_context_new(0); - -#ifdef HAVE_WL_DRM - if (e_config->xkb.use_cache) - ecore_drm_device_keyboard_cached_context_set(e_comp_wl->xkb.context); -#endif + context = xkb_context_new(0); /* fetch new keymap based on names */ - keymap = xkb_map_new_from_names(e_comp_wl->xkb.context, &names, 0); + keymap = xkb_map_new_from_names(context, &names, 0); if (!keymap) { @@ -652,13 +681,7 @@ e_comp_wl_input_keymap_set(const char *rules, const char *model, const char *lay return; } - /* update compositor keymap */ - _e_comp_wl_input_keymap_update(keymap); - -#ifdef HAVE_WL_DRM - if (e_config->xkb.use_cache) - ecore_drm_device_keyboard_cached_keymap_set(keymap); -#endif + _e_comp_wl_input_context_keymap_set(keymap, context); } E_API void