RWS@ZERMATT.LCS.MIT.EDU (Robert Scheifler) (10/22/87)
VERSION:
X11 release 1
SYNOPSIS:
Lock keys on VAXen and Suns don't toggle, but just act like
vanilla shift keys.
Pressing or releasing a modifier key on a Sun disables
autorepeat on any "real" key that is down.
FIX:
3 files: server/dix/events.c, server/ddx/lk201/lk201.c, server/ddx/sun/sunKbd.c
in server/dix/events.c:
*** /tmp/,RCSt1003374 Thu Oct 22 09:07:06 1987
--- events.c Thu Oct 22 09:06:37 1987
***************
*** 23,29 ****
********************************************************/
! /* $Header: events.c,v 1.109 87/10/02 15:31:47 rws Exp $ */
#include "X.h"
#include "misc.h"
--- 23,29 ----
********************************************************/
! /* $Header: events.c,v 1.110 87/10/22 09:05:38 rws Exp $ */
#include "X.h"
#include "misc.h"
***************
*** 155,161 ****
* This is a CARD16 bitmap 'cos it includes the mouse buttons to
* make grab processing simpler.
*/
! static CARD16 keyModifiersList[MAP_LENGTH];
static CARD16 maxKeysPerModifier;
/*
* We also keep a copy of the modifier map in the format
--- 155,161 ----
* This is a CARD16 bitmap 'cos it includes the mouse buttons to
* make grab processing simpler.
*/
! CARD16 keyModifiersList[MAP_LENGTH];
static CARD16 maxKeysPerModifier;
/*
* We also keep a copy of the modifier map in the format
in server/ddx/lk201/lk201.c:
*** /tmp/,RCSt1003408 Thu Oct 22 09:16:33 1987
--- lk201.c Thu Oct 22 09:16:11 1987
***************
*** 21,27 ****
SOFTWARE.
********************************************************/
! /* $Header: lk201.c,v 1.25 87/09/13 00:51:54 toddb Exp $ */
#include "X.h"
#define NEED_EVENTS
--- 21,27 ----
SOFTWARE.
********************************************************/
! /* $Header: lk201.c,v 1.26 87/10/22 09:15:45 rws Exp $ */
#include "X.h"
#define NEED_EVENTS
***************
*** 32,39 ****
/* This file is device dependent, but is common to several devices */
#include <sys/types.h>
! #include "input.h"
#define KEYDOWN_ERROR 0x3d
#define POWERUP_ERROR 0x3e
#define BASEKEY 0x41
--- 32,41 ----
/* This file is device dependent, but is common to several devices */
#include <sys/types.h>
! #include "inputstr.h"
+ extern CARD16 keyModifiersList[];
+
#define KEYDOWN_ERROR 0x3d
#define POWERUP_ERROR 0x3e
#define BASEKEY 0x41
***************
*** 58,63 ****
--- 60,69 ----
/* Handle keyboard input from LK201 */
+ /* Whatever key is associated with the Lock modifier is treated as a toggle key.
+ * The code assumes that such keys are always in up/down mode.
+ */
+
void
ProcessLK201Input (e, dev)
register xEvent *e;
***************
*** 79,84 ****
--- 85,97 ----
e->u.u.type = KeyPress;
else
e->u.u.type = KeyRelease;
+ if (keyModifiersList[lastkey] & LockMask)
+ {
+ if (e->u.u.type == KeyRelease)
+ return;
+ if (((DeviceIntPtr)dev)->down[lastkey >> 3] & (1 << (lastkey & 7)))
+ e->u.u.type = KeyRelease;
+ }
(*dev->processInputProc)(e, dev);
}
else
***************
*** 114,120 ****
if (bits & 1)
{
e->u.u.detail = (idx << 5) | key;
! (*dev->processInputProc)(e, dev);
}
key++;
} while (bits >>= 1);
--- 127,134 ----
if (bits & 1)
{
e->u.u.detail = (idx << 5) | key;
! if (!(keyModifiersList[e->u.u.detail] & LockMask))
! (*dev->processInputProc)(e, dev);
}
key++;
} while (bits >>= 1);
in server/ddx/sun/sunKbd.c:
*** /tmp/,RCSt1003433 Thu Oct 22 09:20:46 1987
--- sunKbd.c Thu Oct 22 09:20:27 1987
***************
*** 51,57 ****
--- 51,60 ----
#include <stdio.h>
#include "Xproto.h"
#include "keysym.h"
+ #include "inputstr.h"
+ extern CARD16 keyModifiersList[];
+
typedef struct {
int trans; /* Original translation form */
} SunKbPrivRec, *SunKbPrivPtr;
***************
*** 365,370 ****
--- 368,374 ----
PtrPrivPtr ptrPriv;
int delta;
static xEvent autoRepeatEvent;
+ BYTE key;
ptrPriv = (PtrPrivPtr) LookupPointerDevice()->devicePrivate;
***************
*** 402,421 ****
return;
}
! /*
! * Kill AutoRepeater on any real Kbd event.
! */
! autoRepeatKeyDown = 0;
! if (autoRepeatDebug)
! ErrorF("sunKbdProcessEvent: autoRepeat off\n");
xE.u.keyButtonPointer.time = TVTOMILLI(fe->time);
xE.u.keyButtonPointer.rootX = ptrPriv->x;
xE.u.keyButtonPointer.rootY = ptrPriv->y;
xE.u.u.type = ((fe->value == VKEY_UP) ? KeyRelease : KeyPress);
! xE.u.u.detail = (fe->id & 0x7F) + sysKbPriv.offset;
! if (fe->value == VKEY_DOWN) { /* turn on AutoRepeater */
if (autoRepeatDebug)
ErrorF("sunKbdProcessEvent: VKEY_DOWN\n");
autoRepeatEvent = xE;
--- 406,438 ----
return;
}
! key = (fe->id & 0x7F) + sysKbPriv.offset;
! if (!keyModifiersList[key])
! {
! /*
! * Kill AutoRepeater on any real non-modifier Kbd event.
! */
! autoRepeatKeyDown = 0;
! if (autoRepeatDebug)
! ErrorF("sunKbdProcessEvent: autoRepeat off\n");
! }
xE.u.keyButtonPointer.time = TVTOMILLI(fe->time);
xE.u.keyButtonPointer.rootX = ptrPriv->x;
xE.u.keyButtonPointer.rootY = ptrPriv->y;
xE.u.u.type = ((fe->value == VKEY_UP) ? KeyRelease : KeyPress);
! xE.u.u.detail = key;
! if (keyModifiersList[key] & LockMask)
! {
! if (xE.u.u.type == KeyRelease)
! return; /* this assumes autorepeat is not desired */
! if (((DeviceIntPtr)pKeyboard)->down[key >> 3] & (1 << (key & 7)))
! xE.u.u.type = KeyRelease;
! }
!
! if ((fe->value == VKEY_DOWN) && !autoRepeatKeyDown)
! { /* turn on AutoRepeater */
if (autoRepeatDebug)
ErrorF("sunKbdProcessEvent: VKEY_DOWN\n");
autoRepeatEvent = xE;