Xi: fix use of button->down - bitflags instead of int arrays.

The device's button down state array was changed to use DOWN_LENGTH and thus
bitflags for each button in cfcb3da7.

Update the DBSN events to copy this bit-wise state.
Update xkb and Xi to check for the bit flag instead of the array value.

Reported by ajax.

Signed-off-by: Peter Hutterer <peter.hutterer@redhat.com>
This commit is contained in:
Peter Hutterer 2008-11-26 11:15:05 +10:00
parent 180bad8477
commit a85f0d6b98
5 changed files with 7 additions and 15 deletions

View File

@ -1183,11 +1183,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;
@ -1302,13 +1300,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;
@ -1723,7 +1719,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];

View File

@ -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);
}

View File

@ -1847,7 +1847,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;
}
}

View File

@ -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)

View File

@ -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;