kbproto unentanglement: XkbSI match flags

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
master
Daniel Stone 2012-09-11 12:28:29 +01:00
parent ed9fd5beb0
commit a8d462e366
5 changed files with 49 additions and 37 deletions

View File

@ -540,7 +540,7 @@ write_compat(struct xkb_keymap *keymap, struct buf *buf)
keymap->vmod_names[interp->virtual_mod])); keymap->vmod_names[interp->virtual_mod]));
} }
if (interp->match & XkbSI_LevelOneOnly) if (interp->match & MATCH_LEVEL_ONE_ONLY)
write_buf(buf, write_buf(buf,
"\t\t\tuseModMapMods=level1;\n"); "\t\t\tuseModMapMods=level1;\n");
if (interp->flags & XkbSI_AutoRepeat) if (interp->flags & XkbSI_AutoRepeat)

View File

@ -202,11 +202,11 @@ const LookupEntry actionTypeNames[] = {
}; };
const LookupEntry symInterpretMatchMaskNames[] = { const LookupEntry symInterpretMatchMaskNames[] = {
{ "NoneOf", XkbSI_NoneOf }, { "NoneOf", MATCH_NONE },
{ "AnyOfOrNone", XkbSI_AnyOfOrNone }, { "AnyOfOrNone", MATCH_ANY_OR_NONE },
{ "AnyOf", XkbSI_AnyOf }, { "AnyOf", MATCH_ANY },
{ "AllOf", XkbSI_AllOf }, { "AllOf", MATCH_ALL },
{ "Exactly", XkbSI_Exactly }, { "Exactly", MATCH_EXACTLY },
}; };
#define BUFFER_SIZE 1024 #define BUFFER_SIZE 1024
@ -444,18 +444,18 @@ KeyNameText(const char name[XKB_KEY_NAME_LENGTH])
} }
const char * const char *
SIMatchText(unsigned type) SIMatchText(enum xkb_match_operation type)
{ {
const char *name; const char *name;
char *buf; char *buf;
type &= XkbSI_OpMask; type &= MATCH_OP_MASK;
name = LookupValue(symInterpretMatchMaskNames, type); name = LookupValue(symInterpretMatchMaskNames, type);
if (name) if (name)
return name; return name;
buf = GetBuffer(40); buf = GetBuffer(40);
snprintf(buf, 40, "0x%x", type & XkbSI_OpMask); snprintf(buf, 40, "0x%x", type);
return buf; return buf;
} }

View File

