diff --git a/Xi/exevents.c b/Xi/exevents.c index 083bb2f0e..2aa316102 100644 --- a/Xi/exevents.c +++ b/Xi/exevents.c @@ -1138,11 +1138,9 @@ 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; - for (i = 0; i < 32; i++) - SetBitIf(ev->buttons, b->down, i); + memcpy((char*)ev->buttons, (char*)b->down, 4); } else if (k) { ev->classes_reported |= (1 << KeyClass); ev->num_keys = k->curKeySyms.maxKeyCode - k->curKeySyms.minKeyCode; @@ -1257,13 +1255,11 @@ 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; - for (i = 32; i < MAP_LENGTH; i++) - SetBitIf(bev->buttons, b->down, i); + memcpy((char*)&bev->buttons[4], (char*)&b->down[4], DOWN_LENGTH - 4); } if (nval > 0) { (ev - 1)->deviceid |= MORE_EVENTS; @@ -1678,7 +1674,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]) && (b->down[i + 1])) + if ((b->map[i + 1] != map[i]) && BitIsOn(b->down, i + 1)) return MappingBusy; for (i = 0; i < nElts; i++) b->map[i + 1] = map[i]; diff --git a/Xi/queryst.c b/Xi/queryst.c index 268bdd78b..21de843f3 100644 --- a/Xi/queryst.c +++ b/Xi/queryst.c @@ -139,8 +139,7 @@ ProcXQueryDeviceState(ClientPtr client) tb->class = ButtonClass; tb->length = sizeof(xButtonState); tb->num_buttons = b->numButtons; - for (i = 0; i < MAP_LENGTH; i++) - SetBitIf(tb->buttons, b->down, i); + memcpy(tb->buttons, b->down, sizeof(b->down)); buf += sizeof(xButtonState); } diff --git a/dix/devices.c b/dix/devices.c index bf790247f..47e07f94f 100644 --- a/dix/devices.c +++ b/dix/devices.c @@ -1848,7 +1848,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]) && - device->button->down[i + 1]) { + BitIsOn(device->button->down, i + 1)) { return MappingBusy; } } diff --git a/include/inputstr.h b/include/inputstr.h index 9591d2f19..4719d37d7 100644 --- a/include/inputstr.h +++ b/include/inputstr.h @@ -57,9 +57,6 @@ 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) diff --git a/xkb/xkbActions.c b/xkb/xkbActions.c index 94420cf68..64e17e9ac 100644 --- a/xkb/xkbActions.c +++ b/xkb/xkbActions.c @@ -1043,7 +1043,7 @@ int button; switch (pAction->type) { case XkbSA_LockDeviceBtn: if ((pAction->devbtn.flags&XkbSA_LockNoLock)|| - (dev->button->down[button])) + BitIsOn(dev->button->down, button)) return 0; XkbDDXFakeDeviceButton(dev,True,button); filter->upAction.type= XkbSA_NoAction; @@ -1075,7 +1075,7 @@ int button; switch (filter->upAction.type) { case XkbSA_LockDeviceBtn: if ((filter->upAction.devbtn.flags&XkbSA_LockNoUnlock)|| - ((dev->button->down[button])==0)) + BitIsOn(dev->button->down, button)) return 0; XkbDDXFakeDeviceButton(dev,False,button); break;