1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
From f32ad442c24f2407d3a14773201e9f8ec43a7bc6 Mon Sep 17 00:00:00 2001
From: Alan Coopersmith <alan.coopersmith@oracle.com>
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 <alan.coopersmith@oracle.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
(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
|