e-comp-wl: Don't crash from a missing keymap

This fixes T2531 where E would crash if the keymap could not be
fetched from xkb. Now if no keymap rules, model, or layout are passed
in we will default to a US keymap.

Signed-off-by: Chris Michael <cp.michael@samsung.com>
This commit is contained in:
Chris Michael 2015-06-30 09:10:54 -04:00
parent 8bbbd7a951
commit 1c59062cda
1 changed files with 8 additions and 3 deletions

View File

@ -541,8 +541,11 @@ e_comp_wl_input_keymap_set(const char *rules, const char *model, const char *lay
/* 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");
/* unreference any existing context */
if (e_comp->wl_comp_data->xkb.context) xkb_context_unref(e_comp->wl_comp_data->xkb.context);
@ -552,9 +555,11 @@ e_comp_wl_input_keymap_set(const char *rules, const char *model, const char *lay
/* fetch new keymap based on names */
keymap = xkb_map_new_from_names(e_comp->wl_comp_data->xkb.context, &names, 0);
/* update compositor keymap */
_e_comp_wl_input_keymap_update(keymap);
if (keymap)
{
/* update compositor keymap */
_e_comp_wl_input_keymap_update(keymap);
}
/* cleanup */
free((char *)names.rules);