@ -185,6 +185,18 @@ enum xkb_action_controls {
CONTROL_IGNORE_GROUP_LOCK) CONTROL_IGNORE_GROUP_LOCK)
}; };
enum xkb_match_operation {
MATCH_NONE = 0,
MATCH_ANY_OR_NONE = 1,
MATCH_ANY = 2,
MATCH_ALL = 3,
MATCH_EXACTLY = 4,
MATCH_OP_MASK = \
(MATCH_NONE | MATCH_ANY_OR_NONE | MATCH_ANY | MATCH_ALL | \
MATCH_EXACTLY),
MATCH_LEVEL_ONE_ONLY = (1 << 7),
};
struct xkb_mods { struct xkb_mods {
xkb_mod_mask_t mods; /* original real+virtual mods in definition */ xkb_mod_mask_t mods; /* original real+virtual mods in definition */
xkb_mod_mask_t mask; /* computed effective mask */ xkb_mod_mask_t mask; /* computed effective mask */
@ -281,7 +293,7 @@ struct xkb_key_type {
struct xkb_sym_interpret { struct xkb_sym_interpret {
xkb_keysym_t sym; xkb_keysym_t sym;
unsigned char flags; unsigned char flags;
unsigned char match; enum xkb_match_operation match;
uint8_t mods; uint8_t mods;
xkb_mod_index_t virtual_mod; xkb_mod_index_t virtual_mod;
union xkb_action act; union xkb_action act;

View File

@ -339,8 +339,8 @@ AddInterp(CompatInfo *info, SymInterpInfo *new)
} }
if (UseNewInterpField(SI_FIELD_LEVEL_ONE_ONLY, old, new, report, if (UseNewInterpField(SI_FIELD_LEVEL_ONE_ONLY, old, new, report,
&collide)) { &collide)) {
old->interp.match &= ~XkbSI_LevelOneOnly; old->interp.match &= ~MATCH_LEVEL_ONE_ONLY;
old->interp.match |= (new->interp.match & XkbSI_LevelOneOnly); old->interp.match |= (new->interp.match & MATCH_LEVEL_ONE_ONLY);
old->defined |= SI_FIELD_LEVEL_ONE_ONLY; old->defined |= SI_FIELD_LEVEL_ONE_ONLY;
} }
@ -363,16 +363,16 @@ AddInterp(CompatInfo *info, SymInterpInfo *new)
/***====================================================================***/ /***====================================================================***/
static bool static bool
ResolveStateAndPredicate(ExprDef *expr, unsigned *pred_rtrn, ResolveStateAndPredicate(ExprDef *expr, enum xkb_match_operation *pred_rtrn,
xkb_mod_mask_t *mods_rtrn, CompatInfo *info) xkb_mod_mask_t *mods_rtrn, CompatInfo *info)
{ {
if (expr == NULL) { if (expr == NULL) {
*pred_rtrn = XkbSI_AnyOfOrNone; *pred_rtrn = MATCH_ANY_OR_NONE;
*mods_rtrn = ~0; *mods_rtrn = ~0;
return true; return true;
} }
*pred_rtrn = XkbSI_Exactly; *pred_rtrn = MATCH_EXACTLY;
if (expr->op == EXPR_ACTION_DECL) { if (expr->op == EXPR_ACTION_DECL) {
const char *pred_txt = xkb_atom_text(info->keymap->ctx, const char *pred_txt = xkb_atom_text(info->keymap->ctx,
expr->value.action.name); expr->value.action.name);
@ -387,7 +387,7 @@ ResolveStateAndPredicate(ExprDef *expr, unsigned *pred_rtrn,
const char *pred_txt = xkb_atom_text(info->keymap->ctx, const char *pred_txt = xkb_atom_text(info->keymap->ctx,
expr->value.str); expr->value.str);
if (pred_txt && istreq(pred_txt, "any")) { if (pred_txt && istreq(pred_txt, "any")) {
*pred_rtrn = XkbSI_AnyOf; *pred_rtrn = MATCH_ANY;
*mods_rtrn = 0xff; *mods_rtrn = 0xff;
return true; return true;
} }
@ -619,9 +619,9 @@ SetInterpField(CompatInfo *info, SymInterpInfo *si, const char *field,
return ReportSIBadType(info, si, field, "level specification"); return ReportSIBadType(info, si, field, "level specification");
if (val) if (val)
si->interp.match |= XkbSI_LevelOneOnly; si->interp.match |= MATCH_LEVEL_ONE_ONLY;
else else
si->interp.match &= ~XkbSI_LevelOneOnly; si->interp.match &= ~MATCH_LEVEL_ONE_ONLY;
si->defined |= SI_FIELD_LEVEL_ONE_ONLY; si->defined |= SI_FIELD_LEVEL_ONE_ONLY;
} }
@ -805,7 +805,7 @@ HandleInterpDef(CompatInfo *info, InterpDef *def, enum merge_mode merge)
return false; return false;
} }
si.interp.match = pred & XkbSI_OpMask; si.interp.match = pred & MATCH_OP_MASK;
si.interp.mods = mods; si.interp.mods = mods;
@ -920,12 +920,12 @@ HandleCompatMapFile(CompatInfo *info, XkbFile *file, enum merge_mode merge)
} }
static void static void
CopyInterps(CompatInfo *info, bool needSymbol, unsigned pred) CopyInterps(CompatInfo *info, bool needSymbol, enum xkb_match_operation pred)
{ {
SymInterpInfo *si; SymInterpInfo *si;
darray_foreach(si, info->interps) { darray_foreach(si, info->interps) {
if (((si->interp.match & XkbSI_OpMask) != pred) || if (((si->interp.match & MATCH_OP_MASK) != pred) ||
(needSymbol && si->interp.sym == XKB_KEY_NoSymbol) || (needSymbol && si->interp.sym == XKB_KEY_NoSymbol) ||
(!needSymbol && si->interp.sym != XKB_KEY_NoSymbol)) (!needSymbol && si->interp.sym != XKB_KEY_NoSymbol))
continue; continue;
@ -989,14 +989,14 @@ CopyCompatToKeymap(struct xkb_keymap *keymap, CompatInfo *info)
if (!darray_empty(info->interps)) { if (!darray_empty(info->interps)) {
/* Most specific to least specific. */ /* Most specific to least specific. */
CopyInterps(info, true, XkbSI_Exactly); CopyInterps(info, true, MATCH_EXACTLY);
CopyInterps(info, true, XkbSI_AllOf | XkbSI_NoneOf); CopyInterps(info, true, MATCH_ALL);
CopyInterps(info, true, XkbSI_AnyOf); CopyInterps(info, true, MATCH_ANY);
CopyInterps(info, true, XkbSI_AnyOfOrNone); CopyInterps(info, true, MATCH_ANY_OR_NONE);
CopyInterps(info, false, XkbSI_Exactly); CopyInterps(info, false, MATCH_EXACTLY);
CopyInterps(info, false, XkbSI_AllOf | XkbSI_NoneOf); CopyInterps(info, false, MATCH_ALL);
CopyInterps(info, false, XkbSI_AnyOf); CopyInterps(info, false, MATCH_ANY);
CopyInterps(info, false, XkbSI_AnyOfOrNone); CopyInterps(info, false, MATCH_ANY_OR_NONE);
} }
CopyIndicatorMapDefs(info); CopyIndicatorMapDefs(info);

View File

@ -100,25 +100,25 @@ FindInterpForKey(struct xkb_keymap *keymap, struct xkb_key *key,
interp->sym != XKB_KEY_NoSymbol) interp->sym != XKB_KEY_NoSymbol)
continue; continue;
if (level == 0 || !(interp->match & XkbSI_LevelOneOnly)) if (level == 0 || !(interp->match & MATCH_LEVEL_ONE_ONLY))
mods = key->modmap; mods = key->modmap;
else else
mods = 0; mods = 0;
switch (interp->match & XkbSI_OpMask) { switch (interp->match & MATCH_OP_MASK) {
case XkbSI_NoneOf: case MATCH_NONE:
found = !(interp->mods & mods); found = !(interp->mods & mods);
break; break;
case XkbSI_AnyOfOrNone: case MATCH_ANY_OR_NONE:
found = (!mods || (interp->mods & mods)); found = (!mods || (interp->mods & mods));
break; break;
case XkbSI_AnyOf: case MATCH_ANY:
found = !!(interp->mods & mods); found = !!(interp->mods & mods);
break; break;
case XkbSI_AllOf: case MATCH_ALL:
found = ((interp->mods & mods) == interp->mods); found = ((interp->mods & mods) == interp->mods);
break; break;
case XkbSI_Exactly: case MATCH_EXACTLY:
found = (interp->mods == mods); found = (interp->mods == mods);
break; break;
default: default:
@ -162,7 +162,7 @@ ApplyInterpsToKey(struct xkb_keymap *keymap, struct xkb_key *key)
continue; continue;
if ((group == 0 && level == 0) || if ((group == 0 && level == 0) ||
!(interp->match & XkbSI_LevelOneOnly)) { !(interp->match & MATCH_LEVEL_ONE_ONLY)) {
if (interp->virtual_mod != XKB_MOD_INVALID) if (interp->virtual_mod != XKB_MOD_INVALID)
vmodmask |= (1 << interp->virtual_mod); vmodmask |= (1 << interp->virtual_mod);
} }