e_comp_wl: allow variants and options for keyboard settings

Also set options and variants to the rule names struct.
There is no need to use strdup here the values are just freed in the
end.
This commit is contained in:
Marcel Hollerbach 2016-01-26 00:26:34 +01:00
parent 3677ff12f9
commit ab4e4e17cb
5 changed files with 28 additions and 22 deletions

View File

@ -2429,7 +2429,7 @@ _e_comp_wl_compositor_create(void)
if (!layout) layout = strdup("us");
/* update compositor keymap */
e_comp_wl_input_keymap_set(rules, model, layout, NULL, NULL);
e_comp_wl_input_keymap_set(rules, model, layout, NULL, NULL, NULL, NULL);
}
#endif
e_comp_wl->wl.client_disp = ecore_wl2_display_connect(NULL);

View File

@ -605,7 +605,7 @@ 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, struct xkb_context *dflt_ctx, struct xkb_keymap *dflt_map)
e_comp_wl_input_keymap_set(const char *rules, const char *model, const char *layout, const char *variant, const char *options, struct xkb_context *dflt_ctx, struct xkb_keymap *dflt_map)
{
struct xkb_keymap *keymap;
struct xkb_rule_names names;
@ -619,18 +619,28 @@ e_comp_wl_input_keymap_set(const char *rules, const char *model, const char *lay
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");
if (rules) names.rules = rules;
else names.rules = "evdev";
if (model) names.model = model;
else names.model = "pc105";
if (layout) names.layout = layout;
else names.layout = "us";
if (variant) names.variant = variant;
else names.variant = NULL;
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 */
if (use_dflt_xkb) e_comp_wl->xkb.context = dflt_ctx;
else e_comp_wl->xkb.context = xkb_context_new(0);
@ -643,24 +653,20 @@ e_comp_wl_input_keymap_set(const char *rules, const char *model, const char *lay
/* fetch new keymap based on names */
if (use_dflt_xkb) keymap = dflt_map;
else keymap = xkb_map_new_from_names(e_comp_wl->xkb.context, &names, 0);
if (keymap)
if (!keymap)
{
/* update compositor keymap */
_e_comp_wl_input_keymap_update(keymap);
ERR("Failed to compile keymap");
NULL;
}
/* 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 */
if (!use_dflt_xkb)
{
free((char *)names.rules);
free((char *)names.model);
free((char *)names.layout);
}
}
E_API void

View File

@ -29,7 +29,7 @@ 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, const char *variant, const char *options,
struct xkb_context *dflt_ctx, struct xkb_keymap *dflt_map);
E_API void e_comp_wl_input_keyboard_event_generate(const char *key, int mods, Eina_Bool up);

View File

@ -790,7 +790,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, ctx, map);
e_comp_wl_input_keymap_set(NULL, NULL, NULL, NULL, NULL, ctx, map);
activate_handler =
ecore_event_handler_add(ECORE_DRM_EVENT_ACTIVATE,

View File

@ -72,7 +72,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, NULL, NULL);
e_comp_wl_input_keymap_set(NULL, NULL, NULL, NULL, NULL, NULL, NULL);
ecore_evas_pointer_xy_get(e_comp->ee, &e_comp_wl->ptr.x,
&e_comp_wl->ptr.y);