make core keyboard/pointer map functions act on all core-sending devices

Make Set{Keyboard,Modifier,Pointer}Mapping act on all devices which send core
events.
Change LegalModifier to accept a DeviceIntPtr.
This commit is contained in:
Daniel Stone 2006-09-29 00:34:23 +03:00 committed by Daniel Stone
parent a5d639cd87
commit ad631afcf3
19 changed files with 299 additions and 237 deletions

View File

@ -1139,112 +1139,102 @@ AllModifierKeysAreUp(dev, map1, per1, map2, per2)
return TRUE; return TRUE;
} }
static int
DoSetModifierMapping(ClientPtr client, KeyCode *inputMap,
int numKeyPerModifier)
{
KeyClassPtr keyc = NULL;
DeviceIntPtr pDev = NULL;
KeyCode *map = NULL;
int i = 0, inputMapLen = numKeyPerModifier * 8;
for (pDev = inputInfo.devices; pDev; pDev = pDev->next) {
if ((pDev->coreEvents || pDev == inputInfo.keyboard) && pDev->key) {
for (i = 0; i < inputMapLen; i++) {
/* Check that all the new modifiers fall within the advertised
* keycode range, and are okay with the DDX. */
if (inputMap[i] && ((inputMap[i] < pDev->key->curKeySyms.minKeyCode ||
inputMap[i] > pDev->key->curKeySyms.maxKeyCode) ||
!LegalModifier(inputMap[i], pDev))) {
client->errorValue = inputMap[i];
return BadValue;
}
}
#ifdef XCSECURITY
if (!SecurityCheckDeviceAccess(client, pDev, TRUE))
return BadAccess;
#endif
/* None of the modifiers (old or new) may be down while we change
* the map. */
if (!AllModifierKeysAreUp(pDev, pDev->key->modifierKeyMap,
pDev->key->maxKeysPerModifier,
inputMap, numKeyPerModifier) ||
!AllModifierKeysAreUp(pDev, inputMap, numKeyPerModifier,
pDev->key->modifierKeyMap,
pDev->key->maxKeysPerModifier)) {
return MappingBusy;
}
}
}
for (pDev = inputInfo.devices; pDev; pDev = pDev->next) {
if ((pDev->coreEvents || pDev == inputInfo.keyboard) && pDev->key) {
bzero(pDev->key->modifierMap, MAP_LENGTH);
/* Annoyingly, we lack a modifierKeyMap size, so we have to just free
* and re-alloc it every time. */
if (pDev->key->modifierKeyMap)
xfree(pDev->key->modifierKeyMap);
if (inputMapLen) {
pDev->key->modifierKeyMap = (KeyCode *) xalloc(inputMapLen);
if (!pDev->key->modifierKeyMap)
return BadAlloc;
memcpy(pDev->key->modifierKeyMap, inputMap, inputMapLen);
pDev->key->maxKeysPerModifier = numKeyPerModifier;
for (i = 0; i < inputMapLen; i++) {
if (inputMap[i]) {
pDev->key->modifierMap[inputMap[i]] |=
(1 << (((unsigned int)i) / numKeyPerModifier));
}
}
}
else {
pDev->key->modifierKeyMap = NULL;
}
}
}
return Success;
}
int int
ProcSetModifierMapping(ClientPtr client) ProcSetModifierMapping(ClientPtr client)
{ {
xSetModifierMappingReply rep; xSetModifierMappingReply rep;
REQUEST(xSetModifierMappingReq); REQUEST(xSetModifierMappingReq);
KeyCode *inputMap;
int inputMapLen;
register int i; register int i;
DeviceIntPtr keybd = inputInfo.keyboard; DeviceIntPtr keybd = inputInfo.keyboard;
register KeyClassPtr keyc = keybd->key;
REQUEST_AT_LEAST_SIZE(xSetModifierMappingReq); REQUEST_AT_LEAST_SIZE(xSetModifierMappingReq);
if (client->req_len != ((stuff->numKeyPerModifier<<1) + if (client->req_len != ((stuff->numKeyPerModifier << 1) +
(sizeof (xSetModifierMappingReq)>>2))) (sizeof (xSetModifierMappingReq) >> 2)))
return BadLength; return BadLength;
inputMapLen = 8*stuff->numKeyPerModifier;
inputMap = (KeyCode *)&stuff[1];
/*
* Now enforce the restriction that "all of the non-zero keycodes must be
* in the range specified by min-keycode and max-keycode in the
* connection setup (else a Value error)"
*/
i = inputMapLen;
while (i--)
{
if (inputMap[i]
&& (inputMap[i] < keyc->curKeySyms.minKeyCode
|| inputMap[i] > keyc->curKeySyms.maxKeyCode))
{
client->errorValue = inputMap[i];
return BadValue;
}
}
#ifdef XCSECURITY
if (!SecurityCheckDeviceAccess(client, keybd, TRUE))
return BadAccess;
#endif
rep.type = X_Reply; rep.type = X_Reply;
rep.length = 0; rep.length = 0;
rep.sequenceNumber = client->sequence; rep.sequenceNumber = client->sequence;
rep.success = MappingSuccess;
/* rep.success = DoSetModifierMapping(client, (KeyCode *)&stuff[1],
* Now enforce the restriction that none of the old or new stuff->numKeyPerModifier);
* modifier keys may be down while we change the mapping, and
* that the DDX layer likes the choice.
*/
if (!AllModifierKeysAreUp(keybd, keyc->modifierKeyMap,
(int)keyc->maxKeysPerModifier,
inputMap, (int)stuff->numKeyPerModifier)
||
!AllModifierKeysAreUp(keybd, inputMap, (int)stuff->numKeyPerModifier,
keyc->modifierKeyMap,
(int)keyc->maxKeysPerModifier))
{
rep.success = MappingBusy;
}
else
{
for (i = 0; i < inputMapLen; i++)
{
if (inputMap[i] && !LegalModifier(inputMap[i], (DevicePtr)keybd))
{
rep.success = MappingFailed;
break;
}
}
}
if (rep.success == MappingSuccess)
{
KeyCode *map;
/*
* Now build the keyboard's modifier bitmap from the
* list of keycodes.
*/
map = (KeyCode *)xalloc(inputMapLen);
if (!map && inputMapLen)
return BadAlloc;
if (keyc->modifierKeyMap)
xfree(keyc->modifierKeyMap);
keyc->modifierKeyMap = map;
memmove((char *)map, (char *)inputMap, inputMapLen);
keyc->maxKeysPerModifier = stuff->numKeyPerModifier;
for (i = 0; i < MAP_LENGTH; i++)
keyc->modifierMap[i] = 0;
for (i = 0; i < inputMapLen; i++)
{
if (inputMap[i])
keyc->modifierMap[inputMap[i]] |=
(1<<(((unsigned int)i)/keyc->maxKeysPerModifier));
}
}
if (rep.success == MappingSuccess)
SendMappingNotify(MappingModifier, 0, 0, client);
/* FIXME: Send mapping notifies for all the extended devices as well. */
SendMappingNotify(MappingModifier, 0, 0, client);
WriteReplyToClient(client, sizeof(xSetModifierMappingReply), &rep); WriteReplyToClient(client, sizeof(xSetModifierMappingReply), &rep);
return client->noClientException;
return(client->noClientException);
} }
int int
@ -1274,40 +1264,80 @@ ProcChangeKeyboardMapping(ClientPtr client)
REQUEST(xChangeKeyboardMappingReq); REQUEST(xChangeKeyboardMappingReq);
unsigned len; unsigned len;
KeySymsRec keysyms; KeySymsRec keysyms;
register KeySymsPtr curKeySyms = &inputInfo.keyboard->key->curKeySyms; KeySymsPtr curKeySyms = &inputInfo.keyboard->key->curKeySyms;
DeviceIntPtr pDev = NULL;
REQUEST_AT_LEAST_SIZE(xChangeKeyboardMappingReq); REQUEST_AT_LEAST_SIZE(xChangeKeyboardMappingReq);
len = client->req_len - (sizeof(xChangeKeyboardMappingReq) >> 2); len = client->req_len - (sizeof(xChangeKeyboardMappingReq) >> 2);
if (len != (stuff->keyCodes * stuff->keySymsPerKeyCode)) if (len != (stuff->keyCodes * stuff->keySymsPerKeyCode))
return BadLength; return BadLength;
if ((stuff->firstKeyCode < curKeySyms->minKeyCode) || if ((stuff->firstKeyCode < curKeySyms->minKeyCode) ||
(stuff->firstKeyCode > curKeySyms->maxKeyCode)) (stuff->firstKeyCode > curKeySyms->maxKeyCode)) {
{
client->errorValue = stuff->firstKeyCode; client->errorValue = stuff->firstKeyCode;
return BadValue; return BadValue;
} }
if ( ((unsigned)(stuff->firstKeyCode + stuff->keyCodes - 1) > if (((unsigned)(stuff->firstKeyCode + stuff->keyCodes - 1) >
curKeySyms->maxKeyCode) || curKeySyms->maxKeyCode) || (stuff->keySymsPerKeyCode == 0)) {
(stuff->keySymsPerKeyCode == 0))
{
client->errorValue = stuff->keySymsPerKeyCode; client->errorValue = stuff->keySymsPerKeyCode;
return BadValue; return BadValue;
} }
#ifdef XCSECURITY #ifdef XCSECURITY
if (!SecurityCheckDeviceAccess(client, inputInfo.keyboard, for (pDev = inputInfo.devices; pDev; pDev = pDev->next) {
TRUE)) if ((pDev->coreEvents || pDev == inputInfo.keyboard) && pDev->key) {
return BadAccess; if (!SecurityCheckDeviceAccess(client, pDev, TRUE))
return BadAccess;
}
}
#endif #endif
keysyms.minKeyCode = stuff->firstKeyCode; keysyms.minKeyCode = stuff->firstKeyCode;
keysyms.maxKeyCode = stuff->firstKeyCode + stuff->keyCodes - 1; keysyms.maxKeyCode = stuff->firstKeyCode + stuff->keyCodes - 1;
keysyms.mapWidth = stuff->keySymsPerKeyCode; keysyms.mapWidth = stuff->keySymsPerKeyCode;
keysyms.map = (KeySym *)&stuff[1]; keysyms.map = (KeySym *)&stuff[1];
if (!SetKeySymsMap(curKeySyms, &keysyms)) for (pDev = inputInfo.devices; pDev; pDev = pDev->next) {
return BadAlloc; if ((pDev->coreEvents || pDev == inputInfo.keyboard) && pDev->key) {
SendMappingNotify(MappingKeyboard, stuff->firstKeyCode, stuff->keyCodes, if (!SetKeySymsMap(&pDev->key->curKeySyms, &keysyms))
client); return BadAlloc;
return client->noClientException; }
}
/* FIXME: Send mapping notifies for all the extended devices as well. */
SendMappingNotify(MappingKeyboard, stuff->firstKeyCode, stuff->keyCodes,
client);
return client->noClientException;
}
static int
DoSetPointerMapping(DeviceIntPtr device, BYTE *map, int n)
{
int i = 0;
DeviceIntPtr dev = NULL;
if (!device || !device->button)
return BadDevice;
for (dev = inputInfo.devices; dev; dev = dev->next) {
if ((dev->coreEvents || dev == inputInfo.pointer) && dev->button) {
for (i = 0; i < n; i++) {
if ((device->button->map[i + 1] != map[i]) &&
BitIsOn(device->button->down, i + 1)) {
return MappingBusy;
}
}
}
}
for (dev = inputInfo.devices; dev; dev = dev->next) {
if ((dev->coreEvents || dev == inputInfo.pointer) && dev->button) {
for (i = 0; i < n; i++)
dev->button->map[i + 1] = map[i];
}
}
return Success;
} }
int int
@ -1315,9 +1345,9 @@ ProcSetPointerMapping(ClientPtr client)
{ {
REQUEST(xSetPointerMappingReq); REQUEST(xSetPointerMappingReq);
BYTE *map; BYTE *map;
int ret;
xSetPointerMappingReply rep; xSetPointerMappingReply rep;
register unsigned int i; unsigned int i;
DeviceIntPtr mouse = inputInfo.pointer;
REQUEST_AT_LEAST_SIZE(xSetPointerMappingReq); REQUEST_AT_LEAST_SIZE(xSetPointerMappingReq);
if (client->req_len != (sizeof(xSetPointerMappingReq)+stuff->nElts+3) >> 2) if (client->req_len != (sizeof(xSetPointerMappingReq)+stuff->nElts+3) >> 2)
@ -1327,23 +1357,24 @@ ProcSetPointerMapping(ClientPtr client)
rep.sequenceNumber = client->sequence; rep.sequenceNumber = client->sequence;
rep.success = MappingSuccess; rep.success = MappingSuccess;
map = (BYTE *)&stuff[1]; map = (BYTE *)&stuff[1];
if (stuff->nElts != mouse->button->numButtons)
{ /* So we're bounded here by the number of core buttons. This check
* probably wants disabling through XFixes. */
if (stuff->nElts != inputInfo.pointer->button->numButtons) {
client->errorValue = stuff->nElts; client->errorValue = stuff->nElts;
return BadValue; return BadValue;
} }
if (BadDeviceMap(&map[0], (int)stuff->nElts, 1, 255, &client->errorValue)) if (BadDeviceMap(&map[0], (int)stuff->nElts, 1, 255, &client->errorValue))
return BadValue; return BadValue;
for (i=0; i < stuff->nElts; i++)
if ((mouse->button->map[i + 1] != map[i]) && ret = DoSetPointerMapping(inputInfo.pointer, map, stuff->nElts);
BitIsOn(mouse->button->down, i + 1)) if (ret != Success) {
{ rep.success = ret;
rep.success = MappingBusy; WriteReplyToClient(client, sizeof(xSetPointerMappingReply), &rep);
WriteReplyToClient(client, sizeof(xSetPointerMappingReply), &rep); return Success;
return Success; }
}
for (i = 0; i < stuff->nElts; i++) /* FIXME: Send mapping notifies for all the extended devices as well. */
mouse->button->map[i + 1] = map[i];
SendMappingNotify(MappingPointer, 0, 0, client); SendMappingNotify(MappingPointer, 0, 0, client);
WriteReplyToClient(client, sizeof(xSetPointerMappingReply), &rep); WriteReplyToClient(client, sizeof(xSetPointerMappingReply), &rep);
return Success; return Success;
@ -1359,14 +1390,12 @@ ProcGetKeyboardMapping(ClientPtr client)
REQUEST_SIZE_MATCH(xGetKeyboardMappingReq); REQUEST_SIZE_MATCH(xGetKeyboardMappingReq);
if ((stuff->firstKeyCode < curKeySyms->minKeyCode) || if ((stuff->firstKeyCode < curKeySyms->minKeyCode) ||
(stuff->firstKeyCode > curKeySyms->maxKeyCode)) (stuff->firstKeyCode > curKeySyms->maxKeyCode)) {
{
client->errorValue = stuff->firstKeyCode; client->errorValue = stuff->firstKeyCode;
return BadValue; return BadValue;
} }
if (stuff->firstKeyCode + stuff->count > if (stuff->firstKeyCode + stuff->count >
(unsigned)(curKeySyms->maxKeyCode + 1)) (unsigned)(curKeySyms->maxKeyCode + 1)) {
{
client->errorValue = stuff->count; client->errorValue = stuff->count;
return BadValue; return BadValue;
} }
@ -1423,47 +1452,31 @@ Ones(unsigned long mask) /* HACKMEM 169 */
return (((y + (y >> 3)) & 030707070707) % 077); return (((y + (y >> 3)) & 030707070707) % 077);
} }
int static int
ProcChangeKeyboardControl (ClientPtr client) DoChangeKeyboardControl (ClientPtr client, DeviceIntPtr keybd, XID *vlist,
BITS32 vmask)
{ {
#define DO_ALL (-1) #define DO_ALL (-1)
KeybdCtrl ctrl; KeybdCtrl ctrl;
DeviceIntPtr keybd = inputInfo.keyboard;
XID *vlist;
int t; int t;
int led = DO_ALL; int led = DO_ALL;
int key = DO_ALL; int key = DO_ALL;
BITS32 vmask, index2; BITS32 index2;
int mask, i; int mask = vmask, i;
REQUEST(xChangeKeyboardControlReq); DeviceIntPtr dev = NULL;
REQUEST_AT_LEAST_SIZE(xChangeKeyboardControlReq);
if (!keybd->kbdfeed->CtrlProc)
return BadDevice;
vmask = stuff->mask;
if (client->req_len != (sizeof(xChangeKeyboardControlReq)>>2)+Ones(vmask))
return BadLength;
#ifdef XCSECURITY
if (!SecurityCheckDeviceAccess(client, keybd, TRUE))
return BadAccess;
#endif
vlist = (XID *)&stuff[1]; /* first word of values */
ctrl = keybd->kbdfeed->ctrl; ctrl = keybd->kbdfeed->ctrl;
while (vmask) while (vmask) {
{
index2 = (BITS32) lowbit (vmask); index2 = (BITS32) lowbit (vmask);
vmask &= ~index2; vmask &= ~index2;
switch (index2) switch (index2) {
{
case KBKeyClickPercent: case KBKeyClickPercent:
t = (INT8)*vlist; t = (INT8)*vlist;
vlist++; vlist++;
if (t == -1) if (t == -1) {
t = defaultKeyboardControl.click; t = defaultKeyboardControl.click;
else if (t < 0 || t > 100) }
{ else if (t < 0 || t > 100) {
client->errorValue = t; client->errorValue = t;
return BadValue; return BadValue;
} }
@ -1472,10 +1485,10 @@ ProcChangeKeyboardControl (ClientPtr client)
case KBBellPercent: case KBBellPercent:
t = (INT8)*vlist; t = (INT8)*vlist;
vlist++; vlist++;
if (t == -1) if (t == -1) {
t = defaultKeyboardControl.bell; t = defaultKeyboardControl.bell;
else if (t < 0 || t > 100) }
{ else if (t < 0 || t > 100) {
client->errorValue = t; client->errorValue = t;
return BadValue; return BadValue;
} }
@ -1484,10 +1497,10 @@ ProcChangeKeyboardControl (ClientPtr client)
case KBBellPitch: case KBBellPitch:
t = (INT16)*vlist; t = (INT16)*vlist;
vlist++; vlist++;
if (t == -1) if (t == -1) {
t = defaultKeyboardControl.bell_pitch; t = defaultKeyboardControl.bell_pitch;
else if (t < 0) }
{ else if (t < 0) {
client->errorValue = t; client->errorValue = t;
return BadValue; return BadValue;
} }
@ -1498,8 +1511,7 @@ ProcChangeKeyboardControl (ClientPtr client)
vlist++; vlist++;
if (t == -1) if (t == -1)
t = defaultKeyboardControl.bell_duration; t = defaultKeyboardControl.bell_duration;
else if (t < 0) else if (t < 0) {
{
client->errorValue = t; client->errorValue = t;
return BadValue; return BadValue;
} }
@ -1508,56 +1520,51 @@ ProcChangeKeyboardControl (ClientPtr client)
case KBLed: case KBLed:
led = (CARD8)*vlist; led = (CARD8)*vlist;
vlist++; vlist++;
if (led < 1 || led > 32) if (led < 1 || led > 32) {
{
client->errorValue = led; client->errorValue = led;
return BadValue; return BadValue;
} }
if (!(stuff->mask & KBLedMode)) if (!(mask & KBLedMode))
return BadMatch; return BadMatch;
break; break;
case KBLedMode: case KBLedMode:
t = (CARD8)*vlist; t = (CARD8)*vlist;
vlist++; vlist++;
if (t == LedModeOff) if (t == LedModeOff) {
{
if (led == DO_ALL) if (led == DO_ALL)
ctrl.leds = 0x0; ctrl.leds = 0x0;
else else
ctrl.leds &= ~(((Leds)(1)) << (led - 1)); ctrl.leds &= ~(((Leds)(1)) << (led - 1));
} }
else if (t == LedModeOn) else if (t == LedModeOn) {
{
if (led == DO_ALL) if (led == DO_ALL)
ctrl.leds = ~0L; ctrl.leds = ~0L;
else else
ctrl.leds |= (((Leds)(1)) << (led - 1)); ctrl.leds |= (((Leds)(1)) << (led - 1));
} }
else else {
{
client->errorValue = t; client->errorValue = t;
return BadValue; return BadValue;
} }
#ifdef XKB #ifdef XKB
if (!noXkbExtension) { if (!noXkbExtension) {
XkbEventCauseRec cause; XkbEventCauseRec cause;
XkbSetCauseCoreReq(&cause,X_ChangeKeyboardControl,client); XkbSetCauseCoreReq(&cause,X_ChangeKeyboardControl,client);
XkbSetIndicators(keybd,((led == DO_ALL) ? ~0L : (1L<<(led-1))), XkbSetIndicators(keybd,((led == DO_ALL) ? ~0L : (1L<<(led-1))),
ctrl.leds, &cause); ctrl.leds, &cause);
ctrl.leds = keybd->kbdfeed->ctrl.leds; ctrl.leds = keybd->kbdfeed->ctrl.leds;
} }
#endif #endif
break; break;
case KBKey: case KBKey:
key = (KeyCode)*vlist; key = (KeyCode)*vlist;
vlist++; vlist++;
if ((KeyCode)key < inputInfo.keyboard->key->curKeySyms.minKeyCode || if ((KeyCode)key < inputInfo.keyboard->key->curKeySyms.minKeyCode ||
(KeyCode)key > inputInfo.keyboard->key->curKeySyms.maxKeyCode) (KeyCode)key > inputInfo.keyboard->key->curKeySyms.maxKeyCode) {
{
client->errorValue = key; client->errorValue = key;
return BadValue; return BadValue;
} }
if (!(stuff->mask & KBAutoRepeatMode)) if (!(mask & KBAutoRepeatMode))
return BadMatch; return BadMatch;
break; break;
case KBAutoRepeatMode: case KBAutoRepeatMode:
@ -1566,25 +1573,22 @@ ProcChangeKeyboardControl (ClientPtr client)
t = (CARD8)*vlist; t = (CARD8)*vlist;
vlist++; vlist++;
#ifdef XKB #ifdef XKB
if (!noXkbExtension && key != DO_ALL) if (!noXkbExtension && key != DO_ALL)
XkbDisableComputedAutoRepeats(keybd,key); XkbDisableComputedAutoRepeats(keybd,key);
#endif #endif
if (t == AutoRepeatModeOff) if (t == AutoRepeatModeOff) {
{
if (key == DO_ALL) if (key == DO_ALL)
ctrl.autoRepeat = FALSE; ctrl.autoRepeat = FALSE;
else else
ctrl.autoRepeats[i] &= ~mask; ctrl.autoRepeats[i] &= ~mask;
} }
else if (t == AutoRepeatModeOn) else if (t == AutoRepeatModeOn) {
{
if (key == DO_ALL) if (key == DO_ALL)
ctrl.autoRepeat = TRUE; ctrl.autoRepeat = TRUE;
else else
ctrl.autoRepeats[i] |= mask; ctrl.autoRepeats[i] |= mask;
} }
else if (t == AutoRepeatModeDefault) else if (t == AutoRepeatModeDefault) {
{
if (key == DO_ALL) if (key == DO_ALL)
ctrl.autoRepeat = defaultKeyboardControl.autoRepeat; ctrl.autoRepeat = defaultKeyboardControl.autoRepeat;
else else
@ -1592,31 +1596,71 @@ ProcChangeKeyboardControl (ClientPtr client)
(ctrl.autoRepeats[i] & ~mask) | (ctrl.autoRepeats[i] & ~mask) |
(defaultKeyboardControl.autoRepeats[i] & mask); (defaultKeyboardControl.autoRepeats[i] & mask);
} }
else else {
{
client->errorValue = t; client->errorValue = t;
return BadValue; return BadValue;
} }
break; break;
default: default:
client->errorValue = stuff->mask; client->errorValue = mask;
return BadValue; return BadValue;
} }
} }
keybd->kbdfeed->ctrl = ctrl; keybd->kbdfeed->ctrl = ctrl;
#ifdef XKB #ifdef XKB
/* The XKB RepeatKeys control and core protocol global autorepeat */ /* The XKB RepeatKeys control and core protocol global autorepeat */
/* value are linked */ /* value are linked */
if (!noXkbExtension) { if (!noXkbExtension)
XkbSetRepeatKeys(keybd,key,keybd->kbdfeed->ctrl.autoRepeat); XkbSetRepeatKeys(keybd, key, keybd->kbdfeed->ctrl.autoRepeat);
}
else else
#endif #endif
(*keybd->kbdfeed->CtrlProc)(keybd, &keybd->kbdfeed->ctrl); (*keybd->kbdfeed->CtrlProc)(keybd, &keybd->kbdfeed->ctrl);
return Success; return Success;
#undef DO_ALL #undef DO_ALL
} }
int
ProcChangeKeyboardControl (ClientPtr client)
{
XID *vlist;
BITS32 vmask;
int ret = Success, error = Success;
DeviceIntPtr pDev = NULL;
REQUEST(xChangeKeyboardControlReq);
REQUEST_AT_LEAST_SIZE(xChangeKeyboardControlReq);
vmask = stuff->mask;
vlist = (XID *)&stuff[1];
if (client->req_len != (sizeof(xChangeKeyboardControlReq)>>2)+Ones(vmask))
return BadLength;
#ifdef XCSECURITY
for (pDev = inputInfo.devices; pDev; pDev = pDev->next) {
if ((pDev->coreEvents || pDev == inputInfo.keyboard) &&
pDev->kbdfeed && pDev->kbdfeed->CtrlProc) {
if (!SecurityCheckDeviceAccess(client, pDev, TRUE))
return BadAccess;
}
}
#endif
for (pDev = inputInfo.devices; pDev; pDev = pDev->next) {
if ((pDev->coreEvents || pDev == inputInfo.keyboard) &&
pDev->kbdfeed && pDev->kbdfeed->CtrlProc) {
ret = DoChangeKeyboardControl(client, pDev, vlist, vmask);
if (ret != Success)
error = ret;
}
}
return error;
}
int int
ProcGetKeyboardControl (ClientPtr client) ProcGetKeyboardControl (ClientPtr client)
{ {
@ -1652,24 +1696,31 @@ ProcBell(ClientPtr client)
if (!keybd->kbdfeed->BellProc) if (!keybd->kbdfeed->BellProc)
return BadDevice; return BadDevice;
if (stuff->percent < -100 || stuff->percent > 100) if (stuff->percent < -100 || stuff->percent > 100) {
{
client->errorValue = stuff->percent; client->errorValue = stuff->percent;
return BadValue; return BadValue;
} }
newpercent = (base * stuff->percent) / 100; newpercent = (base * stuff->percent) / 100;
if (stuff->percent < 0) if (stuff->percent < 0)
newpercent = base + newpercent; newpercent = base + newpercent;
else else
newpercent = base - newpercent + stuff->percent; newpercent = base - newpercent + stuff->percent;
for (keybd = inputInfo.devices; keybd; keybd = keybd->next) {
if ((keybd->coreEvents || keybd == inputInfo.keyboard) &&
keybd->kbdfeed && keybd->kbdfeed->BellProc) {
#ifdef XKB #ifdef XKB
if (!noXkbExtension) if (!noXkbExtension)
XkbHandleBell(FALSE,FALSE, keybd, newpercent, &keybd->kbdfeed->ctrl, 0, XkbHandleBell(FALSE, FALSE, keybd, newpercent,
None, NULL, client); &keybd->kbdfeed->ctrl, 0, None, NULL, client);
else else
#endif #endif
(*keybd->kbdfeed->BellProc)(newpercent, keybd, (*keybd->kbdfeed->BellProc)(newpercent, keybd,
(pointer) &keybd->kbdfeed->ctrl, 0); &keybd->kbdfeed->ctrl, 0);
}
}
return Success; return Success;
} }
@ -1686,48 +1737,59 @@ ProcChangePointerControl(ClientPtr client)
return BadDevice; return BadDevice;
ctrl = mouse->ptrfeed->ctrl; ctrl = mouse->ptrfeed->ctrl;
if ((stuff->doAccel != xTrue) && (stuff->doAccel != xFalse)) if ((stuff->doAccel != xTrue) && (stuff->doAccel != xFalse)) {
{
client->errorValue = stuff->doAccel; client->errorValue = stuff->doAccel;
return(BadValue); return(BadValue);
} }
if ((stuff->doThresh != xTrue) && (stuff->doThresh != xFalse)) if ((stuff->doThresh != xTrue) && (stuff->doThresh != xFalse)) {
{
client->errorValue = stuff->doThresh; client->errorValue = stuff->doThresh;
return(BadValue); return(BadValue);
} }
if (stuff->doAccel) if (stuff->doAccel) {
{ if (stuff->accelNum == -1) {
if (stuff->accelNum == -1)
ctrl.num = defaultPointerControl.num; ctrl.num = defaultPointerControl.num;
else if (stuff->accelNum < 0) }
{ else if (stuff->accelNum < 0) {
client->errorValue = stuff->accelNum; client->errorValue = stuff->accelNum;
return BadValue; return BadValue;
} }
else ctrl.num = stuff->accelNum; else {
if (stuff->accelDenum == -1) ctrl.num = stuff->accelNum;
}
if (stuff->accelDenum == -1) {
ctrl.den = defaultPointerControl.den; ctrl.den = defaultPointerControl.den;
else if (stuff->accelDenum <= 0) }
{ else if (stuff->accelDenum <= 0) {
client->errorValue = stuff->accelDenum; client->errorValue = stuff->accelDenum;
return BadValue; return BadValue;
} }
else ctrl.den = stuff->accelDenum; else {
ctrl.den = stuff->accelDenum;
}
} }
if (stuff->doThresh) if (stuff->doThresh) {
{ if (stuff->threshold == -1) {
if (stuff->threshold == -1)
ctrl.threshold = defaultPointerControl.threshold; ctrl.threshold = defaultPointerControl.threshold;
else if (stuff->threshold < 0) }
{ else if (stuff->threshold < 0) {
client->errorValue = stuff->threshold; client->errorValue = stuff->threshold;
return BadValue; return BadValue;
} }
else ctrl.threshold = stuff->threshold; else {
ctrl.threshold = stuff->threshold;
}
} }
mouse->ptrfeed->ctrl = ctrl;
(*mouse->ptrfeed->CtrlProc)(mouse, &mouse->ptrfeed->ctrl);
for (mouse = inputInfo.devices; mouse; mouse = mouse->next) {
if ((mouse->coreEvents || mouse == inputInfo.pointer) &&
mouse->ptrfeed && mouse->ptrfeed->CtrlProc) {
mouse->ptrfeed->ctrl = ctrl;
(*mouse->ptrfeed->CtrlProc)(mouse, &mouse->ptrfeed->ctrl);
}
}
return Success; return Success;
} }

