summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@redhat.com>2008-11-26 11:15:05 +1000
committerPeter Hutterer <peter.hutterer@redhat.com>2008-12-02 15:50:37 +1000
commita85f0d6b98237d8a196de624207acf1983a1859a (patch)
tree1429f3b39123b17d4622f8f8f50c17e590088663
parent180bad84774493d48f2793a6281d825560944863 (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>
-rw-r--r--Xi/exevents.c10
-rw-r--r--Xi/queryst.c3
-rw-r--r--dix/devices.c2
-rw-r--r--include/inputstr.h3
-rw-r--r--xkb/xkbActions.c4
5 files changed, 7 insertions, 15 deletions
diff --git a/Xi/exevents.c b/Xi/exevents.c
index 025dcd78e..6797f50bf 100644
--- a/Xi/exevents.c
+++ b/Xi/exevents.c
@@ -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];
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 220b895aa..6b8cecb5a 100644
--- a/dix/devices.c
+++ b/dix/devices.c
@@ -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;
}
}
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 a2606297a..c268795b7 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;