diff options
author | Peter Hutterer <peter.hutterer@redhat.com> | 2008-11-26 11:15:05 +1000 |
---|---|---|
committer | Keith Packard <keithp@keithp.com> | 2009-01-30 17:11:44 -0800 |
commit | ebb3872925315d705e47e1ccd7f193ac90ac33dc (patch) | |
tree | 9af96c47c63b8a5cf57511643c103eb13a4d1bb8 /Xi | |
parent | 50d80c25525a691472e3fc5859fb303a3ffe1ef2 (diff) |
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>
(cherry picked from commit a85f0d6b98237d8a196de624207acf1983a1859a)
Diffstat (limited to 'Xi')
-rw-r--r-- | Xi/exevents.c | 10 | ||||
-rw-r--r-- | Xi/queryst.c | 3 |
2 files changed, 4 insertions, 9 deletions
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); } |