xml-xcb.txt revision b26960f7
1d4401354Smrg                                  xcb/proto
2d4401354Smrg
3d4401354SmrgDescription
4d4401354Smrg===========
5d4401354Smrg
6d4401354Smrgxcb/proto is a set of XML files describing the  X Window System protocol
7d4401354SmrgIt is designed for use with libxcb, the X C binding
8d4401354Smrg<http://xcb.freedesktop.org/>.  xcb/proto consists of:
9d4401354Smrg
10d4401354Smrgxcb.xsd      An XML Schema defining the data format for describing the X
11d4401354Smrg             protocol.
12d4401354Smrg
13d4401354Smrg*.py         Code generator helpers that read the protocol descriptions
14d4401354Smrg             into python structures. See libxcb for example usage.
15d4401354Smrg
16d4401354Smrg*.xml        XML descriptions of the core X protocol and many extensions.
17d4401354Smrg
18d4401354Smrg
19d4401354SmrgGenerating C bindings
20d4401354Smrg=====================
21d4401354Smrg
22d4401354SmrgSee libxcb <http://cgit.freedesktop.org/xcb/libxcb/>.
23d4401354Smrg
24d4401354Smrg
25d4401354SmrgProtocol Description Format
26d4401354Smrg===========================
27d4401354Smrg
28d4401354SmrgRoot element
29d4401354Smrg------------
30d4401354Smrg
31d4401354Smrg<xcb header="string" extension-name="string" extension-xname="string">
32d4401354Smrg  top-level elements
33d4401354Smrg</xcb>
34d4401354Smrg
35d4401354Smrg  This is the root element of a protocol description.  The attributes are all
36d4401354Smrg  various forms of the extension name.  header is the basename of the XML
37d4401354Smrg  protocol description file, which will be used as the basename for generated
38d4401354Smrg  bindings as well.  extension-name is the name of the extension in InterCaps,
39d4401354Smrg  which will be used in the names of functions.  extension-xname is the name
40d4401354Smrg  of the extension as passed to QueryExtension.
41d4401354Smrg
42d4401354Smrg  As an example, the XML-XCB description for the GO-FASTER extension would use
43d4401354Smrg  the root element <xcb header="gofaster" extension-name="GoFaster"
44d4401354Smrg  extension-xname="GO-FASTER">; as a result, C bindings will be put in
45d4401354Smrg  gofaster.h and gofaster.c, extension functions will be named
46d4401354Smrg  XCBGoFasterFunctionName, and the extension initialization will call
47d4401354Smrg  QueryExtension with the name "GO-FASTER".
48d4401354Smrg
49d4401354Smrg  This element can contain any number of the elements listed in the section
50d4401354Smrg  "Top-Level Elements" below.
51d4401354Smrg
52d4401354Smrg
53d4401354SmrgTop-Level Elements
54d4401354Smrg------------------
55d4401354Smrg
56d4401354Smrg<import>header_name</import>
57d4401354Smrg
58d4401354Smrg  The import element allows the protocol description to reference types
59d4401354Smrg  declared in another extension.  The content is be the basename of the
60d4401354Smrg  extension XML file, which is also the header attribute of the extension's
61d4401354Smrg  root node.  Note that types from xproto are automatically available, without
62d4401354Smrg  explicitly importing them.
63d4401354Smrg
64d4401354Smrg<struct name="identifier">structure contents</struct>
65d4401354Smrg
66d4401354Smrg  This element represents a data structure.  The name attribute gives the name
67d4401354Smrg  of the structure.  The content represents the fields of the structure, and
68d4401354Smrg  consists of one or more of the field, pad, and list elements described in
69d4401354Smrg  the section "Structure Contents" below.
70d4401354Smrg
71d4401354Smrg<union name="identifier">structure contents</union>
72d4401354Smrg
73d4401354Smrg  This element represents a union of data types, which can hold one value of
74d4401354Smrg  any of those types.  The name attribute gives the name of the union.  The
75d4401354Smrg  content represents the fields of the union, and consists of one or more of
76d4401354Smrg  the field and pad elements described in the section "Structure Contents
77d4401354Smrg  below".
78d4401354Smrg
79d4401354Smrg<xidtype name="identifier" />
80d4401354Smrg
81d4401354Smrg  This element represents an identifier for a particular type of resource.
82d4401354Smrg  The name attribute gives the name of the new type.
83d4401354Smrg
84d4401354Smrg<enum name="identifier">
85d4401354Smrg  <item name="identifier">[optional expression]</item>
86d4401354Smrg  ...
87d4401354Smrg</enum>
88d4401354Smrg
89d4401354Smrg  The enum element represents an enumeration type, which can take on any of
90d4401354Smrg  the values given by the contained item elements.  The name attribute on the
91d4401354Smrg  enum gives the name of the enumerated type.
92d4401354Smrg
93d4401354Smrg  The item element represents one possible value of an enumerated type.  The
94d4401354Smrg  name attribute on the item gives the name of that value, and the optional
95d4401354Smrg  content is an expression giving the numeric value.  If the expression is
96d4401354Smrg  omitted, the value will be one more than that of the previous item, or 0 for
97d4401354Smrg  the first item.
98d4401354Smrg
99d4401354Smrg<typedef oldname="identifier" newname="identifier" />
100d4401354Smrg
101d4401354Smrg  The typedef element declares the type given by the newname attribute to be
102d4401354Smrg  an alias for the type given by the oldname attribute.
103d4401354Smrg
104d4401354Smrg<request name="identifier" opcode="integer" [combine-adjacent="true"]>
105d4401354Smrg  structure contents
106d4401354Smrg  [<reply>structure contents</reply>]
107d4401354Smrg</request>
108d4401354Smrg
109d4401354Smrg  The request element represents an X protocol request.  The name attribute
110d4401354Smrg  gives the name of the request, and the opcode attribute gives the numeric
111d4401354Smrg  request code.  The content of the request element represents the fields in
112d4401354Smrg  the request, and consists of one or more of any of the elements listed in
113d4401354Smrg  the "Structure Contents" section below.  Note that for requests in the core
114d4401354Smrg  protocol, the first field in the request goes into the one-byte gap between
115d4401354Smrg  the major opcode and the length; if the request does not have any data in
116d4401354Smrg  that gap, put a one byte pad as the first element.  Extension requests
117d4401354Smrg  always have this gap filled with the minor opcode.
118d4401354Smrg
119d4401354Smrg  The optional reply element is present if the request has a reply.  The
120d4401354Smrg  content of the reply element represents the fields in the reply, and
121d4401354Smrg  consists of zero or more of the field, pad, and list elements listed in the
122d4401354Smrg  "Structure Contents" section below.  Note that the first field in the reply
123d4401354Smrg  always goes into the one-byte gap between the response type and the sequence
124d4401354Smrg  number; if the reply does not have any data in that gap, put a one byte pad
125d4401354Smrg  as the first element.
126d4401354Smrg
127d4401354Smrg  If the optional combine-adjacent attribute is true, multiple adjacent
128d4401354Smrg  requests of the same type may be combined into a single request without
129d4401354Smrg  affecting the semantics of the requests.
130d4401354Smrg
131f591e195Smrg<event name="identifier" number="integer"
132f591e195Smrg       [[no-sequence-number="true"] | [xge="true"]]>
133d4401354Smrg  structure contents
134d4401354Smrg</event>
135d4401354Smrg
136d4401354Smrg  This element represents an X protocol event.  The name attribute gives the
137d4401354Smrg  name of the event, and the number attribute gives the event number.  The
138d4401354Smrg  content of the event element represents the fields in the event, and
139d4401354Smrg  consists of zero or more of the field, pad, and list elements listed in the
140d4401354Smrg  "Structure Contents" section below.
141d4401354Smrg
142d4401354Smrg  If the optional no-sequence-number attribute is true, the event does not
143d4401354Smrg  include a sequence number.  This is a special-case for the KeymapNotify
144d4401354Smrg  event in the core protocol, and should not be used in any other event.
145d4401354Smrg
146f591e195Smrg  If the optional xge attribute is true, the event is an X Generic Event and
147f591e195Smrg  will be treated as such.
148f591e195Smrg
149f591e195Smrg  The no-sequence-number and xge attribute can not be combined.
150f591e195Smrg
151d4401354Smrg<error name="identifier" number="integer">
152d4401354Smrg  structure contents
153d4401354Smrg</error>
154d4401354Smrg
155d4401354Smrg  This element represents an X protocol error.  The name attribute gives the
156d4401354Smrg  name of the error, and the number attribute gives the error number.  The
157d4401354Smrg  content of the error element represents the fields in the error, and
158d4401354Smrg  consists of zero or more of the field, pad, and list elements listed in the
159d4401354Smrg  "Structure Contents" section below.
160d4401354Smrg
161d4401354Smrg<eventcopy name="identifier" number="identifier" ref="identifier" />
162d4401354Smrg
163d4401354Smrg  This element creates an alias for the event named in the ref attribute, with
164d4401354Smrg  the new name given in the name attribute, and the new event number given in
165d4401354Smrg  the number attribute.
166d4401354Smrg
167d4401354Smrg<errorcopy name="identifier" number="identifier" ref="identifier" />
168d4401354Smrg
169d4401354Smrg  This element creates an alias for the error named in the ref attribute, with
170d4401354Smrg  the new name given in the name attribute, and the new error number given in
171d4401354Smrg  the number attribute.
172d4401354Smrg
173d4401354Smrg
174d4401354SmrgStructure Contents
175d4401354Smrg------------------
176d4401354Smrg
177d4401354SmrgNote: "type" attributes below refer to types defined by previous elements,
178d4401354Smrgeither in the current extension, xproto, or one of the imported extensions.
179d4401354SmrgThe type name must refer to only one possible type; if more than one type
180d4401354Smrgmatches, an error occurs.  To avoid this, the type may be explicitly prefixed
181d4401354Smrgwith a namespace, which should be the value of the header attribute on the
182d4401354Smrgprotocol description containing the desired type.  The namespace and type are
183d4401354Smrgseparated by a single colon.  For example, to refer to the PIXMAP type defined
184d4401354Smrgin glx rather than the one defined in xproto, use type="glx:PIXMAP" rather
185d4401354Smrgthan type="PIXMAP".
186d4401354Smrg
187d4401354SmrgNote: Most of the below may optionally contain an enum, altenum, or mask
188d4401354Smrgattribute, which follows the above rules for "type". "enum" is an exhaustive
189d4401354Smrgenum; the value is restricted to one of the constants named in the enum.
190d4401354Smrg"altenum" may be one of the values contained in the enum, but it need not be.
191d4401354Smrg"mask" refers to an enum to be used as a bitmask.
192d4401354Smrg
193d4401354Smrg<pad bytes="integer" />
194d4401354Smrg
195d4401354Smrg  This element declares some padding in a data structure.  The bytes
196d4401354Smrg  attribute declares the number of bytes of padding.
197d4401354Smrg
198d4401354Smrg<field type="identifier" name="identifier" />
199d4401354Smrg
200d4401354Smrg  This element represents a field in a data structure.  The type attribute
201d4401354Smrg  declares the data type of the field, and the name attribute gives the name
202d4401354Smrg  of the field.
203d4401354Smrg
204b26960f7Smrg<fd name="identifier" />
205b26960f7Smrg
206b26960f7Smrg  This element represents a file descriptor field passed with the request.  The
207b26960f7Smrg  name attribute gives the name of the field.
208b26960f7Smrg
209b26960f7Smrg  While ordinary fields are encoded as part of the request, file descriptor
210b26960f7Smrg  fields are generally passed via an out-of-band mechanism.
211b26960f7Smrg
212d4401354Smrg<list type="identifier" name="identifier">expression</list>
213d4401354Smrg
214d4401354Smrg  This element represents an array or list of fields in a data structure.  The
215d4401354Smrg  type attribute declares the data type of the field, and the name attribute
216d4401354Smrg  gives the name of the field.  The content is an expression giving the length
217d4401354Smrg  of the list in terms of other fields in the structure.  See the section
218d4401354Smrg  "Expressions" for details on the expression representation.
219d4401354Smrg
220d4401354Smrg<localfield type="identifier" name="identifier" />
221d4401354Smrg
222d4401354Smrg  This element represents a parameter in a request that is not sent over the
223d4401354Smrg  wire.  The field can be referenced in the length expressions of lists or in
224d4401354Smrg  an exprfield.  The type attribute declares the data type of the field, and
225d4401354Smrg  the name attribute gives the name of the field.
226d4401354Smrg
227d4401354Smrg<exprfield type="identifier" name="identifier">expression</exprfield>
228d4401354Smrg
229d4401354Smrg  This element represents a field in a request that is calculated rather than
230d4401354Smrg  supplied by the caller.  The type attribute declares the data type of the
231d4401354Smrg  field, and the name attribute gives the name of the field.  The content is
232d4401354Smrg  the expression giving the value of the field.  See the section "Expressions"
233d4401354Smrg  for details on the expression representation.
234d4401354Smrg
235d4401354Smrg<valueparam value-mask-type="identifier" value-mask-name="identifier"
236d4401354Smrg            value-list-name="identifier" />
237d4401354Smrg
238d4401354Smrg  This element represents a BITMASK/LISTofVALUE parameter pair: a bitmask
239d4401354Smrg  defining the set of values included, and a list containing these values.
240d4401354Smrg  value-mask-type gives the type of the bitmask; this must be CARD16 or
241d4401354Smrg  CARD32.  value-mask-name gives the field name of the bitmask, and
242986c8b3dSmrg  value-list-name gives the field name of the list of values. Please use
243986c8b3dSmrg  <switch> instead for new protocol definitions.
244d4401354Smrg
245986c8b3dSmrg<switch name="identifier"> switch expression
246f591e195Smrg    <bitcase> bitcase expression(s), fields </bitcase> </switch>
247986c8b3dSmrg
248986c8b3dSmrg  This element represents conditional inclusion of fields. It can be viewed
249986c8b3dSmrg  as sequence of multiple ifs: if ( switch expression & bitcase expression )
250f591e195Smrg  is non-zero, bitcase fields are included in structure.  It can be used only
251f591e195Smrg  as the last field of a structure.
252f591e195Smrg
253f591e195Smrg  When a bitcase includes multiple <enumref> clauses, the contents of the
254f591e195Smrg  bitcase are only present once regardless of the number of bitcase expressions
255f591e195Smrg  that match.
256f591e195Smrg
257f591e195Smrg  New protocol definitions should prefer to use this instead of <valueparam>.
258d4401354Smrg
259d4401354SmrgExpressions
260d4401354Smrg-----------
261d4401354Smrg
262d4401354Smrg  Expressions consist of a tree of <op> elements with leaves consisting of
263d4401354Smrg  <fieldref> or <value> elements.
264d4401354Smrg
265d4401354Smrg<op op="operator">expression expression</op>
266d4401354Smrg
267d4401354Smrg  The op element represents an operator, with the op attribute specifying
268d4401354Smrg  which operator.  The supported operations are +, -, *, /, &amp;, and
269d4401354Smrg  &lt;&lt;, and their semantics are identical to the corresponding operators
270d4401354Smrg  in C.  The two operand expressions may be other expression elements.
271d4401354Smrg
272d4401354Smrg<fieldref>identifier</fieldref>
273d4401354Smrg
274d4401354Smrg  The fieldref element represents a reference to the value of another field in
275d4401354Smrg  the structure containing this expression.  The identifier is the value of
276d4401354Smrg  the "name" attribute on the referenced field.
277d4401354Smrg
278d4401354Smrg<value>integer</value>
279d4401354Smrg
280d4401354Smrg  The value element represents a literal integer value in an expression.  The
281d4401354Smrg  integer may be expressed in decimal or hexadecimal.
282d4401354Smrg
283d4401354Smrg<bit>integer</bit>
284d4401354Smrg
285d4401354Smrg  The bit element represents a literal bitmask value in an expression.
286d4401354Smrg  The integer must be in the range 0..31, expanding to (1<<n) in C.
287986c8b3dSmrg
288986c8b3dSmrg<enumref ref="identifier">enum item identifier</enumref>
289986c8b3dSmrg
290986c8b3dSmrg  This element represents a reference to item of enum.
291986c8b3dSmrg
292986c8b3dSmrg<unop op="operator">expression</unop>
293986c8b3dSmrg
294986c8b3dSmrg  This element represents a unary operator, with the op attribute specifying
295986c8b3dSmrg  which operator. The only supported operation so far is ~, and its semantic
296986c8b3dSmrg  is identical to the corresponding operator in C.
297986c8b3dSmrg
298986c8b3dSmrg<sumof ref="identifier" />
299986c8b3dSmrg
300986c8b3dSmrg  This element represents a sumation of the elements of the referenced list.
301986c8b3dSmrg
302986c8b3dSmrg<popcount>expression</popcount>
303986c8b3dSmrg
304986c8b3dSmrg  This element represents the number of bits set in the expression.
305986c8b3dSmrg
306986c8b3dSmrgDocumentation
307986c8b3dSmrg-------------
308986c8b3dSmrg
309986c8b3dSmrg  Documentation for each request, reply or event is stored in the appropriate
310986c8b3dSmrg  element using a <doc> element. The <doc> element can contain the following
311986c8b3dSmrg  elements:
312986c8b3dSmrg
313986c8b3dSmrg<brief>brief description</brief>
314986c8b3dSmrg
315986c8b3dSmrg  A short description of the request, reply or event. For example "makes a
316986c8b3dSmrg  window visible" for MapWindow. This will end up in the manpage NAME section
317986c8b3dSmrg  and in the doxygen @brief description.
318986c8b3dSmrg
319986c8b3dSmrg<description><![CDATA[longer description]]></description>
320986c8b3dSmrg
321986c8b3dSmrg  The full description. Use `` to highlight words, such as "Draws
322986c8b3dSmrg  `points_len`-1 lines between each pair of points…"
323986c8b3dSmrg
324986c8b3dSmrg<example><![CDATA[example code]]</description>
325986c8b3dSmrg
326986c8b3dSmrg  Example C code illustrating the usage of the particular request, reply or
327986c8b3dSmrg  event.
328986c8b3dSmrg
329986c8b3dSmrg<field name="name">field description</field>
330986c8b3dSmrg
331986c8b3dSmrg  The full description for the specified field. Depending on the context, this
332986c8b3dSmrg  is either a request parameter or a reply/event datastructure field.
333986c8b3dSmrg
334986c8b3dSmrg<error type="type">error description</field>
335986c8b3dSmrg
336986c8b3dSmrg  The full description for an error which can occur due to this request.
337986c8b3dSmrg
338986c8b3dSmrg<see type="request" name="name" />
339986c8b3dSmrg
340986c8b3dSmrg  A reference to another relevant program, function, request or event.
341