keymap->compat_section_name = strdup_safe(info->name);
if (!darray_empty(info->interps)) {
+ /* Most specific to least specific. */
CopyInterps(info, true, XkbSI_Exactly);
CopyInterps(info, true, XkbSI_AllOf | XkbSI_NoneOf);
CopyInterps(info, true, XkbSI_AnyOf);
FindInterpForKey(struct xkb_keymap *keymap, struct xkb_key *key,
xkb_group_index_t group, xkb_level_index_t level)
{
- struct xkb_sym_interpret *ret = NULL;
struct xkb_sym_interpret *interp;
const xkb_keysym_t *syms;
int num_syms;
if (num_syms == 0)
return NULL;
+ /*
+ * There may be multiple matchings interprets; we should always return
+ * the most specific. Here we rely on compat.c to set up the
+ * sym_interpret array from the most specific to the least specific,
+ * such that when we find a match we return immediately.
+ */
darray_foreach(interp, keymap->sym_interpret) {
uint32_t mods;
bool found;
break;
}
- if (found && interp->sym != XKB_KEY_NoSymbol)
+ if (found)
return interp;
- else if (found && !ret)
- ret = interp;
}
- return ret;
+ return NULL;
}
static bool