Remove now-unneeded mod type annotations Most of the mod type annotations can now be changed to MOD_BOTH, because if you pass a mask which can only contain real mods in the first place to e.g. ModMaskText, then MOD_REAL and MOD_BOTH will give the same result. In the cases where MOD_BOTH is only ever the argument, we just remove it. What's left is where it really "matters". Signed-off-by: Ran Benita <ran234@gmail.com>
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 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339
diff --git a/src/keymap-dump.c b/src/keymap-dump.c
index 75f2654..920a846 100644
--- a/src/keymap-dump.c
+++ b/src/keymap-dump.c
@@ -281,7 +281,7 @@ write_types(struct xkb_keymap *keymap, struct buf *buf)
write_buf(buf, "\t\ttype \"%s\" {\n",
xkb_atom_text(keymap->ctx, type->name));
write_buf(buf, "\t\t\tmodifiers= %s;\n",
- ModMaskText(keymap, type->mods.mods, MOD_BOTH));
+ ModMaskText(keymap, type->mods.mods));
for (j = 0; j < type->num_entries; j++) {
const char *str;
@@ -294,7 +294,7 @@ write_types(struct xkb_keymap *keymap, struct buf *buf)
if (entry->level == 0 && entry->preserve.mods == 0)
continue;
- str = ModMaskText(keymap, entry->mods.mods, MOD_BOTH);
+ str = ModMaskText(keymap, entry->mods.mods);
write_buf(buf, "\t\t\tmap[%s]= Level%d;\n",
str, entry->level + 1);
@@ -303,7 +303,7 @@ write_types(struct xkb_keymap *keymap, struct buf *buf)
write_buf(buf, "\t\t\tpreserve[%s]= ", str);
write_buf(buf, "%s;\n",
- ModMaskText(keymap, entry->preserve.mods, MOD_BOTH));
+ ModMaskText(keymap, entry->preserve.mods));
}
if (type->level_names) {
@@ -344,7 +344,7 @@ write_indicator_map(struct xkb_keymap *keymap, struct buf *buf, int num)
get_indicator_state_text(led->which_mods));
}
write_buf(buf, "\t\t\tmodifiers= %s;\n",
- ModMaskText(keymap, led->mods.mods, MOD_BOTH));
+ ModMaskText(keymap, led->mods.mods));
}
if (led->ctrls) {
@@ -378,7 +378,7 @@ write_action(struct xkb_keymap *keymap, struct buf *buf,
if (action->mods.flags & ACTION_MODS_LOOKUP_MODMAP)
args = "modMapMods";
else
- args = ModMaskText(keymap, action->mods.mods.mods, MOD_BOTH);
+ args = ModMaskText(keymap, action->mods.mods.mods);
write_buf(buf, "%s%s(modifiers=%s%s%s)%s", prefix, type, args,
(action->type != ACTION_TYPE_MOD_LOCK &&
(action->mods.flags & ACTION_LOCK_CLEAR)) ?
@@ -524,11 +524,11 @@ write_compat(struct xkb_keymap *keymap, struct buf *buf)
write_buf(buf, "\t\tinterpret %s+%s(%s) {\n",
keysym_name,
SIMatchText(interp->match),
- ModMaskText(keymap, interp->mods, MOD_REAL));
+ ModMaskText(keymap, interp->mods));
if (interp->virtual_mod != XKB_MOD_INVALID)
write_buf(buf, "\t\t\tvirtualModifier= %s;\n",
- ModIndexText(keymap, interp->virtual_mod, MOD_VIRT));
+ ModIndexText(keymap, interp->virtual_mod));
if (interp->match & MATCH_LEVEL_ONE_ONLY)
write_buf(buf, "\t\t\tuseModMapMods=level1;\n");
@@ -668,7 +668,7 @@ write_symbols(struct xkb_keymap *keymap, struct buf *buf)
if (key->vmodmap && (key->explicit & EXPLICIT_VMODMAP))
write_buf(buf, "\n\t\t\tvirtualMods= %s,",
- ModMaskText(keymap, key->vmodmap, MOD_VIRT));
+ ModMaskText(keymap, key->vmodmap));
switch (key->out_of_range_group_action) {
case RANGE_SATURATE:
diff --git a/src/text.c b/src/text.c
index ff783e3..ccf784c 100644
--- a/src/text.c
+++ b/src/text.c
@@ -232,31 +232,26 @@ GetBuffer(size_t size)
}
const char *
-ModMaskText(const struct xkb_keymap *keymap, xkb_mod_mask_t mask,
- enum mod_type type)
+ModMaskText(const struct xkb_keymap *keymap, xkb_mod_mask_t mask)
{
xkb_mod_index_t i;
- xkb_mod_mask_t rmask, vmask;
size_t len;
ssize_t rem;
char *str;
char buf[BUFFER_SIZE];
const struct xkb_mod *mod;
- rmask = (type & MOD_REAL ? mask : 0) & 0xff;
- vmask = (type & MOD_VIRT ? mask : 0) & (~0xff);
-
- if (rmask == 0 && vmask == 0)
+ if (mask == 0)
return "none";
- if (rmask == 0xff && vmask == 0)
+ if (mask == 0xff)
return "all";
str = buf;
buf[0] = '\0';
rem = BUFFER_SIZE;
darray_enumerate(i, mod, keymap->mods) {
- if (!(mod->type & type) || !(mask & (1 << i)))
+ if (!(mask & (1 << i)))
continue;
len = snprintf(str, rem, "%s%s",
@@ -279,14 +274,12 @@ ModMaskText(const struct xkb_keymap *keymap, xkb_mod_mask_t mask,
}
const char *
-ModIndexText(const struct xkb_keymap *keymap, xkb_mod_index_t ndx,
- enum mod_type type)
+ModIndexText(const struct xkb_keymap *keymap, xkb_mod_index_t ndx)
{
if (ndx == XKB_MOD_INVALID)
return "none";
- if (ndx >= darray_size(keymap->mods) ||
- !(darray_item(keymap->mods, ndx).type & type))
+ if (ndx >= darray_size(keymap->mods))
return NULL;
return xkb_atom_text(keymap->ctx, darray_item(keymap->mods, ndx).name);
diff --git a/src/text.h b/src/text.h
index a3c1f29..32115c8 100644
--- a/src/text.h
+++ b/src/text.h
@@ -48,12 +48,10 @@ extern const LookupEntry actionTypeNames[];
extern const LookupEntry symInterpretMatchMaskNames[];
const char *
-ModMaskText(const struct xkb_keymap *keymap, xkb_mod_mask_t mask,
- enum mod_type type);
+ModMaskText(const struct xkb_keymap *keymap, xkb_mod_mask_t mask);
const char *
-ModIndexText(const struct xkb_keymap *keymap, xkb_mod_index_t ndx,
- enum mod_type type);
+ModIndexText(const struct xkb_keymap *keymap, xkb_mod_index_t ndx);
xkb_mod_index_t
ModNameToIndex(const struct xkb_keymap *keymap, xkb_atom_t name,
diff --git a/src/xkbcomp/compat.c b/src/xkbcomp/compat.c
index 522389b..5678074 100644
--- a/src/xkbcomp/compat.c
+++ b/src/xkbcomp/compat.c
@@ -210,7 +210,7 @@ siText(SymInterpInfo *si, CompatInfo *info)
snprintf(buf, sizeof(buf), "%s+%s(%s)",
KeysymText(si->interp.sym),
SIMatchText(si->interp.match),
- ModMaskText(info->keymap, si->interp.mods, MOD_REAL));
+ ModMaskText(info->keymap, si->interp.mods));
return buf;
}
diff --git a/src/xkbcomp/keymap.c b/src/xkbcomp/keymap.c
index 81e584e..f670a08 100644
--- a/src/xkbcomp/keymap.c
+++ b/src/xkbcomp/keymap.c
@@ -39,7 +39,7 @@ ComputeEffectiveMask(struct xkb_keymap *keymap, struct xkb_mods *mods)
mods->mask = mods->mods & 0xff;
darray_enumerate(i, mod, keymap->mods)
- if (mod->type == MOD_VIRT && mods->mods & (1 << i))
+ if (mods->mods & (1 << i))
mods->mask |= mod->mapping;
}
@@ -198,7 +198,7 @@ UpdateDerivedKeymapFields(struct xkb_keymap *keymap)
/* Update keymap->mods, the virtual -> real mod mapping. */
xkb_foreach_key(key, keymap)
darray_enumerate(i, mod, keymap->mods)
- if (mod->type == MOD_VIRT && key->vmodmap & (1 << i))
+ if (key->vmodmap & (1 << i))
mod->mapping |= key->modmap;
/* Now update the level masks for all the types to reflect the vmods. */
diff --git a/src/xkbcomp/symbols.c b/src/xkbcomp/symbols.c
index 5c5e6c7..ee4c8c1 100644
--- a/src/xkbcomp/symbols.c
+++ b/src/xkbcomp/symbols.c
@@ -463,8 +463,8 @@ AddModMapEntry(SymbolsInfo *info, ModMapEntry *new)
"%s added to symbol map for multiple modifiers; "
"Using %s, ignoring %s.\n",
KeysymText(new->u.keySym),
- ModIndexText(info->keymap, use, MOD_REAL),
- ModIndexText(info->keymap, ignore, MOD_REAL));
+ ModIndexText(info->keymap, use),
+ ModIndexText(info->keymap, ignore));
mm->modifier = use;
}
return true;
@@ -485,8 +485,8 @@ AddModMapEntry(SymbolsInfo *info, ModMapEntry *new)
"Key %s added to map for multiple modifiers; "
"Using %s, ignoring %s.\n",
KeyNameText(info->keymap->ctx, new->u.keyName),
- ModIndexText(info->keymap, use, MOD_REAL),
- ModIndexText(info->keymap, ignore, MOD_REAL));
+ ModIndexText(info->keymap, use),
+ ModIndexText(info->keymap, ignore));
mm->modifier = use;
}
return true;
@@ -1238,7 +1238,7 @@ HandleModMapDef(SymbolsInfo *info, ModMapDef *def)
log_err(info->keymap->ctx,
"Modmap entries may contain only key names or keysyms; "
"Illegal definition for %s modifier ignored\n",
- ModIndexText(info->keymap, tmp.modifier, MOD_REAL));
+ ModIndexText(info->keymap, tmp.modifier));
continue;
}
@@ -1573,7 +1573,7 @@ CopyModMapDef(SymbolsInfo *info, ModMapEntry *entry)
"Key %s not found in keycodes; "
"Modifier map entry for %s not updated\n",
KeyNameText(keymap->ctx, entry->u.keyName),
- ModIndexText(info->keymap, entry->modifier, MOD_REAL));
+ ModIndexText(info->keymap, entry->modifier));
return false;
}
}
@@ -1584,7 +1584,7 @@ CopyModMapDef(SymbolsInfo *info, ModMapEntry *entry)
"Key \"%s\" not found in symbol map; "
"Modifier map entry for %s not updated\n",
KeysymText(entry->u.keySym),
- ModIndexText(info->keymap, entry->modifier, MOD_REAL));
+ ModIndexText(info->keymap, entry->modifier));
return false;
}
}
diff --git a/src/xkbcomp/types.c b/src/xkbcomp/types.c
index 39a730a..ebfc99d 100644
--- a/src/xkbcomp/types.c
+++ b/src/xkbcomp/types.c
@@ -168,7 +168,7 @@ typedef struct {
static inline const char *
MapEntryTxt(KeyTypesInfo *info, struct xkb_kt_map_entry *entry)
{
- return ModMaskText(info->keymap, entry->mods.mods, MOD_BOTH);
+ return ModMaskText(info->keymap, entry->mods.mods);
}
static inline const char *
@@ -180,7 +180,7 @@ TypeTxt(KeyTypesInfo *info, KeyTypeInfo *type)
static inline const char *
TypeMaskTxt(KeyTypesInfo *info, KeyTypeInfo *type)
{
- return ModMaskText(info->keymap, type->mods, MOD_BOTH);
+ return ModMaskText(info->keymap, type->mods);
}
static inline bool
@@ -377,7 +377,7 @@ SetModifiers(KeyTypesInfo *info, KeyTypeInfo *type, ExprDef *arrayNdx,
"Using %s, ignoring %s\n",
xkb_atom_text(info->keymap->ctx, type->name),
TypeMaskTxt(info, type),
- ModMaskText(info->keymap, mods, MOD_BOTH));
+ ModMaskText(info->keymap, mods));
return false;
}
@@ -456,8 +456,7 @@ SetMapEntry(KeyTypesInfo *info, KeyTypeInfo *type, ExprDef *arrayNdx,
"Map entry for unused modifiers in %s; "
"Using %s instead of %s\n",
TypeTxt(info, type),
- ModMaskText(info->keymap, entry.mods.mods & type->mods,
- MOD_BOTH),
+ ModMaskText(info->keymap, entry.mods.mods & type->mods),
MapEntryTxt(info, &entry));
entry.mods.mods &= type->mods;
}
@@ -498,7 +497,7 @@ AddPreserve(KeyTypesInfo *info, KeyTypeInfo *type,
log_vrb(info->keymap->ctx, 10,
"Identical definitions for preserve[%s] in %s; "
"Ignored\n",
- ModMaskText(info->keymap, mods, MOD_BOTH),
+ ModMaskText(info->keymap, mods),
TypeTxt(info, type));
return true;
}
@@ -507,10 +506,10 @@ AddPreserve(KeyTypesInfo *info, KeyTypeInfo *type,
log_vrb(info->keymap->ctx, 1,
"Multiple definitions for preserve[%s] in %s; "
"Using %s, ignoring %s\n",
- ModMaskText(info->keymap, mods, MOD_BOTH),
+ ModMaskText(info->keymap, mods),
TypeTxt(info, type),
- ModMaskText(info->keymap, preserve_mods, MOD_BOTH),
- ModMaskText(info->keymap, entry->preserve.mods, MOD_BOTH));
+ ModMaskText(info->keymap, preserve_mods),
+ ModMaskText(info->keymap, entry->preserve.mods));
entry->preserve.mods = preserve_mods;
return true;
@@ -544,9 +543,9 @@ SetPreserve(KeyTypesInfo *info, KeyTypeInfo *type, ExprDef *arrayNdx,
if (mods & ~type->mods) {
const char *before, *after;
- before = ModMaskText(info->keymap, mods, MOD_BOTH);
+ before = ModMaskText(info->keymap, mods);
mods &= type->mods;
- after = ModMaskText(info->keymap, mods, MOD_BOTH);
+ after = ModMaskText(info->keymap, mods);
log_vrb(info->keymap->ctx, 1,
"Preserve for modifiers not used by the %s type; "
@@ -558,7 +557,7 @@ SetPreserve(KeyTypesInfo *info, KeyTypeInfo *type, ExprDef *arrayNdx,
log_err(info->keymap->ctx,
"Preserve value in a key type is not a modifier mask; "
"Ignoring preserve[%s] in type %s\n",
- ModMaskText(info->keymap, mods, MOD_BOTH),
+ ModMaskText(info->keymap, mods),
TypeTxt(info, type));
return false;
}
@@ -566,14 +565,14 @@ SetPreserve(KeyTypesInfo *info, KeyTypeInfo *type, ExprDef *arrayNdx,
if (preserve_mods & ~mods) {
const char *before, *after;
- before = ModMaskText(info->keymap, preserve_mods, MOD_BOTH);
+ before = ModMaskText(info->keymap, preserve_mods);
preserve_mods &= mods;
- after = ModMaskText(info->keymap, preserve_mods, MOD_BOTH);
+ after = ModMaskText(info->keymap, preserve_mods);
log_vrb(info->keymap->ctx, 1,
"Illegal value for preserve[%s] in type %s; "
"Converted %s to %s\n",
- ModMaskText(info->keymap, mods, MOD_BOTH),
+ ModMaskText(info->keymap, mods),
TypeTxt(info, type), before, after);
}