xkbcomp/keymap: use default interpret in ApplyInterpsToKey

This makes the code easier to follow and does more explicitly what the
xkblib spec says:
     If no matching symbol interpretation is found, the server uses a
     default interpretation where:
        sym =	0
        flags =	XkbSI_AutoRepeat
        match =	XkbSI_AnyOfOrNone
        mods =	0
        virtual_mod =	XkbNoModifier
        act =	SA_NoAction

If a level doesn't have any keysyms, we don't apply anything to it.

Signed-off-by: Ran Benita <ran234@gmail.com>
master
Ran Benita 2012-09-27 09:19:12 +02:00
parent 11df063265
commit 53cfe8c362
1 changed files with 20 additions and 15 deletions

View File

@ -62,13 +62,22 @@ UpdateActionMods(struct xkb_keymap *keymap, union xkb_action *act,
}
}
static const struct xkb_sym_interpret default_interpret = {
.sym = XKB_KEY_NoSymbol,
.repeat = true,
.match = MATCH_ANY_OR_NONE,
.mods = 0,
.virtual_mod = XKB_MOD_INVALID,
.act = { .type = ACTION_TYPE_NONE },
};
/**
* Find an interpretation which applies to this particular level, either by
* finding an exact match for the symbol and modifier combination, or a
* generic XKB_KEY_NoSymbol match.
*/
static struct xkb_sym_interpret *
FindInterpForKey(struct xkb_keymap *keymap, struct xkb_key *key,
static const struct xkb_sym_interpret *
FindInterpForKey(struct xkb_keymap *keymap, const struct xkb_key *key,
xkb_layout_index_t group, xkb_level_index_t level)
{
struct xkb_sym_interpret *interp;
@ -124,7 +133,7 @@ FindInterpForKey(struct xkb_keymap *keymap, struct xkb_key *key,
return interp;
}
return NULL;
return &default_interpret;
}
static bool
@ -132,29 +141,25 @@ ApplyInterpsToKey(struct xkb_keymap *keymap, struct xkb_key *key)
{
xkb_mod_mask_t vmodmask = 0;
xkb_layout_index_t group;
xkb_level_index_t width, level;
xkb_level_index_t level;
/* If we've been told not to bind interps to this key, then don't. */
if (key->explicit & EXPLICIT_INTERP)
return true;
for (group = 0; group < key->num_groups; group++) {
width = XkbKeyGroupWidth(key, group);
for (level = 0; level < width; level++) {
struct xkb_sym_interpret *interp;
for (level = 0; level < XkbKeyGroupWidth(key, group); level++) {
const struct xkb_sym_interpret *interp;
interp = FindInterpForKey(keymap, key, group, level);
/* Infer default key behaviours from the base level. */
if (group == 0 && level == 0) {
if (!(key->explicit & EXPLICIT_REPEAT) &&
(!interp || interp->repeat))
key->repeats = true;
}
if (!interp)
continue;
/* Infer default key behaviours from the base level. */
if (group == 0 && level == 0)
if (!(key->explicit & EXPLICIT_REPEAT) && interp->repeat)
key->repeats = true;
if ((group == 0 && level == 0) ||
!(interp->match & MATCH_LEVEL_ONE_ONLY)) {
if (interp->virtual_mod != XKB_MOD_INVALID)