summaryrefslogtreecommitdiff
path: root/Xi
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@who-t.net>2009-08-11 16:16:54 +1000
committerPeter Hutterer <peter.hutterer@who-t.net>2009-08-13 11:19:37 +1000
commitce69a06aff934b2dcded8606cab079ac6465007c (patch)
treebe1fe9511c6295d2f91f8126b10b61cc8d0d58e3 /Xi
parentb44d34d5fd0d8aaacb89121e8b4afba04f1dcc80 (diff)
Xi: fix up broken DeviceChangedEvent swapping code
Diffstat (limited to 'Xi')
-rw-r--r--Xi/extinit.c33
1 files changed, 20 insertions, 13 deletions
diff --git a/Xi/extinit.c b/Xi/extinit.c
index 2b75b3dab..e3590838a 100644
--- a/Xi/extinit.c
+++ b/Xi/extinit.c
@@ -676,20 +676,11 @@ SDeviceChangedEvent(xXIDeviceChangedEvent* from, xXIDeviceChangedEvent* to)
*to = *from;
memcpy(&to[1], &from[1], from->length * 4);
- swaps(&to->sequenceNumber, n);
- swapl(&to->length, n);
- swaps(&to->evtype, n);
- swaps(&to->deviceid, n);
- swapl(&to->time, n);
- swaps(&to->num_classes, n);
- swaps(&to->sourceid, n);
-
- /* now swap the actual classes */
any = (xXIAnyInfo*)&to[1];
for (i = 0; i < to->num_classes; i++)
{
- swaps(&any->type, n);
- swaps(&any->length, n);
+ int length = any->length;
+
switch(any->type)
{
case KeyClass:
@@ -704,8 +695,10 @@ SDeviceChangedEvent(xXIDeviceChangedEvent* from, xXIDeviceChangedEvent* to)
case ButtonClass:
{
xXIButtonInfo *bi = (xXIButtonInfo*)any;
+ Atom *labels = (Atom*)((char*)bi + sizeof(xXIButtonInfo) +
+ pad_to_int32(bits_to_bytes(bi->num_buttons)));
for (j = 0; j < bi->num_buttons; j++)
- swapl(&bi[1 + j], n);
+ swapl(&labels[j], n);
swaps(&bi->num_buttons, n);
}
break;
@@ -722,8 +715,22 @@ SDeviceChangedEvent(xXIDeviceChangedEvent* from, xXIDeviceChangedEvent* to)
}
break;
}
- any = (xXIAnyInfo*)((char*)any + any->length * 4);
+
+ swaps(&any->type, n);
+ swaps(&any->length, n);
+ swaps(&any->sourceid, n);
+
+ any = (xXIAnyInfo*)((char*)any + length * 4);
}
+
+ swaps(&to->sequenceNumber, n);
+ swapl(&to->length, n);
+ swaps(&to->evtype, n);
+ swaps(&to->deviceid, n);
+ swapl(&to->time, n);
+ swaps(&to->num_classes, n);
+ swaps(&to->sourceid, n);
+
}
static void SDeviceEvent(xXIDeviceEvent *from, xXIDeviceEvent *to)