diff --git a/config/default/e.src b/config/default/e.src index b7cb8359b..6c601c5d3 100644 --- a/config/default/e.src +++ b/config/default/e.src @@ -215,6 +215,7 @@ group "E_Config" struct { value "update.later" uchar: 0; value "xkb.only_label" int: 0; value "xkb.default_model" string: "default"; + value "xkb.use_cache" uchar: 0; value "keyboard.repeat_delay" int: 400; value "keyboard.repeat_rate" int: 25; value "exe_always_single_instance" uchar: 0; diff --git a/config/mobile/e.src b/config/mobile/e.src index 1431dde33..251632d0c 100644 --- a/config/mobile/e.src +++ b/config/mobile/e.src @@ -865,6 +865,7 @@ group "E_Config" struct { } value "xkb.only_label" int: 0; value "xkb.default_model" string: "default"; + value "xkb.use_cache" uchar: 0; value "keyboard.repeat_delay" int: 400; value "keyboard.repeat_rate" int: 25; value "exe_always_single_instance" uchar: 1; diff --git a/config/standard/e.src b/config/standard/e.src index b41057cc6..f43f1933a 100644 --- a/config/standard/e.src +++ b/config/standard/e.src @@ -1106,6 +1106,7 @@ group "E_Config" struct { } value "xkb.only_label" int: 0; value "xkb.default_model" string: "default"; + value "xkb.use_cache" uchar: 0; value "keyboard.repeat_delay" int: 400; value "keyboard.repeat_rate" int: 25; value "exe_always_single_instance" uchar: 0; diff --git a/config/tiling/e.src b/config/tiling/e.src index afeac1fb3..eff658c80 100644 --- a/config/tiling/e.src +++ b/config/tiling/e.src @@ -1128,6 +1128,7 @@ group "E_Config" struct { } value "xkb.only_label" int: 0; value "xkb.default_model" string: "default"; + value "xkb.use_cache" uchar: 0; value "keyboard.repeat_delay" int: 400; value "keyboard.repeat_rate" int: 25; value "exe_always_single_instance" uchar: 0; diff --git a/src/bin/e_comp_wl.c b/src/bin/e_comp_wl.c index bcfb60d31..454ed69da 100644 --- a/src/bin/e_comp_wl.c +++ b/src/bin/e_comp_wl.c @@ -2655,7 +2655,7 @@ _e_comp_wl_compositor_create(void) if (!layout) layout = strdup("us"); /* update compositor keymap */ - e_comp_wl_input_keymap_set(rules, model, layout); + e_comp_wl_input_keymap_set(rules, model, layout, NULL, NULL); } #endif e_comp_wl->wl.client_disp = ecore_wl2_display_connect(NULL); diff --git a/src/bin/e_comp_wl_input.c b/src/bin/e_comp_wl_input.c index 79f75d421..3e80cb82b 100644 --- a/src/bin/e_comp_wl_input.c +++ b/src/bin/e_comp_wl_input.c @@ -2,6 +2,9 @@ #define E_COMP_WL #include "e.h" #include +#ifdef HAVE_WL_DRM +#include +#endif E_API int E_EVENT_TEXT_INPUT_PANEL_VISIBILITY_CHANGE = -1; @@ -586,41 +589,62 @@ e_comp_wl_input_keyboard_enabled_set(Eina_Bool enabled) } E_API void -e_comp_wl_input_keymap_set(const char *rules, const char *model, const char *layout) +e_comp_wl_input_keymap_set(const char *rules, const char *model, const char *layout, struct xkb_context *dflt_ctx, struct xkb_keymap *dflt_map) { struct xkb_keymap *keymap; struct xkb_rule_names names; + Eina_Bool use_dflt_xkb = EINA_FALSE; /* DBG("COMP_WL: Keymap Set: %s %s %s", rules, model, layout); */ + if (dflt_ctx && dflt_map) use_dflt_xkb = EINA_TRUE; + /* assemble xkb_rule_names so we can fetch keymap */ - memset(&names, 0, sizeof(names)); - if (rules) names.rules = strdup(rules); - else names.rules = strdup("evdev"); - if (model) names.model = strdup(model); - else names.model = strdup("pc105"); - if (layout) names.layout = strdup(layout); - else names.layout = strdup("us"); + if (!use_dflt_xkb) + { + memset(&names, 0, sizeof(names)); + if (rules) names.rules = strdup(rules); + else names.rules = strdup("evdev"); + if (model) names.model = strdup(model); + else names.model = strdup("pc105"); + if (layout) names.layout = strdup(layout); + else names.layout = strdup("us"); + } /* 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); + if (use_dflt_xkb) e_comp_wl->xkb.context = dflt_ctx; + else 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 /* fetch new keymap based on names */ - keymap = xkb_map_new_from_names(e_comp_wl->xkb.context, &names, 0); + if (use_dflt_xkb) keymap = dflt_map; + else keymap = xkb_map_new_from_names(e_comp_wl->xkb.context, &names, 0); if (keymap) { /* 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 + /* cleanup */ - free((char *)names.rules); - free((char *)names.model); - free((char *)names.layout); + if (!use_dflt_xkb) + { + free((char *)names.rules); + free((char *)names.model); + free((char *)names.layout); + } } E_API void diff --git a/src/bin/e_comp_wl_input.h b/src/bin/e_comp_wl_input.h index a9bc9d44d..f13d0a151 100644 --- a/src/bin/e_comp_wl_input.h +++ b/src/bin/e_comp_wl_input.h @@ -29,7 +29,8 @@ E_API void e_comp_wl_input_pointer_enabled_set(Eina_Bool enabled); E_API void e_comp_wl_input_keyboard_enabled_set(Eina_Bool enabled); E_API void e_comp_wl_input_touch_enabled_set(Eina_Bool enabled); -E_API void e_comp_wl_input_keymap_set(const char *rules, const char *model, const char *layout); +E_API void e_comp_wl_input_keymap_set(const char *rules, const char *model, const char *layout, + struct xkb_context *dflt_ctx, struct xkb_keymap *dflt_map); # endif #endif diff --git a/src/bin/e_config.c b/src/bin/e_config.c index a24f448fa..7d94141b9 100644 --- a/src/bin/e_config.c +++ b/src/bin/e_config.c @@ -752,6 +752,7 @@ _e_config_edd_init(Eina_Bool old) E_CONFIG_VAL(D, T, xkb.only_label, INT); E_CONFIG_VAL(D, T, xkb.dont_touch_my_damn_keyboard, UCHAR); E_CONFIG_VAL(D, T, xkb.default_model, STR); + E_CONFIG_VAL(D, T, xkb.use_cache, UCHAR); E_CONFIG_VAL(D, T, keyboard.repeat_delay, INT); E_CONFIG_VAL(D, T, keyboard.repeat_rate, INT); diff --git a/src/bin/e_config.h b/src/bin/e_config.h index a2f9a7a43..a3a65cce7 100644 --- a/src/bin/e_config.h +++ b/src/bin/e_config.h @@ -428,6 +428,7 @@ struct _E_Config const char *cur_layout; // whatever the current layout is const char *selected_layout; // whatever teh current layout that the user has selected is const char *desklock_layout; + Eina_Bool use_cache; } xkb; struct diff --git a/src/modules/wl_drm/e_mod_main.c b/src/modules/wl_drm/e_mod_main.c index 7a9f6aaab..9277d52b6 100644 --- a/src/modules/wl_drm/e_mod_main.c +++ b/src/modules/wl_drm/e_mod_main.c @@ -668,10 +668,32 @@ _drm_read_pixels(E_Comp_Wl_Output *output, void *pixels) } } +static void +_e_mod_drm_keymap_set(struct xkb_context *ctx, struct xkb_keymap *map) +{ + struct xkb_rule_names names; + + ctx = xkb_context_new(0); + EINA_SAFETY_ON_NULL_RETURN(ctx); + + memset(&names, 0, sizeof(names)); + names.rules = strdup("evdev"); + names.model = strdup("pc105"); + names.layout = strdup("us"); + + map = xkb_map_new_from_names(ctx, &names, 0); + EINA_SAFETY_ON_NULL_RETURN(map); + + ecore_drm_device_keyboard_cached_context_set(ctx); + ecore_drm_device_keyboard_cached_keymap_set(map); +} + E_API void * e_modapi_init(E_Module *m) { int w = 0, h = 0; + struct xkb_context *ctx = NULL; + struct xkb_keymap *map = NULL; printf("LOAD WL_DRM MODULE\n"); @@ -682,6 +704,8 @@ e_modapi_init(E_Module *m) /* return NULL; */ /* } */ + _e_mod_drm_keymap_set(ctx, map); + if (e_comp_config_get()->engine == E_COMP_ENGINE_GL) { e_comp->ee = ecore_evas_new("gl_drm", 0, 0, 1, 1, NULL); @@ -743,7 +767,7 @@ e_modapi_init(E_Module *m) /* FIXME: This is just for testing at the moment.... * happens to jive with what drm does */ - e_comp_wl_input_keymap_set(NULL, NULL, NULL); + e_comp_wl_input_keymap_set(NULL, NULL, NULL, ctx, map); activate_handler = ecore_event_handler_add(ECORE_DRM_EVENT_ACTIVATE, diff --git a/src/modules/wl_wl/e_mod_main.c b/src/modules/wl_wl/e_mod_main.c index 5cc0aaa4a..35bac199b 100644 --- a/src/modules/wl_wl/e_mod_main.c +++ b/src/modules/wl_wl/e_mod_main.c @@ -58,7 +58,7 @@ e_modapi_init(E_Module *m) e_comp->pointer = e_pointer_canvas_new(e_comp->ee, EINA_TRUE); e_comp->pointer->color = EINA_TRUE; - e_comp_wl_input_keymap_set(NULL, NULL, NULL); + e_comp_wl_input_keymap_set(NULL, NULL, NULL, NULL, NULL); wl_wl_init(); return m; diff --git a/src/modules/wl_x11/e_mod_main.c b/src/modules/wl_x11/e_mod_main.c index 1d8d94087..c38694e34 100644 --- a/src/modules/wl_x11/e_mod_main.c +++ b/src/modules/wl_x11/e_mod_main.c @@ -50,7 +50,7 @@ _cb_keymap_changed(void *data EINA_UNUSED, int type EINA_UNUSED, void *event EIN if (!layout) layout = strdup("us"); /* update compositor keymap */ - e_comp_wl_input_keymap_set(rules, model, layout); + e_comp_wl_input_keymap_set(rules, model, layout, NULL, NULL); free(rules); free(model);