Commit ae968f855a70613920737a7523a3fd369c60802e

Ran Benita 2012-08-01T11:01:21

map: fix virtual mod index calculation The current code made us miss vmod index 0. Also look at the code in vmod.c:LookupVModMask. Signed-off-by: Ran Benita <ran234@gmail.com>

diff --git a/src/map.c b/src/map.c
index 56fe13b..7dc9a57 100644
--- a/src/map.c
+++ b/src/map.c
@@ -64,8 +64,8 @@ xkb_map_num_mods(struct xkb_keymap *keymap)
             break;
 
     /* We always have all the core modifiers (for now), plus any virtual
-     * modifiers we may have defined, and then shift to one-based indexing. */
-    return i + Mod5MapIndex + 1;
+     * modifiers we may have defined. */
+    return i + XkbNumModifiers;
 }
 
 /**
@@ -100,7 +100,7 @@ xkb_map_mod_get_name(struct xkb_keymap *keymap, xkb_mod_index_t idx)
     }
 
     /* If that fails, try to find a virtual mod name. */
-    return keymap->vmod_names[idx - Mod5MapIndex];
+    return keymap->vmod_names[idx - XkbNumModifiers];
 }
 
 /**
@@ -130,7 +130,7 @@ xkb_map_mod_get_index(struct xkb_keymap *keymap, const char *name)
 
     for (i = 0; i < XkbNumVirtualMods && keymap->vmod_names[i]; i++) {
         if (istreq(name, keymap->vmod_names[i]))
-            return i + Mod5MapIndex;
+            return i + XkbNumModifiers;
     }
 
     return XKB_GROUP_INVALID;