xml-xcb.txt revision a27842ff
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 79a27842ffSmrg<eventstruct name="identifier">event-type-selector list</struct> 80a27842ffSmrg 81a27842ffSmrg This element represents a data structure that is the wire-representation of 82a27842ffSmrg an event. The event can be any type that's selected by the 83a27842ffSmrg event-type-selector list. 84a27842ffSmrg 85d4401354Smrg<xidtype name="identifier" /> 86d4401354Smrg 87d4401354Smrg This element represents an identifier for a particular type of resource. 88d4401354Smrg The name attribute gives the name of the new type. 89d4401354Smrg 90d4401354Smrg<enum name="identifier"> 91d4401354Smrg <item name="identifier">[optional expression]</item> 92d4401354Smrg ... 93d4401354Smrg</enum> 94d4401354Smrg 95d4401354Smrg The enum element represents an enumeration type, which can take on any of 96d4401354Smrg the values given by the contained item elements. The name attribute on the 97d4401354Smrg enum gives the name of the enumerated type. 98d4401354Smrg 99d4401354Smrg The item element represents one possible value of an enumerated type. The 100d4401354Smrg name attribute on the item gives the name of that value, and the optional 101d4401354Smrg content is an expression giving the numeric value. If the expression is 102d4401354Smrg omitted, the value will be one more than that of the previous item, or 0 for 103d4401354Smrg the first item. 104d4401354Smrg 105d4401354Smrg<typedef oldname="identifier" newname="identifier" /> 106d4401354Smrg 107d4401354Smrg The typedef element declares the type given by the newname attribute to be 108d4401354Smrg an alias for the type given by the oldname attribute. 109d4401354Smrg 110d4401354Smrg<request name="identifier" opcode="integer" [combine-adjacent="true"]> 111d4401354Smrg structure contents 112d4401354Smrg [<reply>structure contents</reply>] 113d4401354Smrg</request> 114d4401354Smrg 115d4401354Smrg The request element represents an X protocol request. The name attribute 116d4401354Smrg gives the name of the request, and the opcode attribute gives the numeric 117d4401354Smrg request code. The content of the request element represents the fields in 118d4401354Smrg the request, and consists of one or more of any of the elements listed in 119d4401354Smrg the "Structure Contents" section below. Note that for requests in the core 120d4401354Smrg protocol, the first field in the request goes into the one-byte gap between 121d4401354Smrg the major opcode and the length; if the request does not have any data in 122d4401354Smrg that gap, put a one byte pad as the first element. Extension requests 123d4401354Smrg always have this gap filled with the minor opcode. 124d4401354Smrg 125d4401354Smrg The optional reply element is present if the request has a reply. The 126d4401354Smrg content of the reply element represents the fields in the reply, and 127d4401354Smrg consists of zero or more of the field, pad, and list elements listed in the 128d4401354Smrg "Structure Contents" section below. Note that the first field in the reply 129d4401354Smrg always goes into the one-byte gap between the response type and the sequence 130d4401354Smrg number; if the reply does not have any data in that gap, put a one byte pad 131d4401354Smrg as the first element. 132d4401354Smrg 133d4401354Smrg If the optional combine-adjacent attribute is true, multiple adjacent 134d4401354Smrg requests of the same type may be combined into a single request without 135d4401354Smrg affecting the semantics of the requests. 136d4401354Smrg 137f591e195Smrg<event name="identifier" number="integer" 138f591e195Smrg [[no-sequence-number="true"] | [xge="true"]]> 139d4401354Smrg structure contents 140d4401354Smrg</event> 141d4401354Smrg 142d4401354Smrg This element represents an X protocol event. The name attribute gives the 143d4401354Smrg name of the event, and the number attribute gives the event number. The 144d4401354Smrg content of the event element represents the fields in the event, and 145d4401354Smrg consists of zero or more of the field, pad, and list elements listed in the 146d4401354Smrg "Structure Contents" section below. 147d4401354Smrg 148d4401354Smrg If the optional no-sequence-number attribute is true, the event does not 149d4401354Smrg include a sequence number. This is a special-case for the KeymapNotify 150d4401354Smrg event in the core protocol, and should not be used in any other event. 151d4401354Smrg 152f591e195Smrg If the optional xge attribute is true, the event is an X Generic Event and 153f591e195Smrg will be treated as such. 154f591e195Smrg 155f591e195Smrg The no-sequence-number and xge attribute can not be combined. 156f591e195Smrg 157d4401354Smrg<error name="identifier" number="integer"> 158d4401354Smrg structure contents 159d4401354Smrg</error> 160d4401354Smrg 161d4401354Smrg This element represents an X protocol error. The name attribute gives the 162d4401354Smrg name of the error, and the number attribute gives the error number. The 163d4401354Smrg content of the error element represents the fields in the error, and 164d4401354Smrg consists of zero or more of the field, pad, and list elements listed in the 165d4401354Smrg "Structure Contents" section below. 166d4401354Smrg 167d4401354Smrg<eventcopy name="identifier" number="identifier" ref="identifier" /> 168d4401354Smrg 169d4401354Smrg This element creates an alias for the event named in the ref attribute, with 170d4401354Smrg the new name given in the name attribute, and the new event number given in 171d4401354Smrg the number attribute. 172d4401354Smrg 173d4401354Smrg<errorcopy name="identifier" number="identifier" ref="identifier" /> 174d4401354Smrg 175d4401354Smrg This element creates an alias for the error named in the ref attribute, with 176d4401354Smrg the new name given in the name attribute, and the new error number given in 177d4401354Smrg the number attribute. 178d4401354Smrg 179d4401354Smrg 180d4401354SmrgStructure Contents 181d4401354Smrg------------------ 182d4401354Smrg 183d4401354SmrgNote: "type" attributes below refer to types defined by previous elements, 184d4401354Smrgeither in the current extension, xproto, or one of the imported extensions. 185d4401354SmrgThe type name must refer to only one possible type; if more than one type 186d4401354Smrgmatches, an error occurs. To avoid this, the type may be explicitly prefixed 187d4401354Smrgwith a namespace, which should be the value of the header attribute on the 188d4401354Smrgprotocol description containing the desired type. The namespace and type are 189d4401354Smrgseparated by a single colon. For example, to refer to the PIXMAP type defined 190d4401354Smrgin glx rather than the one defined in xproto, use type="glx:PIXMAP" rather 191d4401354Smrgthan type="PIXMAP". 192d4401354Smrg 193891601f5SmrgNote: Most of the below may optionally contain an enum, altenum, mask or altmask 194d4401354Smrgattribute, which follows the above rules for "type". "enum" is an exhaustive 195d4401354Smrgenum; the value is restricted to one of the constants named in the enum. 196d4401354Smrg"altenum" may be one of the values contained in the enum, but it need not be. 197891601f5Smrg"mask" refers to an exhaustive enum to be used as a bitmask. 198891601f5Smrg"altmask" may be a mask from the referred enum, but it need not be. 199d4401354Smrg 200891601f5Smrg<pad bytes="integer" serialize="bool" /> 201d4401354Smrg 202d4401354Smrg This element declares some padding in a data structure. The bytes 203d4401354Smrg attribute declares the number of bytes of padding. 204d4401354Smrg 205891601f5Smrg If serialize="true", then the pad will be serialized/deserialized. 206891601f5Smrg This is only needed for ABI compatibility with legacy. 207891601f5Smrg Newly added pads should not be defined with serialize="true". 208891601f5Smrg 209891601f5Smrg The serialize attribute may be omitted. 210891601f5Smrg Default is serialize="false". 211891601f5Smrg 212d4401354Smrg<field type="identifier" name="identifier" /> 213d4401354Smrg 214d4401354Smrg This element represents a field in a data structure. The type attribute 215d4401354Smrg declares the data type of the field, and the name attribute gives the name 216d4401354Smrg of the field. 217d4401354Smrg 218b26960f7Smrg<fd name="identifier" /> 219b26960f7Smrg 220b26960f7Smrg This element represents a file descriptor field passed with the request. The 221b26960f7Smrg name attribute gives the name of the field. 222b26960f7Smrg 223b26960f7Smrg While ordinary fields are encoded as part of the request, file descriptor 224b26960f7Smrg fields are generally passed via an out-of-band mechanism. 225b26960f7Smrg 226d4401354Smrg<list type="identifier" name="identifier">expression</list> 227d4401354Smrg 228d4401354Smrg This element represents an array or list of fields in a data structure. The 229d4401354Smrg type attribute declares the data type of the field, and the name attribute 230d4401354Smrg gives the name of the field. The content is an expression giving the length 231d4401354Smrg of the list in terms of other fields in the structure. See the section 232d4401354Smrg "Expressions" for details on the expression representation. 233d4401354Smrg 234d4401354Smrg<exprfield type="identifier" name="identifier">expression</exprfield> 235d4401354Smrg 236d4401354Smrg This element represents a field in a request that is calculated rather than 237d4401354Smrg supplied by the caller. The type attribute declares the data type of the 238d4401354Smrg field, and the name attribute gives the name of the field. The content is 239d4401354Smrg the expression giving the value of the field. See the section "Expressions" 240d4401354Smrg for details on the expression representation. 241d4401354Smrg 242d4401354Smrg<valueparam value-mask-type="identifier" value-mask-name="identifier" 243d4401354Smrg value-list-name="identifier" /> 244d4401354Smrg 245d4401354Smrg This element represents a BITMASK/LISTofVALUE parameter pair: a bitmask 246d4401354Smrg defining the set of values included, and a list containing these values. 247d4401354Smrg value-mask-type gives the type of the bitmask; this must be CARD16 or 248d4401354Smrg CARD32. value-mask-name gives the field name of the bitmask, and 249986c8b3dSmrg value-list-name gives the field name of the list of values. Please use 250986c8b3dSmrg <switch> instead for new protocol definitions. 251d4401354Smrg 252986c8b3dSmrg<switch name="identifier"> switch expression 253891601f5Smrg <bitcase [name="identifier"]> bitcase expression(s), fields </bitcase> 254891601f5Smrg <case [name="identifier"]> case expression(s), fields </case> 255891601f5Smrg</switch> 256986c8b3dSmrg 257986c8b3dSmrg This element represents conditional inclusion of fields. It can be viewed 258891601f5Smrg as sequence of multiple ifs: 259891601f5Smrg 260891601f5Smrg <bitcase>: 261891601f5Smrg if ( switch expression & bitcase expression ) is non-zero, 262891601f5Smrg bitcase fields are included in structure. 263891601f5Smrg 264891601f5Smrg <case>: 265891601f5Smrg if ( switch expression == case expression ) is true, 266891601f5Smrg then case fields are included in structure. 267891601f5Smrg 268891601f5Smrg It can be used only as the last field of a structure. 269891601f5Smrg 270891601f5Smrg When a bitcase or case includes multiple <enumref> clauses, the contents 271891601f5Smrg of the bitcase or case are only present once regardless of the number of 272891601f5Smrg bitcase or case expressions that match. 273891601f5Smrg 274891601f5Smrg <enumref> inside <bitcase> can only refer to an enum's <bit> members. 275891601f5Smrg <enumref> inside <case> can only refer to an enum's <value> members. 276891601f5Smrg 277891601f5Smrg A switch may contain multiple <bitcase> or <case> elements. 278891601f5Smrg Usually it will only contain <bitcase> elements 279891601f5Smrg or only contain <case> elements. 280891601f5Smrg That is, mixing of <case> and <bitcase> usually doesn't make any sense. 281f591e195Smrg 282891601f5Smrg The same value may appear in multiple <case> or <bitcase> elements. 283891601f5Smrg 284891601f5Smrg New protocol definitions should prefer to use this instead of <valueparam> 285891601f5Smrg and instead of <union>. 286f591e195Smrg 287d4401354Smrg 288d4401354SmrgExpressions 289d4401354Smrg----------- 290d4401354Smrg 291d4401354Smrg Expressions consist of a tree of <op> elements with leaves consisting of 292d4401354Smrg <fieldref> or <value> elements. 293d4401354Smrg 294d4401354Smrg<op op="operator">expression expression</op> 295d4401354Smrg 296d4401354Smrg The op element represents an operator, with the op attribute specifying 297d4401354Smrg which operator. The supported operations are +, -, *, /, &, and 298d4401354Smrg <<, and their semantics are identical to the corresponding operators 299d4401354Smrg in C. The two operand expressions may be other expression elements. 300d4401354Smrg 301d4401354Smrg<fieldref>identifier</fieldref> 302d4401354Smrg 303d4401354Smrg The fieldref element represents a reference to the value of another field in 304d4401354Smrg the structure containing this expression. The identifier is the value of 305d4401354Smrg the "name" attribute on the referenced field. 306d4401354Smrg 307891601f5Smrg<paramref type="type">identifier</paramref> 308891601f5Smrg 309891601f5Smrg A paramref is similar to a fieldref, but it refers to the value of 310891601f5Smrg a field in the context which refers to the struct which contains the paramref. 311891601f5Smrg 312891601f5Smrg So, it refers to a field outside of the structure where it is defined. 313891601f5Smrg This has the following consequences: 314891601f5Smrg * The generator cannot deduce its type. 315891601f5Smrg So, it is mandatory to specify its type. 316891601f5Smrg * The identifier-name must not be used as a field in the structure 317891601f5Smrg which contaons the paramref. 318891601f5Smrg 319891601f5Smrg For an example, see struct "DeviceTimeCoord" and request/reply 320891601f5Smrg "GetDeviceMotionEvents" in xinput.xml, where paramref "num_axes" 321891601f5Smrg in struct DeviceTimeCoord refers to field "num_axes" in 322891601f5Smrg the DeviceTimeCoord reply. 323891601f5Smrg 324d4401354Smrg<value>integer</value> 325d4401354Smrg 326d4401354Smrg The value element represents a literal integer value in an expression. The 327d4401354Smrg integer may be expressed in decimal or hexadecimal. 328d4401354Smrg 329d4401354Smrg<bit>integer</bit> 330d4401354Smrg 331d4401354Smrg The bit element represents a literal bitmask value in an expression. 332d4401354Smrg The integer must be in the range 0..31, expanding to (1<<n) in C. 333986c8b3dSmrg 334986c8b3dSmrg<enumref ref="identifier">enum item identifier</enumref> 335986c8b3dSmrg 336986c8b3dSmrg This element represents a reference to item of enum. 337986c8b3dSmrg 338986c8b3dSmrg<unop op="operator">expression</unop> 339986c8b3dSmrg 340986c8b3dSmrg This element represents a unary operator, with the op attribute specifying 341986c8b3dSmrg which operator. The only supported operation so far is ~, and its semantic 342986c8b3dSmrg is identical to the corresponding operator in C. 343986c8b3dSmrg 344986c8b3dSmrg<sumof ref="identifier" /> 345986c8b3dSmrg 346986c8b3dSmrg This element represents a sumation of the elements of the referenced list. 347986c8b3dSmrg 348891601f5Smrg<sumof ref="identifier" >expression</sumof> 349891601f5Smrg 350891601f5Smrg The expression is evaluated for each element of the referenced list, 351891601f5Smrg in the context of this element. 352891601f5Smrg This sumof element then represents a sumation of the results of these 353891601f5Smrg evaluations. 354891601f5Smrg 355891601f5Smrg expression will usually be a fieldref which references a field of 356891601f5Smrg a list-element or an expression containing a fieldref, 357891601f5Smrg such as popcount of a fieldref. 358891601f5Smrg 359986c8b3dSmrg<popcount>expression</popcount> 360986c8b3dSmrg 361986c8b3dSmrg This element represents the number of bits set in the expression. 362986c8b3dSmrg 363891601f5Smrg<listelement-ref/> 364891601f5Smrg 365891601f5Smrg This element represents the current list-element when used inside 366891601f5Smrg a list-iteration expression such as <sumof>. 367891601f5Smrg 368a27842ffSmrg 369a27842ffSmrgEvent-Type-Selector List 370a27842ffSmrg------------------------ 371a27842ffSmrg 372a27842ffSmrg The event-type-selector list selects a set of eventtypes. 373a27842ffSmrg It consists of any number of the following elements: 374a27842ffSmrg 375a27842ffSmrg <allowed extension="identifier" xge="boolean" 376a27842ffSmrg opcode-min="integer" opcode-max="integer" /> 377a27842ffSmrg 378a27842ffSmrg The extension attribute selects events from the given extension. 379a27842ffSmrg 380a27842ffSmrg If the xge attribute is true, the event is an X Generic Event and 381a27842ffSmrg will be treated as such. 382a27842ffSmrg 383a27842ffSmrg opcode-min and opcode-max describe the minimum and maximum opcode 384a27842ffSmrg respectively. The opcode is the same number as the number-attribute 385a27842ffSmrg of an event definition. I.e. this is the offset from the event-base 386a27842ffSmrg to the actual number used on the wire. 387a27842ffSmrg 388a27842ffSmrg In the current implementation, only xge="false" is supported. 389a27842ffSmrg 390a27842ffSmrg 391986c8b3dSmrgDocumentation 392986c8b3dSmrg------------- 393986c8b3dSmrg 394986c8b3dSmrg Documentation for each request, reply or event is stored in the appropriate 395986c8b3dSmrg element using a <doc> element. The <doc> element can contain the following 396986c8b3dSmrg elements: 397986c8b3dSmrg 398986c8b3dSmrg<brief>brief description</brief> 399986c8b3dSmrg 400986c8b3dSmrg A short description of the request, reply or event. For example "makes a 401986c8b3dSmrg window visible" for MapWindow. This will end up in the manpage NAME section 402986c8b3dSmrg and in the doxygen @brief description. 403986c8b3dSmrg 404986c8b3dSmrg<description><![CDATA[longer description]]></description> 405986c8b3dSmrg 406986c8b3dSmrg The full description. Use `` to highlight words, such as "Draws 407986c8b3dSmrg `points_len`-1 lines between each pair of points…" 408986c8b3dSmrg 409986c8b3dSmrg<example><![CDATA[example code]]</description> 410986c8b3dSmrg 411986c8b3dSmrg Example C code illustrating the usage of the particular request, reply or 412986c8b3dSmrg event. 413986c8b3dSmrg 414986c8b3dSmrg<field name="name">field description</field> 415986c8b3dSmrg 416986c8b3dSmrg The full description for the specified field. Depending on the context, this 417986c8b3dSmrg is either a request parameter or a reply/event datastructure field. 418986c8b3dSmrg 419986c8b3dSmrg<error type="type">error description</field> 420986c8b3dSmrg 421986c8b3dSmrg The full description for an error which can occur due to this request. 422986c8b3dSmrg 423986c8b3dSmrg<see type="request" name="name" /> 424986c8b3dSmrg 425986c8b3dSmrg A reference to another relevant program, function, request or event. 426