Fixes xmodmap changes to modifiers to stop corrupting modifier maps

Previous code had two bugs:
 - the code to increment mod was after the code to continue if no
   modifier was set, so mod wouldn't be incremented for modifiers
   with no keys mapped to them (such as if you called
   xmodmap -e 'clear Lock')
 - the value it set in the modifier map was the raw modifier number,
   not the bitmask value for that modifier

Signed-off-by: Alan Coopersmith <[email protected]>
---
 dix/inpututils.c |    6 ++----
 1 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/dix/inpututils.c b/dix/inpututils.c
index 378deb0..66936c9 100644
--- a/dix/inpututils.c
+++ b/dix/inpututils.c
@@ -227,7 +227,7 @@ do_modmap_change(ClientPtr client, DeviceIntPtr dev, CARD8 
*modmap)
 static int build_modmap_from_modkeymap(CARD8 *modmap, KeyCode *modkeymap,
                                        int max_keys_per_mod)
 {
-    int i, mod = 0, len = max_keys_per_mod * 8;
+    int i, len = max_keys_per_mod * 8;
 
     memset(modmap, 0, MAP_LENGTH);
 
@@ -241,9 +241,7 @@ static int build_modmap_from_modkeymap(CARD8 *modmap, 
KeyCode *modkeymap,
         if (modmap[modkeymap[i]])
             return BadValue;
 
-        if (!(i % max_keys_per_mod))
-            mod++;
-        modmap[modkeymap[i]] = mod;
+        modmap[modkeymap[i]] = 1 << (i / max_keys_per_mod);
     }
 
     return Success;
-- 
1.5.6.5

_______________________________________________
xorg-devel mailing list
[email protected]
http://lists.x.org/mailman/listinfo/xorg-devel

Reply via email to