kbproto unentanglement: XkbSI match flags Signed-off-by: Daniel Stone <daniel@fooishbar.org>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237
diff --git a/src/keymap-dump.c b/src/keymap-dump.c
index bd538b2..41adf5b 100644
--- a/src/keymap-dump.c
+++ b/src/keymap-dump.c
@@ -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)
diff --git a/src/text.c b/src/text.c
index e2e1268..6151145 100644
--- a/src/text.c
+++ b/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;
}
diff --git a/src/xkb-priv.h b/src/xkb-priv.h
index 3900b84..7a69356 100644
--- a/src/xkb-priv.h
+++ b/src/xkb-priv.h
@@ -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;
diff --git a/src/xkbcomp/compat.c b/src/xkbcomp/compat.c
index f0a61b3..cab6b33 100644
--- a/src/xkbcomp/compat.c
+++ b/src/xkbcomp/compat.c
@@ -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);
diff --git a/src/xkbcomp/keymap.c b/src/xkbcomp/keymap.c
index 210ccac..4bad351 100644
--- a/src/xkbcomp/keymap.c
+++ b/src/xkbcomp/keymap.c
@@ -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);
}