From f32ad442c24f2407d3a14773201e9f8ec43a7bc6 Mon Sep 17 00:00:00 2001 From: Alan Coopersmith Date: Mon, 29 Apr 2013 18:39:34 -0700 Subject: [PATCH 1/3] Expand comment on the memory vs. reply ordering in XIGetSelectedEvents() Unpacking from the wire involves un-interleaving the structs & masks, which wasn't obvious to me the first time I read it, so make notes before I forget again. Signed-off-by: Alan Coopersmith Signed-off-by: Peter Hutterer (cherry picked from commit bb82c72a1d69eaf60b7586570faf797df967f661) (cherry picked from commit 362c9058dcbeedacaae0190c279e076a5db1d564) --- src/XISelEv.c | 10 ++++++++-- 1 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/XISelEv.c b/src/XISelEv.c index 3192b6b..bd5a29a 100644 --- a/src/XISelEv.c +++ b/src/XISelEv.c @@ -132,8 +132,14 @@ XIGetSelectedEvents(Display* dpy, Window win, int *num_masks_return) _XRead(dpy, (char*)mask_in, reply.length * 4); - /* Memory layout of the XIEventMask for a 3 mask reply: - * [struct a][struct b][struct c][masks a][masks b][masks c] + /* + * This function takes interleaved xXIEventMask structs & masks off + * the wire, such as this 3 mask reply: + * [struct a][masks a][struct b][masks b][struct c][masks c] + * And generates a memory buffer to be returned to callers in which + * they are not interleaved, so that callers can treat the returned + * pointer as a simple array of XIEventMask structs, such as: + * [struct a][struct b][struct c][masks a][masks b][masks c] */ len = reply.num_masks * sizeof(XIEventMask); -- 1.7.7.1