[Xcb] [PATCH] Remove fieldref from sole list in GetIndicatorMap reply

Daniel Martin consume.noise at gmail.com
Thu Feb 21 09:45:47 PST 2013


On Tue, Feb 19, 2013 at 02:22:43PM -0500, Peter Harris wrote:
> On 2013-02-19 13:59, Daniel Martin wrote:
> That's... annoying. <list /> works properly in requests (and in replies
> in the app I was targeting, which wasn't libxcb).

<list />s are working in libxcb, because there's the assumption that
they are in a request and therefor an additional ..._len parameter will
be used in the function generating the request.

> > And the server doesn't set the 'length' field 1:1 to the length of the
> > list.
> 
> <list /> knows (or should know) that already.
> 
> Is there any chance that fixing <list /> for replies is trivial? If not,

Just tried and for this case it's simple (see the attachment). But, it's
more difficult if the list is hidden in struct. There're such cases i.e.
in xkb. (I'll have a second look at it when my fever is gone completly.)

> I'll re-submit the patch using <op> as per your suggestion.

Another more simply solution would be to use the 'which' field. Didn't
noticed it at first. It's the bitmask saying which indicator is set and
the <popcount> of it would give what you want.
-------------- next part --------------
>From 4a7595d949e50dc2b364e79f58fcc688a190cac3 Mon Sep 17 00:00:00 2001
From: Daniel Martin <consume.noise at gmail.com>
Date: Thu, 21 Feb 2013 17:00:59 +0100
Subject: [PATCH] Use 'length' in reply for list with unspec. length

---
 xcbgen/expr.py | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/xcbgen/expr.py b/xcbgen/expr.py
index 4f8af6f..3dc38ee 100644
--- a/xcbgen/expr.py
+++ b/xcbgen/expr.py
@@ -52,9 +52,17 @@ class Expression(object):
         self.rhs = None
 
         if elt.tag == 'list':
-            # List going into a request, which has no length field (inferred by server)
-            self.lenfield_name = elt.get('name') + '_len'
-            self.lenfield_type = 'CARD32'
+            parent_is_reply = False
+            if hasattr(self.parent, "parents"):
+                for p in self.parent.parents:
+                    parent_is_reply = p.is_reply
+
+            if parent_is_reply:
+                self.lenfield_name = 'length'
+                self.lenfield_type = 'CARD32'
+            else:
+                self.lenfield_name = elt.get('name') + '_len'
+                self.lenfield_type = 'CARD32'
 
         elif elt.tag == 'fieldref':
             # Standard list with a fieldref
-- 
1.8.1.4



More information about the Xcb mailing list