View File

@ -1020,7 +1020,7 @@ int DarwinModifierStringToNXKey(const char *str)
* This allows the ddx layer to prevent some keys from being remapped * This allows the ddx layer to prevent some keys from being remapped
* as modifier keys. * as modifier keys.
*/ */
Bool LegalModifier(unsigned int key, DevicePtr pDev) Bool LegalModifier(unsigned int key, DeviceIntPtr pDev)
{ {
return 1; return 1;
} }

View File

@ -53,7 +53,7 @@
/** Returns TRUE if the key is a valid modifier. For PC-class /** Returns TRUE if the key is a valid modifier. For PC-class
* keyboards, all keys can be used as modifiers, so return TRUE * keyboards, all keys can be used as modifiers, so return TRUE
* always. */ * always. */
Bool LegalModifier(unsigned int key, DevicePtr pDev) Bool LegalModifier(unsigned int key, DeviceIntPtr pDev)
{ {
return TRUE; return TRUE;
} }

View File

@ -516,7 +516,7 @@ KdPointerProc(DeviceIntPtr pDevice, int onoff)
} }
Bool Bool
LegalModifier(unsigned int key, DevicePtr pDev) LegalModifier(unsigned int key, DeviceIntPtr pDev)
{ {
return TRUE; return TRUE;
} }

View File

@ -43,7 +43,7 @@ from The Open Group.
#include <X11/keysym.h> #include <X11/keysym.h>
Bool Bool
LegalModifier(unsigned int key, DevicePtr pDev) LegalModifier(unsigned int key, DeviceIntPtr pDev)
{ {
return TRUE; return TRUE;
} }

View File

@ -164,7 +164,7 @@ static IHPtr InputHandlers = NULL;
Bool Bool
LegalModifier(unsigned int key, DevicePtr pDev) LegalModifier(unsigned int key, DeviceIntPtr pDev)
{ {
return TRUE; return TRUE;
} }

View File

@ -52,7 +52,7 @@ InitOutput (ScreenInfo *pScreenInfo,
Bool Bool
LegalModifier (unsigned int key, LegalModifier (unsigned int key,
DevicePtr pDev) DeviceIntPtr pDev)
{ {
return xeglLegalModifier (key, pDev); return xeglLegalModifier (key, pDev);
} }

View File

@ -252,7 +252,7 @@ xeglInitInput (int argc,
Bool Bool
xeglLegalModifier (unsigned int key, xeglLegalModifier (unsigned int key,
DevicePtr pDev) DeviceIntPtr pDev)
{ {
return KdLegalModifier (key, pDev); return KdLegalModifier (key, pDev);
} }

View File

@ -173,7 +173,7 @@ KdWakeupHandler (pointer data,
Bool Bool
KdLegalModifier (unsigned int key, KdLegalModifier (unsigned int key,
DevicePtr pDev); DeviceIntPtr pDev);
void void
KdProcessInputEvents (void); KdProcessInputEvents (void);

View File

@ -58,7 +58,7 @@ InitOutput (ScreenInfo *pScreenInfo,
Bool Bool
LegalModifier (unsigned int key, LegalModifier (unsigned int key,
DevicePtr pDev) DeviceIntPtr pDev)
{ {
return xeglLegalModifier (key, pDev); return xeglLegalModifier (key, pDev);
} }

View File

@ -52,7 +52,7 @@ InitOutput (ScreenInfo *pScreenInfo,
Bool Bool
LegalModifier (unsigned int key, LegalModifier (unsigned int key,
DevicePtr pDev) DeviceIntPtr pDev)
{ {
return xglxLegalModifier (key, pDev); return xglxLegalModifier (key, pDev);
} }

View File

@ -1243,7 +1243,7 @@ xglxKeybdProc (DeviceIntPtr pDevice,
Bool Bool
xglxLegalModifier (unsigned int key, xglxLegalModifier (unsigned int key,
DevicePtr pDev) DeviceIntPtr pDev)
{ {
return TRUE; return TRUE;
} }

View File

@ -91,7 +91,7 @@ xglxInitOutput (ScreenInfo *pScreenInfo,
Bool Bool
xglxLegalModifier (unsigned int key, xglxLegalModifier (unsigned int key,
DevicePtr pDev); DeviceIntPtr pDev);
void void
xglxProcessInputEvents (void); xglxProcessInputEvents (void);

View File

@ -81,7 +81,7 @@ InitOutput (ScreenInfo *pScreenInfo,
Bool Bool
LegalModifier (unsigned int key, LegalModifier (unsigned int key,
DevicePtr pDev) DeviceIntPtr pDev)
{ {
return xglxLegalModifier (key, pDev); return xglxLegalModifier (key, pDev);
} }

View File

@ -192,7 +192,7 @@ InitOutput (ScreenInfo *pScreenInfo,
Bool Bool
LegalModifier (unsigned int key, LegalModifier (unsigned int key,
DevicePtr pDev) DeviceIntPtr pDev)
{ {
return (*__ddxFunc.legalModifier) (key, pDev); return (*__ddxFunc.legalModifier) (key, pDev);
} }

View File

@ -253,7 +253,7 @@ XkbError:
} }
Bool Bool
LegalModifier(unsigned int key, DevicePtr pDev) LegalModifier(unsigned int key, DeviceIntPtr pDev)
{ {
return TRUE; return TRUE;
} }

View File

@ -189,7 +189,7 @@ InitInput(
Bool Bool
LegalModifier( LegalModifier(
unsigned int key, unsigned int key,
DevicePtr dev) DeviceIntPtr dev)
{ {
return TRUE; return TRUE;
} }

View File

@ -79,7 +79,7 @@ extern winDispatchProcPtr winProcQueryTreeOrig;
*/ */
Bool Bool
LegalModifier (unsigned int uiKey, DevicePtr pDevice) LegalModifier (unsigned int uiKey, DeviceIntPtr pDevice)
{ {
return TRUE; return TRUE;
} }

View File

@ -371,7 +371,7 @@ extern void CoreProcessKeyboardEvent(
extern Bool LegalModifier( extern Bool LegalModifier(
unsigned int /*key*/, unsigned int /*key*/,
DevicePtr /*pDev*/); DeviceIntPtr /*pDev*/);
extern void ProcessInputEvents(void); extern void ProcessInputEvents(void);