symbols: refactor AddModMapEntry

It really asks for it.

Signed-off-by: Ran Benita <ran234@gmail.com>
master
Ran Benita 2012-10-06 21:26:01 +02:00
parent 6d74e66e3f
commit fcceeeafa8
1 changed files with 32 additions and 47 deletions

View File

@ -442,55 +442,40 @@ AddKeySymbols(SymbolsInfo *info, KeyInfo *keyi)
static bool static bool
AddModMapEntry(SymbolsInfo *info, ModMapEntry *new) AddModMapEntry(SymbolsInfo *info, ModMapEntry *new)
{ {
ModMapEntry *mm; ModMapEntry *old;
bool clobber; bool clobber = (new->merge != MERGE_AUGMENT);
clobber = (new->merge != MERGE_AUGMENT); darray_foreach(old, info->modMaps) {
darray_foreach(mm, info->modMaps) { xkb_mod_index_t use, ignore;
if (new->haveSymbol && mm->haveSymbol
&& (new->u.keySym == mm->u.keySym)) { if ((new->haveSymbol != old->haveSymbol) ||
xkb_mod_index_t use, ignore; (new->haveSymbol && new->u.keySym != old->u.keySym) ||
if (mm->modifier != new->modifier) { (!new->haveSymbol && new->u.keyName != old->u.keyName))
if (clobber) { continue;
use = new->modifier;
ignore = mm->modifier; if (new->modifier == old->modifier)
}
else {
use = mm->modifier;
ignore = new->modifier;
}
log_err(info->keymap->ctx,
"%s added to symbol map for multiple modifiers; "
"Using %s, ignoring %s.\n",
KeysymText(new->u.keySym),
ModIndexText(info->keymap, use),
ModIndexText(info->keymap, ignore));
mm->modifier = use;
}
return true; return true;
}
if ((!new->haveSymbol) && (!mm->haveSymbol) && use = (clobber ? new->modifier : old->modifier);
(new->u.keyName == mm->u.keyName)) { ignore = (clobber ? old->modifier : new->modifier);
xkb_mod_index_t use, ignore;
if (mm->modifier != new->modifier) { if (new->haveSymbol)
if (clobber) { log_err(info->keymap->ctx,
use = new->modifier; "Symbol \"%s\" added to modifier map for multiple modifiers; "
ignore = mm->modifier; "Using %s, ignoring %s\n",
} KeysymText(new->u.keySym),
else { ModIndexText(info->keymap, use),
use = mm->modifier; ModIndexText(info->keymap, ignore));
ignore = new->modifier; else
} log_err(info->keymap->ctx,
log_err(info->keymap->ctx, "Key \"%s\" added to modifier map for multiple modifiers; "
"Key %s added to map for multiple modifiers; " "Using %s, ignoring %s\n",
"Using %s, ignoring %s.\n", KeyNameText(info->keymap->ctx, new->u.keyName),
KeyNameText(info->keymap->ctx, new->u.keyName), ModIndexText(info->keymap, use),
ModIndexText(info->keymap, use), ModIndexText(info->keymap, ignore));
ModIndexText(info->keymap, ignore));
mm->modifier = use; old->modifier = use;
} return true;
return true;
}
} }
darray_append(info->modMaps, *new); darray_append(info->modMaps, *new);