kbproto unentanglement: XkbSI match flags
Signed-off-by: Daniel Stone <daniel@fooishbar.org>master
parent
ed9fd5beb0
commit
a8d462e366
|
@ -540,7 +540,7 @@ write_compat(struct xkb_keymap *keymap, struct buf *buf)
|
|||
keymap->vmod_names[interp->virtual_mod]));
|
||||
}
|
||||
|
||||
if (interp->match & XkbSI_LevelOneOnly)
|
||||
if (interp->match & MATCH_LEVEL_ONE_ONLY)
|
||||
write_buf(buf,
|
||||
"\t\t\tuseModMapMods=level1;\n");
|
||||
if (interp->flags & XkbSI_AutoRepeat)
|
||||
|
|
16
src/text.c
16
src/text.c
|
@ -202,11 +202,11 @@ const LookupEntry actionTypeNames[] = {
|
|||
};
|
||||
|
||||
const LookupEntry symInterpretMatchMaskNames[] = {
|
||||
{ "NoneOf", XkbSI_NoneOf },
|
||||
{ "AnyOfOrNone", XkbSI_AnyOfOrNone },
|
||||
{ "AnyOf", XkbSI_AnyOf },
|
||||
{ "AllOf", XkbSI_AllOf },
|
||||
{ "Exactly", XkbSI_Exactly },
|
||||
{ "NoneOf", MATCH_NONE },
|
||||
{ "AnyOfOrNone", MATCH_ANY_OR_NONE },
|
||||
{ "AnyOf", MATCH_ANY },
|
||||
{ "AllOf", MATCH_ALL },
|
||||
{ "Exactly", MATCH_EXACTLY },
|
||||
};
|
||||
|
||||
#define BUFFER_SIZE 1024
|
||||
|
@ -444,18 +444,18 @@ KeyNameText(const char name[XKB_KEY_NAME_LENGTH])
|
|||
}
|
||||
|
||||
const char *
|
||||
SIMatchText(unsigned type)
|
||||
SIMatchText(enum xkb_match_operation type)
|
||||
{
|
||||
const char *name;
|
||||
char *buf;
|
||||
|
||||
type &= XkbSI_OpMask;
|
||||
type &= MATCH_OP_MASK;
|
||||
|
||||
name = LookupValue(symInterpretMatchMaskNames, type);
|
||||
if (name)
|
||||
return name;
|
||||
|
||||
buf = GetBuffer(40);
|
||||
snprintf(buf, 40, "0x%x", type & XkbSI_OpMask);
|
||||
snprintf(buf, 40, "0x%x", type);
|
||||
return buf;
|
||||
}
|
||||
|
|
|
@ -185,6 +185,18 @@ enum xkb_action_controls {
|
|||
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 {
|
||||
xkb_mod_mask_t mods; /* original real+virtual mods in definition */
|
||||
xkb_mod_mask_t mask; /* computed effective mask */
|
||||
|
@ -281,7 +293,7 @@ struct xkb_key_type {
|
|||
struct xkb_sym_interpret {
|
||||
xkb_keysym_t sym;
|
||||
unsigned char flags;
|
||||
unsigned char match;
|
||||
enum xkb_match_operation match;
|
||||
uint8_t mods;
|
||||
xkb_mod_index_t virtual_mod;
|
||||
union xkb_action act;
|
||||
|
|
|
@ -339,8 +339,8 @@ AddInterp(CompatInfo *info, SymInterpInfo *new)
|
|||
}
|
||||
if (UseNewInterpField(SI_FIELD_LEVEL_ONE_ONLY, old, new, report,
|
||||
&collide)) {
|
||||
old->interp.match &= ~XkbSI_LevelOneOnly;
|
||||
old->interp.match |= (new->interp.match & XkbSI_LevelOneOnly);
|
||||
old->interp.match &= ~MATCH_LEVEL_ONE_ONLY;
|
||||
old->interp.match |= (new->interp.match & MATCH_LEVEL_ONE_ONLY);
|
||||
old->defined |= SI_FIELD_LEVEL_ONE_ONLY;
|
||||
}
|
||||
|
||||
|
@ -363,16 +363,16 @@ AddInterp(CompatInfo *info, SymInterpInfo *new)
|
|||
/***====================================================================***/
|
||||
|
||||
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)
|
||||
{
|
||||
if (expr == NULL) {
|
||||
*pred_rtrn = XkbSI_AnyOfOrNone;
|
||||
*pred_rtrn = MATCH_ANY_OR_NONE;
|
||||
*mods_rtrn = ~0;
|
||||
return true;
|
||||
}
|
||||
|
||||
*pred_rtrn = XkbSI_Exactly;
|
||||
*pred_rtrn = MATCH_EXACTLY;
|
||||
if (expr->op == EXPR_ACTION_DECL) {
|
||||
const char *pred_txt = xkb_atom_text(info->keymap->ctx,
|
||||
expr->value.action.name);
|
||||
|
@ -387,7 +387,7 @@ ResolveStateAndPredicate(ExprDef *expr, unsigned *pred_rtrn,
|
|||
const char *pred_txt = xkb_atom_text(info->keymap->ctx,
|
||||
expr->value.str);
|
||||
if (pred_txt && istreq(pred_txt, "any")) {
|
||||
*pred_rtrn = XkbSI_AnyOf;
|
||||
*pred_rtrn = MATCH_ANY;
|
||||
*mods_rtrn = 0xff;
|
||||
return true;
|
||||
}
|
||||
|
@ -619,9 +619,9 @@ SetInterpField(CompatInfo *info, SymInterpInfo *si, const char *field,
|
|||
return ReportSIBadType(info, si, field, "level specification");
|
||||
|
||||
if (val)
|
||||
si->interp.match |= XkbSI_LevelOneOnly;
|
||||
si->interp.match |= MATCH_LEVEL_ONE_ONLY;
|
||||
else
|
||||
si->interp.match &= ~XkbSI_LevelOneOnly;
|
||||
si->interp.match &= ~MATCH_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;
|
||||
}
|
||||
|
||||
si.interp.match = pred & XkbSI_OpMask;
|
||||
si.interp.match = pred & MATCH_OP_MASK;
|
||||
|
||||
si.interp.mods = mods;
|
||||
|
||||
|
@ -920,12 +920,12 @@ HandleCompatMapFile(CompatInfo *info, XkbFile *file, enum merge_mode merge)
|
|||
}
|
||||
|
||||
static void
|
||||
CopyInterps(CompatInfo *info, bool needSymbol, unsigned pred)
|
||||
CopyInterps(CompatInfo *info, bool needSymbol, enum xkb_match_operation pred)
|
||||
{
|
||||
SymInterpInfo *si;
|
||||
|
||||
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))
|
||||
continue;
|
||||
|
@ -989,14 +989,14 @@ CopyCompatToKeymap(struct xkb_keymap *keymap, CompatInfo *info)
|
|||
|
||||
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);
|
||||
CopyInterps(info, true, XkbSI_AnyOfOrNone);
|
||||
CopyInterps(info, false, XkbSI_Exactly);
|
||||
CopyInterps(info, false, XkbSI_AllOf | XkbSI_NoneOf);
|
||||
CopyInterps(info, false, XkbSI_AnyOf);
|
||||
CopyInterps(info, false, XkbSI_AnyOfOrNone);
|
||||
CopyInterps(info, true, MATCH_EXACTLY);
|
||||
CopyInterps(info, true, MATCH_ALL);
|
||||
CopyInterps(info, true, MATCH_ANY);
|
||||
CopyInterps(info, true, MATCH_ANY_OR_NONE);
|
||||
CopyInterps(info, false, MATCH_EXACTLY);
|
||||
CopyInterps(info, false, MATCH_ALL);
|
||||
CopyInterps(info, false, MATCH_ANY);
|
||||
CopyInterps(info, false, MATCH_ANY_OR_NONE);
|
||||
}
|
||||
|
||||
CopyIndicatorMapDefs(info);
|
||||
|
|
|
@ -100,25 +100,25 @@ FindInterpForKey(struct xkb_keymap *keymap, struct xkb_key *key,
|
|||
interp->sym != XKB_KEY_NoSymbol)
|
||||
continue;
|
||||
|
||||
if (level == 0 || !(interp->match & XkbSI_LevelOneOnly))
|
||||
if (level == 0 || !(interp->match & MATCH_LEVEL_ONE_ONLY))
|
||||
mods = key->modmap;
|
||||
else
|
||||
mods = 0;
|
||||
|
||||
switch (interp->match & XkbSI_OpMask) {
|
||||
case XkbSI_NoneOf:
|
||||
switch (interp->match & MATCH_OP_MASK) {
|
||||
case MATCH_NONE:
|
||||
found = !(interp->mods & mods);
|
||||
break;
|
||||
case XkbSI_AnyOfOrNone:
|
||||
case MATCH_ANY_OR_NONE:
|
||||
found = (!mods || (interp->mods & mods));
|
||||
break;
|
||||
case XkbSI_AnyOf:
|
||||
case MATCH_ANY:
|
||||
found = !!(interp->mods & mods);
|
||||
break;
|
||||
case XkbSI_AllOf:
|
||||
case MATCH_ALL:
|
||||
found = ((interp->mods & mods) == interp->mods);
|
||||
break;
|
||||
case XkbSI_Exactly:
|
||||
case MATCH_EXACTLY:
|
||||
found = (interp->mods == mods);
|
||||
break;
|
||||
default:
|
||||
|
@ -162,7 +162,7 @@ ApplyInterpsToKey(struct xkb_keymap *keymap, struct xkb_key *key)
|
|||
continue;
|
||||
|
||||
if ((group == 0 && level == 0) ||
|
||||
!(interp->match & XkbSI_LevelOneOnly)) {
|
||||
!(interp->match & MATCH_LEVEL_ONE_ONLY)) {
|
||||
if (interp->virtual_mod != XKB_MOD_INVALID)
|
||||
vmodmask |= (1 << interp->virtual_mod);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue