input: fix up usage of button->down, used to be a bitmask, is now an array.
device->button->down used to be a 32-byte bitmask with one bit for each button. This has changed into a 256-byte array, with one byte assigned for each button. Some of the callers were still using this array as a bitmask however, this is fixed with this patch. Thanks to Keith Packard for pointing this out. See also: http://lists.freedesktop.org/archives/xorg/2008-June/036202.html
This commit is contained in:
parent
2b9c829bde
commit
d21155a3e9
|
@ -1153,9 +1153,11 @@ FixDeviceStateNotify(DeviceIntPtr dev, deviceStateNotify * ev, KeyClassPtr k,
|
|||
ev->num_valuators = 0;
|
||||
|
||||
if (b) {
|
||||
int i;
|
||||
ev->classes_reported |= (1 << ButtonClass);
|
||||
ev->num_buttons = b->numButtons;
|
||||
memmove((char *)&ev->buttons[0], (char *)b->down, 4);
|
||||
for (i = 0; i < 32; i++)
|
||||
SetBitIf(ev->buttons, b->down, i);
|
||||
} else if (k) {
|
||||
ev->classes_reported |= (1 << KeyClass);
|
||||
ev->num_keys = k->curKeySyms.maxKeyCode - k->curKeySyms.minKeyCode;
|
||||
|
@ -1270,11 +1272,13 @@ DeviceFocusEvent(DeviceIntPtr dev, int type, int mode, int detail,
|
|||
first += 3;
|
||||
nval -= 3;
|
||||
if (nbuttons > 32) {
|
||||
int i;
|
||||
(ev - 1)->deviceid |= MORE_EVENTS;
|
||||
bev = (deviceButtonStateNotify *) ev++;
|
||||
bev->type = DeviceButtonStateNotify;
|
||||
bev->deviceid = dev->id;
|
||||
memmove((char *)&bev->buttons[0], (char *)&b->down[4], 28);
|
||||
for (i = 32; i < MAP_LENGTH; i++)
|
||||
SetBitIf(bev->buttons, b->down, i);
|
||||
}
|
||||
if (nval > 0) {
|
||||
(ev - 1)->deviceid |= MORE_EVENTS;
|
||||
|
@ -1692,7 +1696,7 @@ SetButtonMapping(ClientPtr client, DeviceIntPtr dev, int nElts, BYTE * map)
|
|||
if (BadDeviceMap(&map[0], nElts, 1, 255, &client->errorValue))
|
||||
return BadValue;
|
||||
for (i = 0; i < nElts; i++)
|
||||
if ((b->map[i + 1] != map[i]) && BitIsOn(b->down, i + 1))
|
||||
if ((b->map[i + 1] != map[i]) && (b->down[i + 1]))
|
||||
return MappingBusy;
|
||||
for (i = 0; i < nElts; i++)
|
||||
b->map[i + 1] = map[i];
|
||||
|
|
|
@ -119,7 +119,7 @@ ProcXQueryDeviceState(ClientPtr client)
|
|||
total_length += (sizeof(xValuatorState) + (v->numAxes * sizeof(int)));
|
||||
num_classes++;
|
||||
}
|
||||
buf = (char *)xalloc(total_length);
|
||||
buf = (char *)xcalloc(total_length, 1);
|
||||
if (!buf)
|
||||
return BadAlloc;
|
||||
savbuf = buf;
|
||||
|
@ -139,8 +139,8 @@ ProcXQueryDeviceState(ClientPtr client)
|
|||
tb->class = ButtonClass;
|
||||
tb->length = sizeof(xButtonState);
|
||||
tb->num_buttons = b->numButtons;
|
||||
for (i = 0; i < 32; i++)
|
||||
tb->buttons[i] = b->down[i];
|
||||
for (i = 0; i < MAP_LENGTH; i++)
|
||||
SetBitIf(tb->buttons, b->down, i);
|
||||
buf += sizeof(xButtonState);
|
||||
}
|
||||
|
||||
|
|
|
@ -1734,7 +1734,7 @@ DoSetPointerMapping(ClientPtr client, DeviceIntPtr device, BYTE *map, int n)
|
|||
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)) {
|
||||
device->button->down[i + 1]) {
|
||||
return MappingBusy;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4077,15 +4077,11 @@ ProcessPointerEvent (xEvent *xE, DeviceIntPtr mouse, int count)
|
|||
if (xE->u.u.type != MotionNotify)
|
||||
{
|
||||
int key;
|
||||
BYTE *kptr;
|
||||
int bit;
|
||||
|
||||
XE_KBPTR.rootX = pSprite->hot.x;
|
||||
XE_KBPTR.rootY = pSprite->hot.y;
|
||||
|
||||
key = xE->u.u.detail;
|
||||
kptr = &butc->down[key >> 3];
|
||||
bit = 1 << (key & 7);
|
||||
switch (xE->u.u.type)
|
||||
{
|
||||
case ButtonPress:
|
||||
|
|
|
@ -57,6 +57,9 @@ SOFTWARE.
|
|||
#include "privates.h"
|
||||
|
||||
#define BitIsOn(ptr, bit) (((BYTE *) (ptr))[(bit)>>3] & (1 << ((bit) & 7)))
|
||||
/* If byte[i] in src is non-zero, set bit i in dst, otherwise set bit to 0 */
|
||||
#define SetBitIf(dst, src, i) \
|
||||
(src[i]) ? (dst[i/8] |= (1 << (i % 8))) : (dst[i/8] &= ~(1 << (i % 8)));
|
||||
|
||||
#define SameClient(obj,client) \
|
||||
(CLIENT_BITS((obj)->resource) == (client)->clientAsMask)
|
||||
|
|
|
@ -1045,7 +1045,7 @@ int button;
|
|||
switch (pAction->type) {
|
||||
case XkbSA_LockDeviceBtn:
|
||||
if ((pAction->devbtn.flags&XkbSA_LockNoLock)||
|
||||
(dev->button->down[button/8]&(1L<<(button%8))))
|
||||
(dev->button->down[button]))
|
||||
return 0;
|
||||
XkbDDXFakeDeviceButton(dev,True,button);
|
||||
filter->upAction.type= XkbSA_NoAction;
|
||||
|
@ -1077,7 +1077,7 @@ int button;
|
|||
switch (filter->upAction.type) {
|
||||
case XkbSA_LockDeviceBtn:
|
||||
if ((filter->upAction.devbtn.flags&XkbSA_LockNoUnlock)||
|
||||
((dev->button->down[button/8]&(1L<<(button%8)))==0))
|
||||
((dev->button->down[button])==0))
|
||||
return 0;
|
||||
XkbDDXFakeDeviceButton(dev,False,button);
|
||||
break;
|
||||
|
|
Loading…
Reference in New Issue