diff options
author | Peter Hutterer <peter.hutterer@who-t.net> | 2009-08-11 16:16:54 +1000 |
---|---|---|
committer | Peter Hutterer <peter.hutterer@who-t.net> | 2009-08-13 11:19:37 +1000 |
commit | ce69a06aff934b2dcded8606cab079ac6465007c (patch) | |
tree | be1fe9511c6295d2f91f8126b10b61cc8d0d58e3 | |
parent | b44d34d5fd0d8aaacb89121e8b4afba04f1dcc80 (diff) |
Xi: fix up broken DeviceChangedEvent swapping code
-rw-r--r-- | Xi/extinit.c | 33 |
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) | |||
676 | *to = *from; | 676 | *to = *from; |
677 | memcpy(&to[1], &from[1], from->length * 4); | 677 | memcpy(&to[1], &from[1], from->length * 4); |
678 | 678 | ||
679 | swaps(&to->sequenceNumber, n); | ||
680 | swapl(&to->length, n); | ||
681 | swaps(&to->evtype, n); | ||
682 | swaps(&to->deviceid, n); | ||
683 | swapl(&to->time, n); | ||
684 | swaps(&to->num_classes, n); | ||
685 | swaps(&to->sourceid, n); | ||
686 | |||
687 | /* now swap the actual classes */ | ||
688 | any = (xXIAnyInfo*)&to[1]; | 679 | any = (xXIAnyInfo*)&to[1]; |
689 | for (i = 0; i < to->num_classes; i++) | 680 | for (i = 0; i < to->num_classes; i++) |
690 | { | 681 | { |
691 | swaps(&any->type, n); | 682 | int length = any->length; |
692 | swaps(&any->length, n); | 683 | |
693 | switch(any->type) | 684 | switch(any->type) |
694 | { | 685 | { |
695 | case KeyClass: | 686 | case KeyClass: |
@@ -704,8 +695,10 @@ SDeviceChangedEvent(xXIDeviceChangedEvent* from, xXIDeviceChangedEvent* to) | |||
704 | case ButtonClass: | 695 | case ButtonClass: |
705 | { | 696 | { |
706 | xXIButtonInfo *bi = (xXIButtonInfo*)any; | 697 | xXIButtonInfo *bi = (xXIButtonInfo*)any; |
698 | Atom *labels = (Atom*)((char*)bi + sizeof(xXIButtonInfo) + | ||
699 | pad_to_int32(bits_to_bytes(bi->num_buttons))); | ||
707 | for (j = 0; j < bi->num_buttons; j++) | 700 | for (j = 0; j < bi->num_buttons; j++) |
708 | swapl(&bi[1 + j], n); | 701 | swapl(&labels[j], n); |
709 | swaps(&bi->num_buttons, n); | 702 | swaps(&bi->num_buttons, n); |
710 | } | 703 | } |
711 | break; | 704 | break; |
@@ -722,8 +715,22 @@ SDeviceChangedEvent(xXIDeviceChangedEvent* from, xXIDeviceChangedEvent* to) | |||
722 | } | 715 | } |
723 | break; | 716 | break; |
724 | } | 717 | } |
725 | any = (xXIAnyInfo*)((char*)any + any->length * 4); | 718 | |
719 | swaps(&any->type, n); | ||
720 | swaps(&any->length, n); | ||
721 | swaps(&any->sourceid, n); | ||
722 | |||
723 | any = (xXIAnyInfo*)((char*)any + length * 4); | ||
726 | } | 724 | } |
725 | |||
726 | swaps(&to->sequenceNumber, n); | ||
727 | swapl(&to->length, n); | ||
728 | swaps(&to->evtype, n); | ||
729 | swaps(&to->deviceid, n); | ||
730 | swapl(&to->time, n); | ||
731 | swaps(&to->num_classes, n); | ||
732 | swaps(&to->sourceid, n); | ||
733 | |||
727 | } | 734 | } |
728 | 735 | ||
729 | static void SDeviceEvent(xXIDeviceEvent *from, xXIDeviceEvent *to) | 736 | static void SDeviceEvent(xXIDeviceEvent *from, xXIDeviceEvent *to) |