xml-xcb.txt revision 986c8b3d
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 131d4401354Smrg<event name="identifier" number="integer" [no-sequence-number="true"]> 132d4401354Smrg structure contents 133d4401354Smrg</event> 134d4401354Smrg 135d4401354Smrg This element represents an X protocol event. The name attribute gives the 136d4401354Smrg name of the event, and the number attribute gives the event number. The 137d4401354Smrg content of the event element represents the fields in the event, and 138d4401354Smrg consists of zero or more of the field, pad, and list elements listed in the 139d4401354Smrg "Structure Contents" section below. 140d4401354Smrg 141d4401354Smrg If the optional no-sequence-number attribute is true, the event does not 142d4401354Smrg include a sequence number. This is a special-case for the KeymapNotify 143d4401354Smrg event in the core protocol, and should not be used in any other event. 144d4401354Smrg 145d4401354Smrg<error name="identifier" number="integer"> 146d4401354Smrg structure contents 147d4401354Smrg</error> 148d4401354Smrg 149d4401354Smrg This element represents an X protocol error. The name attribute gives the 150d4401354Smrg name of the error, and the number attribute gives the error number. The 151d4401354Smrg content of the error element represents the fields in the error, and 152d4401354Smrg consists of zero or more of the field, pad, and list elements listed in the 153d4401354Smrg "Structure Contents" section below. 154d4401354Smrg 155d4401354Smrg<eventcopy name="identifier" number="identifier" ref="identifier" /> 156d4401354Smrg 157d4401354Smrg This element creates an alias for the event named in the ref attribute, with 158d4401354Smrg the new name given in the name attribute, and the new event number given in 159d4401354Smrg the number attribute. 160d4401354Smrg 161d4401354Smrg<errorcopy name="identifier" number="identifier" ref="identifier" /> 162d4401354Smrg 163d4401354Smrg This element creates an alias for the error named in the ref attribute, with 164d4401354Smrg the new name given in the name attribute, and the new error number given in 165d4401354Smrg the number attribute. 166d4401354Smrg 167d4401354Smrg 168d4401354SmrgStructure Contents 169d4401354Smrg------------------ 170d4401354Smrg 171d4401354SmrgNote: "type" attributes below refer to types defined by previous elements, 172d4401354Smrgeither in the current extension, xproto, or one of the imported extensions. 173d4401354SmrgThe type name must refer to only one possible type; if more than one type 174d4401354Smrgmatches, an error occurs. To avoid this, the type may be explicitly prefixed 175d4401354Smrgwith a namespace, which should be the value of the header attribute on the 176d4401354Smrgprotocol description containing the desired type. The namespace and type are 177d4401354Smrgseparated by a single colon. For example, to refer to the PIXMAP type defined 178d4401354Smrgin glx rather than the one defined in xproto, use type="glx:PIXMAP" rather 179d4401354Smrgthan type="PIXMAP". 180d4401354Smrg 181d4401354SmrgNote: Most of the below may optionally contain an enum, altenum, or mask 182d4401354Smrgattribute, which follows the above rules for "type". "enum" is an exhaustive 183d4401354Smrgenum; the value is restricted to one of the constants named in the enum. 184d4401354Smrg"altenum" may be one of the values contained in the enum, but it need not be. 185d4401354Smrg"mask" refers to an enum to be used as a bitmask. 186d4401354Smrg 187d4401354Smrg<pad bytes="integer" /> 188d4401354Smrg 189d4401354Smrg This element declares some padding in a data structure. The bytes 190d4401354Smrg attribute declares the number of bytes of padding. 191d4401354Smrg 192d4401354Smrg<field type="identifier" name="identifier" /> 193d4401354Smrg 194d4401354Smrg This element represents a field in a data structure. The type attribute 195d4401354Smrg declares the data type of the field, and the name attribute gives the name 196d4401354Smrg of the field. 197d4401354Smrg 198d4401354Smrg<list type="identifier" name="identifier">expression</list> 199d4401354Smrg 200d4401354Smrg This element represents an array or list of fields in a data structure. The 201d4401354Smrg type attribute declares the data type of the field, and the name attribute 202d4401354Smrg gives the name of the field. The content is an expression giving the length 203d4401354Smrg of the list in terms of other fields in the structure. See the section 204d4401354Smrg "Expressions" for details on the expression representation. 205d4401354Smrg 206d4401354Smrg<localfield type="identifier" name="identifier" /> 207d4401354Smrg 208d4401354Smrg This element represents a parameter in a request that is not sent over the 209d4401354Smrg wire. The field can be referenced in the length expressions of lists or in 210d4401354Smrg an exprfield. The type attribute declares the data type of the field, and 211d4401354Smrg the name attribute gives the name of the field. 212d4401354Smrg 213d4401354Smrg<exprfield type="identifier" name="identifier">expression</exprfield> 214d4401354Smrg 215d4401354Smrg This element represents a field in a request that is calculated rather than 216d4401354Smrg supplied by the caller. The type attribute declares the data type of the 217d4401354Smrg field, and the name attribute gives the name of the field. The content is 218d4401354Smrg the expression giving the value of the field. See the section "Expressions" 219d4401354Smrg for details on the expression representation. 220d4401354Smrg 221d4401354Smrg<valueparam value-mask-type="identifier" value-mask-name="identifier" 222d4401354Smrg value-list-name="identifier" /> 223d4401354Smrg 224d4401354Smrg This element represents a BITMASK/LISTofVALUE parameter pair: a bitmask 225d4401354Smrg defining the set of values included, and a list containing these values. 226d4401354Smrg value-mask-type gives the type of the bitmask; this must be CARD16 or 227d4401354Smrg CARD32. value-mask-name gives the field name of the bitmask, and 228986c8b3dSmrg value-list-name gives the field name of the list of values. Please use 229986c8b3dSmrg <switch> instead for new protocol definitions. 230d4401354Smrg 231986c8b3dSmrg<switch name="identifier"> switch expression 232986c8b3dSmrg <bitcase> bitcase expression, fields </bitcase> </switch> 233986c8b3dSmrg 234986c8b3dSmrg This element represents conditional inclusion of fields. It can be viewed 235986c8b3dSmrg as sequence of multiple ifs: if ( switch expression & bitcase expression ) 236986c8b3dSmrg is equal to bitcase expression, bitcase fields are included in structure. 237986c8b3dSmrg It can be used only as the last field of structure. New protocol definitions 238986c8b3dSmrg should prefer to use this instead of <valueparam>. 239d4401354Smrg 240d4401354SmrgExpressions 241d4401354Smrg----------- 242d4401354Smrg 243d4401354Smrg Expressions consist of a tree of <op> elements with leaves consisting of 244d4401354Smrg <fieldref> or <value> elements. 245d4401354Smrg 246d4401354Smrg<op op="operator">expression expression</op> 247d4401354Smrg 248d4401354Smrg The op element represents an operator, with the op attribute specifying 249d4401354Smrg which operator. The supported operations are +, -, *, /, &, and 250d4401354Smrg <<, and their semantics are identical to the corresponding operators 251d4401354Smrg in C. The two operand expressions may be other expression elements. 252d4401354Smrg 253d4401354Smrg<fieldref>identifier</fieldref> 254d4401354Smrg 255d4401354Smrg The fieldref element represents a reference to the value of another field in 256d4401354Smrg the structure containing this expression. The identifier is the value of 257d4401354Smrg the "name" attribute on the referenced field. 258d4401354Smrg 259d4401354Smrg<value>integer</value> 260d4401354Smrg 261d4401354Smrg The value element represents a literal integer value in an expression. The 262d4401354Smrg integer may be expressed in decimal or hexadecimal. 263d4401354Smrg 264d4401354Smrg<bit>integer</bit> 265d4401354Smrg 266d4401354Smrg The bit element represents a literal bitmask value in an expression. 267d4401354Smrg The integer must be in the range 0..31, expanding to (1<<n) in C. 268986c8b3dSmrg 269986c8b3dSmrg<enumref ref="identifier">enum item identifier</enumref> 270986c8b3dSmrg 271986c8b3dSmrg This element represents a reference to item of enum. 272986c8b3dSmrg 273986c8b3dSmrg<unop op="operator">expression</unop> 274986c8b3dSmrg 275986c8b3dSmrg This element represents a unary operator, with the op attribute specifying 276986c8b3dSmrg which operator. The only supported operation so far is ~, and its semantic 277986c8b3dSmrg is identical to the corresponding operator in C. 278986c8b3dSmrg 279986c8b3dSmrg<sumof ref="identifier" /> 280986c8b3dSmrg 281986c8b3dSmrg This element represents a sumation of the elements of the referenced list. 282986c8b3dSmrg 283986c8b3dSmrg<popcount>expression</popcount> 284986c8b3dSmrg 285986c8b3dSmrg This element represents the number of bits set in the expression. 286986c8b3dSmrg 287986c8b3dSmrgDocumentation 288986c8b3dSmrg------------- 289986c8b3dSmrg 290986c8b3dSmrg Documentation for each request, reply or event is stored in the appropriate 291986c8b3dSmrg element using a <doc> element. The <doc> element can contain the following 292986c8b3dSmrg elements: 293986c8b3dSmrg 294986c8b3dSmrg<brief>brief description</brief> 295986c8b3dSmrg 296986c8b3dSmrg A short description of the request, reply or event. For example "makes a 297986c8b3dSmrg window visible" for MapWindow. This will end up in the manpage NAME section 298986c8b3dSmrg and in the doxygen @brief description. 299986c8b3dSmrg 300986c8b3dSmrg<description><![CDATA[longer description]]></description> 301986c8b3dSmrg 302986c8b3dSmrg The full description. Use `` to highlight words, such as "Draws 303986c8b3dSmrg `points_len`-1 lines between each pair of points…" 304986c8b3dSmrg 305986c8b3dSmrg<example><![CDATA[example code]]</description> 306986c8b3dSmrg 307986c8b3dSmrg Example C code illustrating the usage of the particular request, reply or 308986c8b3dSmrg event. 309986c8b3dSmrg 310986c8b3dSmrg<field name="name">field description</field> 311986c8b3dSmrg 312986c8b3dSmrg The full description for the specified field. Depending on the context, this 313986c8b3dSmrg is either a request parameter or a reply/event datastructure field. 314986c8b3dSmrg 315986c8b3dSmrg<error type="type">error description</field> 316986c8b3dSmrg 317986c8b3dSmrg The full description for an error which can occur due to this request. 318986c8b3dSmrg 319986c8b3dSmrg<see type="request" name="name" /> 320986c8b3dSmrg 321986c8b3dSmrg A reference to another relevant program, function, request or event. 322