xml-xcb.txt revision 891601f5
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 187891601f5SmrgNote: Most of the below may optionally contain an enum, altenum, mask or altmask 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. 191891601f5Smrg"mask" refers to an exhaustive enum to be used as a bitmask. 192891601f5Smrg"altmask" may be a mask from the referred enum, but it need not be. 193d4401354Smrg 194891601f5Smrg<pad bytes="integer" serialize="bool" /> 195d4401354Smrg 196d4401354Smrg This element declares some padding in a data structure. The bytes 197d4401354Smrg attribute declares the number of bytes of padding. 198d4401354Smrg 199891601f5Smrg If serialize="true", then the pad will be serialized/deserialized. 200891601f5Smrg This is only needed for ABI compatibility with legacy. 201891601f5Smrg Newly added pads should not be defined with serialize="true". 202891601f5Smrg 203891601f5Smrg The serialize attribute may be omitted. 204891601f5Smrg Default is serialize="false". 205891601f5Smrg 206d4401354Smrg<field type="identifier" name="identifier" /> 207d4401354Smrg 208d4401354Smrg This element represents a field in a data structure. The type attribute 209d4401354Smrg declares the data type of the field, and the name attribute gives the name 210d4401354Smrg of the field. 211d4401354Smrg 212b26960f7Smrg<fd name="identifier" /> 213b26960f7Smrg 214b26960f7Smrg This element represents a file descriptor field passed with the request. The 215b26960f7Smrg name attribute gives the name of the field. 216b26960f7Smrg 217b26960f7Smrg While ordinary fields are encoded as part of the request, file descriptor 218b26960f7Smrg fields are generally passed via an out-of-band mechanism. 219b26960f7Smrg 220d4401354Smrg<list type="identifier" name="identifier">expression</list> 221d4401354Smrg 222d4401354Smrg This element represents an array or list of fields in a data structure. The 223d4401354Smrg type attribute declares the data type of the field, and the name attribute 224d4401354Smrg gives the name of the field. The content is an expression giving the length 225d4401354Smrg of the list in terms of other fields in the structure. See the section 226d4401354Smrg "Expressions" for details on the expression representation. 227d4401354Smrg 228d4401354Smrg<exprfield type="identifier" name="identifier">expression</exprfield> 229d4401354Smrg 230d4401354Smrg This element represents a field in a request that is calculated rather than 231d4401354Smrg supplied by the caller. The type attribute declares the data type of the 232d4401354Smrg field, and the name attribute gives the name of the field. The content is 233d4401354Smrg the expression giving the value of the field. See the section "Expressions" 234d4401354Smrg for details on the expression representation. 235d4401354Smrg 236d4401354Smrg<valueparam value-mask-type="identifier" value-mask-name="identifier" 237d4401354Smrg value-list-name="identifier" /> 238d4401354Smrg 239d4401354Smrg This element represents a BITMASK/LISTofVALUE parameter pair: a bitmask 240d4401354Smrg defining the set of values included, and a list containing these values. 241d4401354Smrg value-mask-type gives the type of the bitmask; this must be CARD16 or 242d4401354Smrg CARD32. value-mask-name gives the field name of the bitmask, and 243986c8b3dSmrg value-list-name gives the field name of the list of values. Please use 244986c8b3dSmrg <switch> instead for new protocol definitions. 245d4401354Smrg 246986c8b3dSmrg<switch name="identifier"> switch expression 247891601f5Smrg <bitcase [name="identifier"]> bitcase expression(s), fields </bitcase> 248891601f5Smrg <case [name="identifier"]> case expression(s), fields </case> 249891601f5Smrg</switch> 250986c8b3dSmrg 251986c8b3dSmrg This element represents conditional inclusion of fields. It can be viewed 252891601f5Smrg as sequence of multiple ifs: 253891601f5Smrg 254891601f5Smrg <bitcase>: 255891601f5Smrg if ( switch expression & bitcase expression ) is non-zero, 256891601f5Smrg bitcase fields are included in structure. 257891601f5Smrg 258891601f5Smrg <case>: 259891601f5Smrg if ( switch expression == case expression ) is true, 260891601f5Smrg then case fields are included in structure. 261891601f5Smrg 262891601f5Smrg It can be used only as the last field of a structure. 263891601f5Smrg 264891601f5Smrg When a bitcase or case includes multiple <enumref> clauses, the contents 265891601f5Smrg of the bitcase or case are only present once regardless of the number of 266891601f5Smrg bitcase or case expressions that match. 267891601f5Smrg 268891601f5Smrg <enumref> inside <bitcase> can only refer to an enum's <bit> members. 269891601f5Smrg <enumref> inside <case> can only refer to an enum's <value> members. 270891601f5Smrg 271891601f5Smrg A switch may contain multiple <bitcase> or <case> elements. 272891601f5Smrg Usually it will only contain <bitcase> elements 273891601f5Smrg or only contain <case> elements. 274891601f5Smrg That is, mixing of <case> and <bitcase> usually doesn't make any sense. 275f591e195Smrg 276891601f5Smrg The same value may appear in multiple <case> or <bitcase> elements. 277891601f5Smrg 278891601f5Smrg New protocol definitions should prefer to use this instead of <valueparam> 279891601f5Smrg and instead of <union>. 280f591e195Smrg 281d4401354Smrg 282d4401354SmrgExpressions 283d4401354Smrg----------- 284d4401354Smrg 285d4401354Smrg Expressions consist of a tree of <op> elements with leaves consisting of 286d4401354Smrg <fieldref> or <value> elements. 287d4401354Smrg 288d4401354Smrg<op op="operator">expression expression</op> 289d4401354Smrg 290d4401354Smrg The op element represents an operator, with the op attribute specifying 291d4401354Smrg which operator. The supported operations are +, -, *, /, &, and 292d4401354Smrg <<, and their semantics are identical to the corresponding operators 293d4401354Smrg in C. The two operand expressions may be other expression elements. 294d4401354Smrg 295d4401354Smrg<fieldref>identifier</fieldref> 296d4401354Smrg 297d4401354Smrg The fieldref element represents a reference to the value of another field in 298d4401354Smrg the structure containing this expression. The identifier is the value of 299d4401354Smrg the "name" attribute on the referenced field. 300d4401354Smrg 301891601f5Smrg<paramref type="type">identifier</paramref> 302891601f5Smrg 303891601f5Smrg A paramref is similar to a fieldref, but it refers to the value of 304891601f5Smrg a field in the context which refers to the struct which contains the paramref. 305891601f5Smrg 306891601f5Smrg So, it refers to a field outside of the structure where it is defined. 307891601f5Smrg This has the following consequences: 308891601f5Smrg * The generator cannot deduce its type. 309891601f5Smrg So, it is mandatory to specify its type. 310891601f5Smrg * The identifier-name must not be used as a field in the structure 311891601f5Smrg which contaons the paramref. 312891601f5Smrg 313891601f5Smrg For an example, see struct "DeviceTimeCoord" and request/reply 314891601f5Smrg "GetDeviceMotionEvents" in xinput.xml, where paramref "num_axes" 315891601f5Smrg in struct DeviceTimeCoord refers to field "num_axes" in 316891601f5Smrg the DeviceTimeCoord reply. 317891601f5Smrg 318d4401354Smrg<value>integer</value> 319d4401354Smrg 320d4401354Smrg The value element represents a literal integer value in an expression. The 321d4401354Smrg integer may be expressed in decimal or hexadecimal. 322d4401354Smrg 323d4401354Smrg<bit>integer</bit> 324d4401354Smrg 325d4401354Smrg The bit element represents a literal bitmask value in an expression. 326d4401354Smrg The integer must be in the range 0..31, expanding to (1<<n) in C. 327986c8b3dSmrg 328986c8b3dSmrg<enumref ref="identifier">enum item identifier</enumref> 329986c8b3dSmrg 330986c8b3dSmrg This element represents a reference to item of enum. 331986c8b3dSmrg 332986c8b3dSmrg<unop op="operator">expression</unop> 333986c8b3dSmrg 334986c8b3dSmrg This element represents a unary operator, with the op attribute specifying 335986c8b3dSmrg which operator. The only supported operation so far is ~, and its semantic 336986c8b3dSmrg is identical to the corresponding operator in C. 337986c8b3dSmrg 338986c8b3dSmrg<sumof ref="identifier" /> 339986c8b3dSmrg 340986c8b3dSmrg This element represents a sumation of the elements of the referenced list. 341986c8b3dSmrg 342891601f5Smrg<sumof ref="identifier" >expression</sumof> 343891601f5Smrg 344891601f5Smrg The expression is evaluated for each element of the referenced list, 345891601f5Smrg in the context of this element. 346891601f5Smrg This sumof element then represents a sumation of the results of these 347891601f5Smrg evaluations. 348891601f5Smrg 349891601f5Smrg expression will usually be a fieldref which references a field of 350891601f5Smrg a list-element or an expression containing a fieldref, 351891601f5Smrg such as popcount of a fieldref. 352891601f5Smrg 353986c8b3dSmrg<popcount>expression</popcount> 354986c8b3dSmrg 355986c8b3dSmrg This element represents the number of bits set in the expression. 356986c8b3dSmrg 357891601f5Smrg<listelement-ref/> 358891601f5Smrg 359891601f5Smrg This element represents the current list-element when used inside 360891601f5Smrg a list-iteration expression such as <sumof>. 361891601f5Smrg 362986c8b3dSmrgDocumentation 363986c8b3dSmrg------------- 364986c8b3dSmrg 365986c8b3dSmrg Documentation for each request, reply or event is stored in the appropriate 366986c8b3dSmrg element using a <doc> element. The <doc> element can contain the following 367986c8b3dSmrg elements: 368986c8b3dSmrg 369986c8b3dSmrg<brief>brief description</brief> 370986c8b3dSmrg 371986c8b3dSmrg A short description of the request, reply or event. For example "makes a 372986c8b3dSmrg window visible" for MapWindow. This will end up in the manpage NAME section 373986c8b3dSmrg and in the doxygen @brief description. 374986c8b3dSmrg 375986c8b3dSmrg<description><![CDATA[longer description]]></description> 376986c8b3dSmrg 377986c8b3dSmrg The full description. Use `` to highlight words, such as "Draws 378986c8b3dSmrg `points_len`-1 lines between each pair of points…" 379986c8b3dSmrg 380986c8b3dSmrg<example><![CDATA[example code]]</description> 381986c8b3dSmrg 382986c8b3dSmrg Example C code illustrating the usage of the particular request, reply or 383986c8b3dSmrg event. 384986c8b3dSmrg 385986c8b3dSmrg<field name="name">field description</field> 386986c8b3dSmrg 387986c8b3dSmrg The full description for the specified field. Depending on the context, this 388986c8b3dSmrg is either a request parameter or a reply/event datastructure field. 389986c8b3dSmrg 390986c8b3dSmrg<error type="type">error description</field> 391986c8b3dSmrg 392986c8b3dSmrg The full description for an error which can occur due to this request. 393986c8b3dSmrg 394986c8b3dSmrg<see type="request" name="name" /> 395986c8b3dSmrg 396986c8b3dSmrg A reference to another relevant program, function, request or event. 397