[Xcb] [PATCH proto 2/2] SendExtensionEvent uses eventstruct

Christian Linhart chris at demorecorder.com
Wed Jan 25 10:18:07 UTC 2017


Use the eventstruct element to define the SendExtensionEvent request
instead of using a byte-array.

This has the advantage that the structure of the data to be sent
is now defined in the xml definition.
This can be used by generators to make sending events safer.
Such as avoiding type-casts in C.

It can also be useful for protocol analyzers and tools like that
because the structure of the sent events is now defined in the xml-definition.

Tested-by: Christian Linhart <chris at demorecorder.com>
Signed-off-by: Christian Linhart <chris at demorecorder.com>
---
 src/xinput.xml | 57 ++++++++++++++++++++++++++++++++++++++-------------------
 1 file changed, 38 insertions(+), 19 deletions(-)

diff --git a/src/xinput.xml b/src/xinput.xml
index c0b497e..9a35e9d 100644
--- a/src/xinput.xml
+++ b/src/xinput.xml
@@ -983,33 +983,16 @@ <request name="QueryDeviceState" opcode="30">
             <pad bytes="23" />
             <list type="InputState" name="classes">
                 <fieldref>num_classes</fieldref>
             </list>
         </reply>
     </request>
 
-    <!-- SendExtensionEvent -->
-
-    <request name="SendExtensionEvent" opcode="31">
-        <field type="WINDOW" name="destination" />
-        <field type="CARD8"  name="device_id" />
-        <field type="BOOL"   name="propagate" />
-        <field type="CARD16" name="num_classes" />
-        <field type="CARD8"  name="num_events" />
-        <pad bytes="3" />
-        <list type="CARD8" name="events">
-            <op op="*">
-                <fieldref>num_events</fieldref>
-                <value>32</value>
-            </op>
-        </list>
-        <list type="EventClass" name="classes">
-            <fieldref>num_classes</fieldref>
-        </list>
-    </request>
+    <!-- SendExtensionEvent (opcode 16) has to be defined after the events
+         because we do not support backward references -->
 
     <!-- DeviceBell -->
 
     <request name="DeviceBell" opcode="32">
         <field type="CARD8" name="device_id" />
         <field type="CARD8" name="feedback_id" />
         <field type="CARD8" name="feedback_class" />
@@ -2638,14 +2621,50 @@ <event name="BarrierHit" number="25" xge="true">
         <field type="FP1616"    name="root_y" />
         <field type="FP3232"    name="dx" />
         <field type="FP3232"    name="dy" />
     </event>
 
     <eventcopy name="BarrierLeave" number="26" ref="BarrierHit" />
 
+    <!-- ⋅⋅⋅ Requests that depend on events ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ -->
+
+    <!-- SendExtensionEvent -->
+    <eventstruct name="EventForSend">
+        <allowed extension="Input" xge="false" opcode-min="0" opcode-max="16" />
+        <!-- We need not allow the newer events which are based on
+             the GenericEvent extension:
+             The wire-protocol-spec
+             https://cgit.freedesktop.org/xorg/lib/libXi/tree/specs/encoding.xml?idĺibXi-1.7.9#n1793
+             only allows fixed sized events, which seems
+             to rule out GenericEvent.
+
+             The xlib-implementation also assumes fixed-sized events.
+             https://cgit.freedesktop.org/xorg/lib/libXi/tree/src/XSndExEv.c?id=libXi-1.7.9#n106
+
+             The Xserver also allows only non-GE events:
+	     https:g/xorg/xserver/tree/Xi/sendexev.c?id=xorg-server-1.19.1#n144
+        -->
+    </eventstruct>
+
+    <request name="SendExtensionEvent" opcode="31">
+        <field type="WINDOW" name="destination" />
+        <field type="CARD8"  name="device_id" />
+        <field type="BOOL"   name="propagate" />
+        <field type="CARD16" name="num_classes" />
+        <field type="CARD8"  name="num_events" />
+        <pad bytes="3" />
+        <list type="EventForSend" name="events">
+            <fieldref>num_events</fieldref>
+        </list>
+        <list type="EventClass" name="classes">
+            <fieldref>num_classes</fieldref>
+        </list>
+    </request>
+
+
     <!-- ⋅⋅⋅ Errors (v1.0) ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ -->
 
     <error name="Device"     number="0" />
     <error name="Event"      number="1" />
     <error name="Mode"       number="2" />
     <error name="DeviceBusy" number="3" />
     <error name="Class"      number="4" />
-- 
2.1.4



More information about the Xcb mailing list