Correct modifier map built when ProcSetModifierMapping is called

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 <alan.coopersmith@sun.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
Alan Coopersmith 2009-08-03 23:49:56 -07:00 committed by Peter Hutterer
parent 4ca305956e
commit 95b678e6dc

View File

@ -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;