xml-xcb.txt revision d5c9b07b
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 68d5c9b07bSmrg consists of one or more of the length, field, pad, and list elements described 69d5c9b07bSmrg in 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 218d5c9b07bSmrg<length>expression</length> 219d5c9b07bSmrg This element overrides the length of the data structure by specifying it 220d5c9b07bSmrg explicitly instead of it being defined by the layout of the structure. 221d5c9b07bSmrg This makes it possible to handle structures with conditional fields 222d5c9b07bSmrg (see the <switch> element) where the future revisions of protocols may 223d5c9b07bSmrg introduce new variants and old code must still properly ignore them. 224d5c9b07bSmrg 225d5c9b07bSmrg The content is an expression giving the length of the data structure in terms 226d5c9b07bSmrg of other fields in the structure. See the section "Expressions" for details 227d5c9b07bSmrg on the expression representation. 228d5c9b07bSmrg 229d5c9b07bSmrg The expression must not depend on conditional fields. 230d5c9b07bSmrg 231d5c9b07bSmrg Additionally, the length of the data structure must be at least such that it 232d5c9b07bSmrg includes the fields that the expression depends on. Smaller length is 233d5c9b07bSmrg considered a violation of the protocol. 234d5c9b07bSmrg 235b26960f7Smrg<fd name="identifier" /> 236b26960f7Smrg 237b26960f7Smrg This element represents a file descriptor field passed with the request. The 238b26960f7Smrg name attribute gives the name of the field. 239b26960f7Smrg 240b26960f7Smrg While ordinary fields are encoded as part of the request, file descriptor 241b26960f7Smrg fields are generally passed via an out-of-band mechanism. 242b26960f7Smrg 243d4401354Smrg<list type="identifier" name="identifier">expression</list> 244d4401354Smrg 245d4401354Smrg This element represents an array or list of fields in a data structure. The 246d4401354Smrg type attribute declares the data type of the field, and the name attribute 247d4401354Smrg gives the name of the field. The content is an expression giving the length 248d4401354Smrg of the list in terms of other fields in the structure. See the section 249d4401354Smrg "Expressions" for details on the expression representation. 250d4401354Smrg 251d4401354Smrg<exprfield type="identifier" name="identifier">expression</exprfield> 252d4401354Smrg 253d4401354Smrg This element represents a field in a request that is calculated rather than 254d4401354Smrg supplied by the caller. The type attribute declares the data type of the 255d4401354Smrg field, and the name attribute gives the name of the field. The content is 256d4401354Smrg the expression giving the value of the field. See the section "Expressions" 257d4401354Smrg for details on the expression representation. 258d4401354Smrg 259d4401354Smrg<valueparam value-mask-type="identifier" value-mask-name="identifier" 260d4401354Smrg value-list-name="identifier" /> 261d4401354Smrg 262d4401354Smrg This element represents a BITMASK/LISTofVALUE parameter pair: a bitmask 263d4401354Smrg defining the set of values included, and a list containing these values. 264d4401354Smrg value-mask-type gives the type of the bitmask; this must be CARD16 or 265d4401354Smrg CARD32. value-mask-name gives the field name of the bitmask, and 266986c8b3dSmrg value-list-name gives the field name of the list of values. Please use 267986c8b3dSmrg <switch> instead for new protocol definitions. 268d4401354Smrg 269986c8b3dSmrg<switch name="identifier"> switch expression 270891601f5Smrg <bitcase [name="identifier"]> bitcase expression(s), fields </bitcase> 271891601f5Smrg <case [name="identifier"]> case expression(s), fields </case> 272891601f5Smrg</switch> 273986c8b3dSmrg 274986c8b3dSmrg This element represents conditional inclusion of fields. It can be viewed 275891601f5Smrg as sequence of multiple ifs: 276891601f5Smrg 277891601f5Smrg <bitcase>: 278891601f5Smrg if ( switch expression & bitcase expression ) is non-zero, 279891601f5Smrg bitcase fields are included in structure. 280891601f5Smrg 281891601f5Smrg <case>: 282891601f5Smrg if ( switch expression == case expression ) is true, 283891601f5Smrg then case fields are included in structure. 284891601f5Smrg 285891601f5Smrg It can be used only as the last field of a structure. 286891601f5Smrg 287891601f5Smrg When a bitcase or case includes multiple <enumref> clauses, the contents 288891601f5Smrg of the bitcase or case are only present once regardless of the number of 289891601f5Smrg bitcase or case expressions that match. 290891601f5Smrg 291891601f5Smrg <enumref> inside <bitcase> can only refer to an enum's <bit> members. 292891601f5Smrg <enumref> inside <case> can only refer to an enum's <value> members. 293891601f5Smrg 294891601f5Smrg A switch may contain multiple <bitcase> or <case> elements. 295891601f5Smrg Usually it will only contain <bitcase> elements 296891601f5Smrg or only contain <case> elements. 297891601f5Smrg That is, mixing of <case> and <bitcase> usually doesn't make any sense. 298f591e195Smrg 299891601f5Smrg The same value may appear in multiple <case> or <bitcase> elements. 300891601f5Smrg 301891601f5Smrg New protocol definitions should prefer to use this instead of <valueparam> 302891601f5Smrg and instead of <union>. 303f591e195Smrg 304d4401354Smrg 305d4401354SmrgExpressions 306d4401354Smrg----------- 307d4401354Smrg 308d4401354Smrg Expressions consist of a tree of <op> elements with leaves consisting of 309d4401354Smrg <fieldref> or <value> elements. 310d4401354Smrg 311d4401354Smrg<op op="operator">expression expression</op> 312d4401354Smrg 313d4401354Smrg The op element represents an operator, with the op attribute specifying 314d4401354Smrg which operator. The supported operations are +, -, *, /, &, and 315d4401354Smrg <<, and their semantics are identical to the corresponding operators 316d4401354Smrg in C. The two operand expressions may be other expression elements. 317d4401354Smrg 318d4401354Smrg<fieldref>identifier</fieldref> 319d4401354Smrg 320d4401354Smrg The fieldref element represents a reference to the value of another field in 321d4401354Smrg the structure containing this expression. The identifier is the value of 322d4401354Smrg the "name" attribute on the referenced field. 323d4401354Smrg 324891601f5Smrg<paramref type="type">identifier</paramref> 325891601f5Smrg 326891601f5Smrg A paramref is similar to a fieldref, but it refers to the value of 327891601f5Smrg a field in the context which refers to the struct which contains the paramref. 328891601f5Smrg 329891601f5Smrg So, it refers to a field outside of the structure where it is defined. 330891601f5Smrg This has the following consequences: 331891601f5Smrg * The generator cannot deduce its type. 332891601f5Smrg So, it is mandatory to specify its type. 333891601f5Smrg * The identifier-name must not be used as a field in the structure 334891601f5Smrg which contaons the paramref. 335891601f5Smrg 336891601f5Smrg For an example, see struct "DeviceTimeCoord" and request/reply 337891601f5Smrg "GetDeviceMotionEvents" in xinput.xml, where paramref "num_axes" 338891601f5Smrg in struct DeviceTimeCoord refers to field "num_axes" in 339891601f5Smrg the DeviceTimeCoord reply. 340891601f5Smrg 341d4401354Smrg<value>integer</value> 342d4401354Smrg 343d4401354Smrg The value element represents a literal integer value in an expression. The 344d4401354Smrg integer may be expressed in decimal or hexadecimal. 345d4401354Smrg 346d4401354Smrg<bit>integer</bit> 347d4401354Smrg 348d4401354Smrg The bit element represents a literal bitmask value in an expression. 349d4401354Smrg The integer must be in the range 0..31, expanding to (1<<n) in C. 350986c8b3dSmrg 351986c8b3dSmrg<enumref ref="identifier">enum item identifier</enumref> 352986c8b3dSmrg 353986c8b3dSmrg This element represents a reference to item of enum. 354986c8b3dSmrg 355986c8b3dSmrg<unop op="operator">expression</unop> 356986c8b3dSmrg 357986c8b3dSmrg This element represents a unary operator, with the op attribute specifying 358986c8b3dSmrg which operator. The only supported operation so far is ~, and its semantic 359986c8b3dSmrg is identical to the corresponding operator in C. 360986c8b3dSmrg 361986c8b3dSmrg<sumof ref="identifier" /> 362986c8b3dSmrg 363986c8b3dSmrg This element represents a sumation of the elements of the referenced list. 364986c8b3dSmrg 365891601f5Smrg<sumof ref="identifier" >expression</sumof> 366891601f5Smrg 367891601f5Smrg The expression is evaluated for each element of the referenced list, 368891601f5Smrg in the context of this element. 369891601f5Smrg This sumof element then represents a sumation of the results of these 370891601f5Smrg evaluations. 371891601f5Smrg 372891601f5Smrg expression will usually be a fieldref which references a field of 373891601f5Smrg a list-element or an expression containing a fieldref, 374891601f5Smrg such as popcount of a fieldref. 375891601f5Smrg 376986c8b3dSmrg<popcount>expression</popcount> 377986c8b3dSmrg 378986c8b3dSmrg This element represents the number of bits set in the expression. 379986c8b3dSmrg 380891601f5Smrg<listelement-ref/> 381891601f5Smrg 382891601f5Smrg This element represents the current list-element when used inside 383891601f5Smrg a list-iteration expression such as <sumof>. 384891601f5Smrg 385a27842ffSmrg 386a27842ffSmrgEvent-Type-Selector List 387a27842ffSmrg------------------------ 388a27842ffSmrg 389a27842ffSmrg The event-type-selector list selects a set of eventtypes. 390a27842ffSmrg It consists of any number of the following elements: 391a27842ffSmrg 392a27842ffSmrg <allowed extension="identifier" xge="boolean" 393a27842ffSmrg opcode-min="integer" opcode-max="integer" /> 394a27842ffSmrg 395a27842ffSmrg The extension attribute selects events from the given extension. 396a27842ffSmrg 397a27842ffSmrg If the xge attribute is true, the event is an X Generic Event and 398a27842ffSmrg will be treated as such. 399a27842ffSmrg 400a27842ffSmrg opcode-min and opcode-max describe the minimum and maximum opcode 401a27842ffSmrg respectively. The opcode is the same number as the number-attribute 402a27842ffSmrg of an event definition. I.e. this is the offset from the event-base 403a27842ffSmrg to the actual number used on the wire. 404a27842ffSmrg 405a27842ffSmrg In the current implementation, only xge="false" is supported. 406a27842ffSmrg 407a27842ffSmrg 408986c8b3dSmrgDocumentation 409986c8b3dSmrg------------- 410986c8b3dSmrg 411986c8b3dSmrg Documentation for each request, reply or event is stored in the appropriate 412986c8b3dSmrg element using a <doc> element. The <doc> element can contain the following 413986c8b3dSmrg elements: 414986c8b3dSmrg 415986c8b3dSmrg<brief>brief description</brief> 416986c8b3dSmrg 417986c8b3dSmrg A short description of the request, reply or event. For example "makes a 418986c8b3dSmrg window visible" for MapWindow. This will end up in the manpage NAME section 419986c8b3dSmrg and in the doxygen @brief description. 420986c8b3dSmrg 421986c8b3dSmrg<description><![CDATA[longer description]]></description> 422986c8b3dSmrg 423986c8b3dSmrg The full description. Use `` to highlight words, such as "Draws 424986c8b3dSmrg `points_len`-1 lines between each pair of points…" 425986c8b3dSmrg 426986c8b3dSmrg<example><![CDATA[example code]]</description> 427986c8b3dSmrg 428986c8b3dSmrg Example C code illustrating the usage of the particular request, reply or 429986c8b3dSmrg event. 430986c8b3dSmrg 431986c8b3dSmrg<field name="name">field description</field> 432986c8b3dSmrg 433986c8b3dSmrg The full description for the specified field. Depending on the context, this 434986c8b3dSmrg is either a request parameter or a reply/event datastructure field. 435986c8b3dSmrg 436986c8b3dSmrg<error type="type">error description</field> 437986c8b3dSmrg 438986c8b3dSmrg The full description for an error which can occur due to this request. 439986c8b3dSmrg 440986c8b3dSmrg<see type="request" name="name" /> 441986c8b3dSmrg 442986c8b3dSmrg A reference to another relevant program, function, request or event. 443