diff options
author | Daniel Stone <daniel@fooishbar.org> | 2012-08-21 12:48:20 +0100 |
---|---|---|
committer | Daniel Stone <daniel@fooishbar.org> | 2012-09-10 19:23:35 +0100 |
commit | b04d896ab25cca055e5bcc3d2e58d9c9fb6ef3c4 (patch) | |
tree | de0aaff12b30c7465941a128520ca11a0fdafae3 | |
parent | 74ec4c1c3fa9d7ff739013728d42ff06d72697c7 (diff) | |
download | libxkbcommon-b04d896ab25cca055e5bcc3d2e58d9c9fb6ef3c4.tar.gz libxkbcommon-b04d896ab25cca055e5bcc3d2e58d9c9fb6ef3c4.tar.bz2 libxkbcommon-b04d896ab25cca055e5bcc3d2e58d9c9fb6ef3c4.zip |
kbproto unentanglement: XkbNumVirtualMods
Signed-off-by: Daniel Stone <daniel@fooishbar.org>
-rw-r--r-- | src/keymap-dump.c | 6 | ||||
-rw-r--r-- | src/map.c | 10 | ||||
-rw-r--r-- | src/text.c | 16 | ||||
-rw-r--r-- | src/xkb-priv.h | 6 | ||||
-rw-r--r-- | src/xkbcomp/action.c | 2 | ||||
-rw-r--r-- | src/xkbcomp/keymap.c | 8 | ||||
-rw-r--r-- | src/xkbcomp/symbols.c | 2 | ||||
-rw-r--r-- | src/xkbcomp/vmod.c | 12 |
8 files changed, 32 insertions, 30 deletions
diff --git a/src/keymap-dump.c b/src/keymap-dump.c index 0aebf54..4926762 100644 --- a/src/keymap-dump.c +++ b/src/keymap-dump.c @@ -135,7 +135,7 @@ write_vmods(struct xkb_keymap *keymap, struct buf *buf) int num_vmods = 0; int i; - for (i = 0; i < XkbNumVirtualMods; i++) { + for (i = 0; i < XKB_NUM_VIRTUAL_MODS; i++) { if (!keymap->vmod_names[i]) continue; if (num_vmods == 0) @@ -686,7 +686,7 @@ write_symbols(struct xkb_keymap *keymap, struct buf *buf) if (key->vmodmap && (key->explicit & XkbExplicitVModMapMask)) { /* XXX: vmodmap cmask? */ write_buf(buf, "\n\t\t\tvirtualMods= %s,", - VModMaskText(keymap, key->vmodmap << XkbNumModifiers)); + VModMaskText(keymap, key->vmodmap << XKB_NUM_CORE_MODS)); } switch (key->out_of_range_group_action) { @@ -749,7 +749,7 @@ write_symbols(struct xkb_keymap *keymap, struct buf *buf) if (key->modmap == 0) continue; - for (mod = 0; mod < XkbNumModifiers; mod++) { + for (mod = 0; mod < XKB_NUM_CORE_MODS; mod++) { if (!(key->modmap & (1 << mod))) continue; @@ -113,13 +113,13 @@ xkb_map_num_mods(struct xkb_keymap *keymap) { xkb_mod_index_t i; - for (i = 0; i < XkbNumVirtualMods; i++) + for (i = 0; i < XKB_NUM_VIRTUAL_MODS; i++) if (!keymap->vmod_names[i]) break; /* We always have all the core modifiers (for now), plus any virtual * modifiers we may have defined. */ - return i + XkbNumModifiers; + return i + XKB_NUM_CORE_MODS; } /** @@ -138,7 +138,7 @@ xkb_map_mod_get_name(struct xkb_keymap *keymap, xkb_mod_index_t idx) name = ModIndexToName(idx); if (!name) name = xkb_atom_text(keymap->ctx, - keymap->vmod_names[idx - XkbNumModifiers]); + keymap->vmod_names[idx - XKB_NUM_CORE_MODS]); return name; } @@ -160,11 +160,11 @@ xkb_map_mod_get_index(struct xkb_keymap *keymap, const char *name) if (atom == XKB_ATOM_NONE) return XKB_MOD_INVALID; - for (i = 0; i < XkbNumVirtualMods; i++) { + for (i = 0; i < XKB_NUM_VIRTUAL_MODS; i++) { if (keymap->vmod_names[i] == XKB_ATOM_NONE) break; if (keymap->vmod_names[i] == atom) - return i + XkbNumModifiers; + return i + XKB_NUM_CORE_MODS; } return XKB_MOD_INVALID; @@ -231,7 +231,7 @@ GetBuffer(size_t size) /* * Get a vmod name's text, where the vmod index is zero based - * (0..XkbNumVirtualMods-1). + * (0..XKB_NUM_VIRTUAL_MODS-1). */ static const char * VModIndexText(struct xkb_keymap *keymap, xkb_mod_index_t ndx) @@ -241,7 +241,7 @@ VModIndexText(struct xkb_keymap *keymap, xkb_mod_index_t ndx) const char *tmp = NULL; char buf[20]; - if (ndx >= XkbNumVirtualMods) + if (ndx >= XKB_NUM_VIRTUAL_MODS) tmp = "illegal"; else tmp = xkb_atom_text(keymap->ctx, keymap->vmod_names[ndx]); @@ -274,7 +274,7 @@ VModMaskText(struct xkb_keymap *keymap, xkb_mod_mask_t cmask) char buf[BUFFER_SIZE]; rmask = cmask & 0xff; - vmask = cmask >> XkbNumModifiers; + vmask = cmask >> XKB_NUM_CORE_MODS; if (rmask == 0 && vmask == 0) return "none"; @@ -287,7 +287,7 @@ VModMaskText(struct xkb_keymap *keymap, xkb_mod_mask_t cmask) rem = BUFFER_SIZE; if (vmask != 0) { - for (i = 0, bit = 1; i < XkbNumVirtualMods && rem > 1; i++, bit <<= + for (i = 0, bit = 1; i < XKB_NUM_VIRTUAL_MODS && rem > 1; i++, bit <<= 1) { if (!(vmask & bit)) continue; @@ -325,7 +325,7 @@ VModMaskText(struct xkb_keymap *keymap, xkb_mod_mask_t cmask) * ShiftMapIndex, LockMapIndex, etc. from X11/X.h. Take note before * changing. */ -static const char *modNames[XkbNumModifiers] = { +static const char *modNames[XKB_NUM_CORE_MODS] = { "Shift", "Lock", "Control", @@ -341,7 +341,7 @@ ModNameToIndex(const char *name) { xkb_mod_index_t i; - for (i = 0; i < XkbNumModifiers; i++) + for (i = 0; i < XKB_NUM_CORE_MODS; i++) if (istreq(name, modNames[i])) return i; @@ -351,7 +351,7 @@ ModNameToIndex(const char *name) const char * ModIndexToName(xkb_mod_index_t ndx) { - if (ndx < XkbNumModifiers) + if (ndx < XKB_NUM_CORE_MODS) return modNames[ndx]; return NULL; } @@ -393,7 +393,7 @@ ModMaskText(xkb_mod_mask_t mask) buf = GetBuffer(rem); str = buf; buf[0] = '\0'; - for (i = 0, bit = 1; i < XkbNumModifiers && rem > 1; i++, bit <<= 1) { + for (i = 0, bit = 1; i < XKB_NUM_CORE_MODS && rem > 1; i++, bit <<= 1) { int len; if (!(mask & bit)) diff --git a/src/xkb-priv.h b/src/xkb-priv.h index 468cf6b..b9ff714 100644 --- a/src/xkb-priv.h +++ b/src/xkb-priv.h @@ -100,6 +100,8 @@ typedef uint32_t xkb_atom_t; /* These should all be dynamic. */ #define XKB_NUM_GROUPS 4 #define XKB_NUM_INDICATORS 32 +#define XKB_NUM_VIRTUAL_MODS 16 +#define XKB_NUM_CORE_MODS 8 struct xkb_context { int refcnt; @@ -352,8 +354,8 @@ struct xkb_keymap { darray(struct xkb_sym_interpret) sym_interpret; /* vmod -> mod mapping */ - xkb_mod_mask_t vmods[XkbNumVirtualMods]; - xkb_atom_t vmod_names[XkbNumVirtualMods]; + xkb_mod_mask_t vmods[XKB_NUM_VIRTUAL_MODS]; + xkb_atom_t vmod_names[XKB_NUM_VIRTUAL_MODS]; /* Number of groups in the key with the most groups. */ xkb_group_index_t num_groups; diff --git a/src/xkbcomp/action.c b/src/xkbcomp/action.c index 114d4ea..24ae68f 100644 --- a/src/xkbcomp/action.c +++ b/src/xkbcomp/action.c @@ -915,7 +915,7 @@ HandleRedirectKey(struct xkb_keymap *keymap, union xkb_action *action, else act->mods &= ~(t2 & 0xff); - t2 = (t2 >> XkbNumModifiers) & 0xffff; + t2 = (t2 >> XKB_NUM_CORE_MODS) & 0xffff; act->vmods_mask |= t2; if (field == ACTION_FIELD_MODIFIERS) act->vmods |= t2; diff --git a/src/xkbcomp/keymap.c b/src/xkbcomp/keymap.c index 6529921..b1cd369 100644 --- a/src/xkbcomp/keymap.c +++ b/src/xkbcomp/keymap.c @@ -30,12 +30,12 @@ static void ComputeEffectiveMask(struct xkb_keymap *keymap, struct xkb_mods *mods) { xkb_mod_index_t i; - xkb_mod_mask_t vmask = mods->mods >> XkbNumModifiers; + xkb_mod_mask_t vmask = mods->mods >> XKB_NUM_CORE_MODS; /* The effective mask is only real mods for now. */ mods->mask = mods->mods & 0xff; - for (i = 0; i < XkbNumVirtualMods; i++) { + for (i = 0; i < XKB_NUM_VIRTUAL_MODS; i++) { if (!(vmask & (1 << i))) continue; mods->mask |= keymap->vmods[i]; @@ -212,14 +212,14 @@ UpdateDerivedKeymapFields(struct xkb_keymap *keymap) return false; /* Update keymap->vmods, the virtual -> real mod mapping. */ - for (vmod = 0; vmod < XkbNumVirtualMods; vmod++) + for (vmod = 0; vmod < XKB_NUM_VIRTUAL_MODS; vmod++) keymap->vmods[vmod] = 0; xkb_foreach_key(key, keymap) { if (!key->vmodmap) continue; - for (vmod = 0; vmod < XkbNumVirtualMods; vmod++) { + for (vmod = 0; vmod < XKB_NUM_VIRTUAL_MODS; vmod++) { if (!(key->vmodmap & (1 << vmod))) continue; keymap->vmods[vmod] |= key->modmap; diff --git a/src/xkbcomp/symbols.c b/src/xkbcomp/symbols.c index f4cf0b3..c5edbab 100644 --- a/src/xkbcomp/symbols.c +++ b/src/xkbcomp/symbols.c @@ -1065,7 +1065,7 @@ SetSymbolsField(SymbolsInfo *info, KeyInfo *keyi, const char *field, ok = ExprResolveVModMask(info->keymap, value, &mask); if (ok) { - keyi->vmodmap = (mask >> XkbNumModifiers) & 0xffff; + keyi->vmodmap = (mask >> XKB_NUM_CORE_MODS) & 0xffff; keyi->defined |= KEY_FIELD_VMODMAP; } else { diff --git a/src/xkbcomp/vmod.c b/src/xkbcomp/vmod.c index 56e840c..64db7ed 100644 --- a/src/xkbcomp/vmod.c +++ b/src/xkbcomp/vmod.c @@ -36,7 +36,7 @@ InitVModInfo(VModInfo *info, struct xkb_keymap *keymap) info->defined = info->available = 0; - for (i = 0; i < XkbNumVirtualMods; i++) + for (i = 0; i < XKB_NUM_VIRTUAL_MODS; i++) if (keymap->vmod_names[i]) info->defined |= (1 << i); } @@ -61,7 +61,7 @@ HandleVModDef(VModDef *stmt, struct xkb_keymap *keymap, "Value ignored\n"); nextFree = -1; - for (i = 0, bit = 1; i < XkbNumVirtualMods; i++, bit <<= 1) { + for (i = 0, bit = 1; i < XKB_NUM_VIRTUAL_MODS; i++, bit <<= 1) { if (!(info->defined & bit)) { if (nextFree < 0) nextFree = i; @@ -82,7 +82,7 @@ HandleVModDef(VModDef *stmt, struct xkb_keymap *keymap, if (nextFree < 0) { log_err(keymap->ctx, "Too many virtual modifiers defined (maximum %d)\n", - XkbNumVirtualMods); + XKB_NUM_VIRTUAL_MODS); return false; } @@ -102,7 +102,7 @@ LookupVModIndex(const struct xkb_keymap *keymap, xkb_atom_t field, if (type != EXPR_TYPE_INT) return false; - for (i = 0; i < XkbNumVirtualMods; i++) { + for (i = 0; i < XKB_NUM_VIRTUAL_MODS; i++) { if (keymap->vmod_names[i] == field) { *val_rtrn = i; return true; @@ -122,7 +122,7 @@ LookupVModMask(struct xkb_context *ctx, const void *priv, xkb_atom_t field, return true; } else if (LookupVModIndex(priv, field, type, &ndx)) { - *val_rtrn = (1 << (XkbNumModifiers + ndx)); + *val_rtrn = (1 << (XKB_NUM_CORE_MODS + ndx)); return true; } @@ -144,7 +144,7 @@ ResolveVirtualModifier(ExprDef *def, struct xkb_keymap *keymap, return false; } - for (i = 0; i < XkbNumVirtualMods; i++) { + for (i = 0; i < XKB_NUM_VIRTUAL_MODS; i++) { if ((info->available & (1 << i)) && keymap->vmod_names[i] == name) { *ndx_rtrn = i; return true; |