summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@who-t.net>2012-03-15 11:51:41 +1000
committerPeter Hutterer <peter.hutterer@who-t.net>2012-03-15 13:00:31 +1000
commit8436c920953f288aea2d6d5f370f8eaaaef82d97 (patch)
tree7fd771400a8b0a9a215fb05be3b09e268b7077b7
parent70b730b0548ca9e408f14f2576b972beb32a0ad0 (diff)
Fix wrong button label and mask copy on OS X
Regression introduced in c1a5a70b51f12dedf354102217c7cd4247ed3a4b. If double-padding is applied, the length of the mask on the wire may be smaller than libXi's mask_len. When copying, only the wire length must be copied, with the remainder set to 0. When advancing to the button labels, the wire length matters, not libXi's internal length. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Jeremy Huddleston <jeremyhu@apple.com> Tested-by: Jeremy Huddleston <jeremyhu@apple.com>
-rw-r--r--src/XExtInt.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/XExtInt.c b/src/XExtInt.c
index 89c0894..0c64f9a 100644
--- a/src/XExtInt.c
+++ b/src/XExtInt.c
@@ -1610,12 +1610,14 @@ copy_classes(XIDeviceInfo* to, xXIAnyInfo* from, int *nclasses)
int struct_size;
int state_size;
int labels_size;
+ int wire_mask_size;
cls_wire = (xXIButtonInfo*)any_wire;
sizeXIButtonClassType(cls_wire->num_buttons,
&struct_size, &state_size,
&labels_size);
cls_lib = next_block(&ptr_lib, struct_size);
+ wire_mask_size = ((cls_wire->num_buttons + 7)/8 + 3)/4 * 4;
cls_lib->type = cls_wire->type;
cls_lib->sourceid = cls_wire->sourceid;
@@ -1623,10 +1625,14 @@ copy_classes(XIDeviceInfo* to, xXIAnyInfo* from, int *nclasses)
cls_lib->state.mask_len = state_size;
cls_lib->state.mask = next_block(&ptr_lib, state_size);
memcpy(cls_lib->state.mask, &cls_wire[1],
- cls_lib->state.mask_len);
+ wire_mask_size);
+ if (state_size != wire_mask_size)
+ memset(&cls_lib->state.mask[wire_mask_size], 0,
+ state_size - wire_mask_size);
cls_lib->labels = next_block(&ptr_lib, labels_size);
- atoms =(uint32_t*)((char*)&cls_wire[1] + cls_lib->state.mask_len);
+
+ atoms =(uint32_t*)((char*)&cls_wire[1] + wire_mask_size);
for (j = 0; j < cls_lib->num_buttons; j++)
cls_lib->labels[j] = *atoms++;