--- orig/programs/Xserver/hw/xfree86/input/keyboard/kbd.c 2004-12-15 22:38:45.000000000 -0500 +++ new/programs/Xserver/hw/xfree86/input/keyboard/kbd.c 2005-05-03 11:51:19.000000000 -0400 @@ -536,6 +536,8 @@ int keycode; unsigned long changeLock = 0; static int lockkeys = 0; + static unsigned char firsttime=1; + static CARD8 keypressed[DOWN_LENGTH]; /* 1 bit for each keycode, same as the KeyPressed() macro */ /* Disable any keyboard processing while in suspend */ if (xf86inSuspend) @@ -719,9 +721,11 @@ #endif /* - * check for an autorepeat-event + * check for an autorepeat-event (two presses without a release between them). + * We can't use the KeyPressed macro because there may be a release event that + * hasn't been processed yet, so we track the status here. */ - if (down && KeyPressed(keycode)) { + if (down && (keypressed[keycode >> 3] & (1 << (keycode & 7)))) { int num = keycode >> 3; int bit = 1 << (keycode & 7); @@ -731,6 +735,12 @@ return; } + /* Note whether this key was just pressed or released */ + if (down) + keypressed[keycode >> 3]|=1 << (keycode & 7); + else + keypressed[keycode >> 3]&=~(1 << (keycode & 7)); + if (UsePrefix) { xf86PostKeyboardEvent(device, keyc->modifierKeyMap[keyc->maxKeysPerModifier*7], TRUE);