github.com/BurntSushi/xgb@v0.0.0-20210121224620-deaf085860bc/res/res.go (about)

     1  // Package res is the X client API for the X-Resource extension.
     2  package res
     3  
     4  // This file is automatically generated from res.xml. Edit at your peril!
     5  
     6  import (
     7  	"github.com/BurntSushi/xgb"
     8  
     9  	"github.com/BurntSushi/xgb/xproto"
    10  )
    11  
    12  // Init must be called before using the X-Resource extension.
    13  func Init(c *xgb.Conn) error {
    14  	reply, err := xproto.QueryExtension(c, 10, "X-Resource").Reply()
    15  	switch {
    16  	case err != nil:
    17  		return err
    18  	case !reply.Present:
    19  		return xgb.Errorf("No extension named X-Resource could be found on on the server.")
    20  	}
    21  
    22  	c.ExtLock.Lock()
    23  	c.Extensions["X-Resource"] = reply.MajorOpcode
    24  	c.ExtLock.Unlock()
    25  	for evNum, fun := range xgb.NewExtEventFuncs["X-Resource"] {
    26  		xgb.NewEventFuncs[int(reply.FirstEvent)+evNum] = fun
    27  	}
    28  	for errNum, fun := range xgb.NewExtErrorFuncs["X-Resource"] {
    29  		xgb.NewErrorFuncs[int(reply.FirstError)+errNum] = fun
    30  	}
    31  	return nil
    32  }
    33  
    34  func init() {
    35  	xgb.NewExtEventFuncs["X-Resource"] = make(map[int]xgb.NewEventFun)
    36  	xgb.NewExtErrorFuncs["X-Resource"] = make(map[int]xgb.NewErrorFun)
    37  }
    38  
    39  type Client struct {
    40  	ResourceBase uint32
    41  	ResourceMask uint32
    42  }
    43  
    44  // ClientRead reads a byte slice into a Client value.
    45  func ClientRead(buf []byte, v *Client) int {
    46  	b := 0
    47  
    48  	v.ResourceBase = xgb.Get32(buf[b:])
    49  	b += 4
    50  
    51  	v.ResourceMask = xgb.Get32(buf[b:])
    52  	b += 4
    53  
    54  	return b
    55  }
    56  
    57  // ClientReadList reads a byte slice into a list of Client values.
    58  func ClientReadList(buf []byte, dest []Client) int {
    59  	b := 0
    60  	for i := 0; i < len(dest); i++ {
    61  		dest[i] = Client{}
    62  		b += ClientRead(buf[b:], &dest[i])
    63  	}
    64  	return xgb.Pad(b)
    65  }
    66  
    67  // Bytes writes a Client value to a byte slice.
    68  func (v Client) Bytes() []byte {
    69  	buf := make([]byte, 8)
    70  	b := 0
    71  
    72  	xgb.Put32(buf[b:], v.ResourceBase)
    73  	b += 4
    74  
    75  	xgb.Put32(buf[b:], v.ResourceMask)
    76  	b += 4
    77  
    78  	return buf[:b]
    79  }
    80  
    81  // ClientListBytes writes a list of Client values to a byte slice.
    82  func ClientListBytes(buf []byte, list []Client) int {
    83  	b := 0
    84  	var structBytes []byte
    85  	for _, item := range list {
    86  		structBytes = item.Bytes()
    87  		copy(buf[b:], structBytes)
    88  		b += len(structBytes)
    89  	}
    90  	return xgb.Pad(b)
    91  }
    92  
    93  const (
    94  	ClientIdMaskClientXID      = 1
    95  	ClientIdMaskLocalClientPID = 2
    96  )
    97  
    98  type ClientIdSpec struct {
    99  	Client uint32
   100  	Mask   uint32
   101  }
   102  
   103  // ClientIdSpecRead reads a byte slice into a ClientIdSpec value.
   104  func ClientIdSpecRead(buf []byte, v *ClientIdSpec) int {
   105  	b := 0
   106  
   107  	v.Client = xgb.Get32(buf[b:])
   108  	b += 4
   109  
   110  	v.Mask = xgb.Get32(buf[b:])
   111  	b += 4
   112  
   113  	return b
   114  }
   115  
   116  // ClientIdSpecReadList reads a byte slice into a list of ClientIdSpec values.
   117  func ClientIdSpecReadList(buf []byte, dest []ClientIdSpec) int {
   118  	b := 0
   119  	for i := 0; i < len(dest); i++ {
   120  		dest[i] = ClientIdSpec{}
   121  		b += ClientIdSpecRead(buf[b:], &dest[i])
   122  	}
   123  	return xgb.Pad(b)
   124  }
   125  
   126  // Bytes writes a ClientIdSpec value to a byte slice.
   127  func (v ClientIdSpec) Bytes() []byte {
   128  	buf := make([]byte, 8)
   129  	b := 0
   130  
   131  	xgb.Put32(buf[b:], v.Client)
   132  	b += 4
   133  
   134  	xgb.Put32(buf[b:], v.Mask)
   135  	b += 4
   136  
   137  	return buf[:b]
   138  }
   139  
   140  // ClientIdSpecListBytes writes a list of ClientIdSpec values to a byte slice.
   141  func ClientIdSpecListBytes(buf []byte, list []ClientIdSpec) int {
   142  	b := 0
   143  	var structBytes []byte
   144  	for _, item := range list {
   145  		structBytes = item.Bytes()
   146  		copy(buf[b:], structBytes)
   147  		b += len(structBytes)
   148  	}
   149  	return xgb.Pad(b)
   150  }
   151  
   152  type ClientIdValue struct {
   153  	Spec   ClientIdSpec
   154  	Length uint32
   155  	Value  []uint32 // size: xgb.Pad((int(Length) * 4))
   156  }
   157  
   158  // ClientIdValueRead reads a byte slice into a ClientIdValue value.
   159  func ClientIdValueRead(buf []byte, v *ClientIdValue) int {
   160  	b := 0
   161  
   162  	v.Spec = ClientIdSpec{}
   163  	b += ClientIdSpecRead(buf[b:], &v.Spec)
   164  
   165  	v.Length = xgb.Get32(buf[b:])
   166  	b += 4
   167  
   168  	v.Value = make([]uint32, v.Length)
   169  	for i := 0; i < int(v.Length); i++ {
   170  		v.Value[i] = xgb.Get32(buf[b:])
   171  		b += 4
   172  	}
   173  
   174  	return b
   175  }
   176  
   177  // ClientIdValueReadList reads a byte slice into a list of ClientIdValue values.
   178  func ClientIdValueReadList(buf []byte, dest []ClientIdValue) int {
   179  	b := 0
   180  	for i := 0; i < len(dest); i++ {
   181  		dest[i] = ClientIdValue{}
   182  		b += ClientIdValueRead(buf[b:], &dest[i])
   183  	}
   184  	return xgb.Pad(b)
   185  }
   186  
   187  // Bytes writes a ClientIdValue value to a byte slice.
   188  func (v ClientIdValue) Bytes() []byte {
   189  	buf := make([]byte, (12 + xgb.Pad((int(v.Length) * 4))))
   190  	b := 0
   191  
   192  	{
   193  		structBytes := v.Spec.Bytes()
   194  		copy(buf[b:], structBytes)
   195  		b += len(structBytes)
   196  	}
   197  
   198  	xgb.Put32(buf[b:], v.Length)
   199  	b += 4
   200  
   201  	for i := 0; i < int(v.Length); i++ {
   202  		xgb.Put32(buf[b:], v.Value[i])
   203  		b += 4
   204  	}
   205  
   206  	return buf[:b]
   207  }
   208  
   209  // ClientIdValueListBytes writes a list of ClientIdValue values to a byte slice.
   210  func ClientIdValueListBytes(buf []byte, list []ClientIdValue) int {
   211  	b := 0
   212  	var structBytes []byte
   213  	for _, item := range list {
   214  		structBytes = item.Bytes()
   215  		copy(buf[b:], structBytes)
   216  		b += len(structBytes)
   217  	}
   218  	return xgb.Pad(b)
   219  }
   220  
   221  // ClientIdValueListSize computes the size (bytes) of a list of ClientIdValue values.
   222  func ClientIdValueListSize(list []ClientIdValue) int {
   223  	size := 0
   224  	for _, item := range list {
   225  		size += (12 + xgb.Pad((int(item.Length) * 4)))
   226  	}
   227  	return size
   228  }
   229  
   230  type ResourceIdSpec struct {
   231  	Resource uint32
   232  	Type     uint32
   233  }
   234  
   235  // ResourceIdSpecRead reads a byte slice into a ResourceIdSpec value.
   236  func ResourceIdSpecRead(buf []byte, v *ResourceIdSpec) int {
   237  	b := 0
   238  
   239  	v.Resource = xgb.Get32(buf[b:])
   240  	b += 4
   241  
   242  	v.Type = xgb.Get32(buf[b:])
   243  	b += 4
   244  
   245  	return b
   246  }
   247  
   248  // ResourceIdSpecReadList reads a byte slice into a list of ResourceIdSpec values.
   249  func ResourceIdSpecReadList(buf []byte, dest []ResourceIdSpec) int {
   250  	b := 0
   251  	for i := 0; i < len(dest); i++ {
   252  		dest[i] = ResourceIdSpec{}
   253  		b += ResourceIdSpecRead(buf[b:], &dest[i])
   254  	}
   255  	return xgb.Pad(b)
   256  }
   257  
   258  // Bytes writes a ResourceIdSpec value to a byte slice.
   259  func (v ResourceIdSpec) Bytes() []byte {
   260  	buf := make([]byte, 8)
   261  	b := 0
   262  
   263  	xgb.Put32(buf[b:], v.Resource)
   264  	b += 4
   265  
   266  	xgb.Put32(buf[b:], v.Type)
   267  	b += 4
   268  
   269  	return buf[:b]
   270  }
   271  
   272  // ResourceIdSpecListBytes writes a list of ResourceIdSpec values to a byte slice.
   273  func ResourceIdSpecListBytes(buf []byte, list []ResourceIdSpec) int {
   274  	b := 0
   275  	var structBytes []byte
   276  	for _, item := range list {
   277  		structBytes = item.Bytes()
   278  		copy(buf[b:], structBytes)
   279  		b += len(structBytes)
   280  	}
   281  	return xgb.Pad(b)
   282  }
   283  
   284  type ResourceSizeSpec struct {
   285  	Spec     ResourceIdSpec
   286  	Bytes_   uint32
   287  	RefCount uint32
   288  	UseCount uint32
   289  }
   290  
   291  // ResourceSizeSpecRead reads a byte slice into a ResourceSizeSpec value.
   292  func ResourceSizeSpecRead(buf []byte, v *ResourceSizeSpec) int {
   293  	b := 0
   294  
   295  	v.Spec = ResourceIdSpec{}
   296  	b += ResourceIdSpecRead(buf[b:], &v.Spec)
   297  
   298  	v.Bytes_ = xgb.Get32(buf[b:])
   299  	b += 4
   300  
   301  	v.RefCount = xgb.Get32(buf[b:])
   302  	b += 4
   303  
   304  	v.UseCount = xgb.Get32(buf[b:])
   305  	b += 4
   306  
   307  	return b
   308  }
   309  
   310  // ResourceSizeSpecReadList reads a byte slice into a list of ResourceSizeSpec values.
   311  func ResourceSizeSpecReadList(buf []byte, dest []ResourceSizeSpec) int {
   312  	b := 0
   313  	for i := 0; i < len(dest); i++ {
   314  		dest[i] = ResourceSizeSpec{}
   315  		b += ResourceSizeSpecRead(buf[b:], &dest[i])
   316  	}
   317  	return xgb.Pad(b)
   318  }
   319  
   320  // Bytes writes a ResourceSizeSpec value to a byte slice.
   321  func (v ResourceSizeSpec) Bytes() []byte {
   322  	buf := make([]byte, 20)
   323  	b := 0
   324  
   325  	{
   326  		structBytes := v.Spec.Bytes()
   327  		copy(buf[b:], structBytes)
   328  		b += len(structBytes)
   329  	}
   330  
   331  	xgb.Put32(buf[b:], v.Bytes_)
   332  	b += 4
   333  
   334  	xgb.Put32(buf[b:], v.RefCount)
   335  	b += 4
   336  
   337  	xgb.Put32(buf[b:], v.UseCount)
   338  	b += 4
   339  
   340  	return buf[:b]
   341  }
   342  
   343  // ResourceSizeSpecListBytes writes a list of ResourceSizeSpec values to a byte slice.
   344  func ResourceSizeSpecListBytes(buf []byte, list []ResourceSizeSpec) int {
   345  	b := 0
   346  	var structBytes []byte
   347  	for _, item := range list {
   348  		structBytes = item.Bytes()
   349  		copy(buf[b:], structBytes)
   350  		b += len(structBytes)
   351  	}
   352  	return xgb.Pad(b)
   353  }
   354  
   355  type ResourceSizeValue struct {
   356  	Size               ResourceSizeSpec
   357  	NumCrossReferences uint32
   358  	CrossReferences    []ResourceSizeSpec // size: xgb.Pad((int(NumCrossReferences) * 20))
   359  }
   360  
   361  // ResourceSizeValueRead reads a byte slice into a ResourceSizeValue value.
   362  func ResourceSizeValueRead(buf []byte, v *ResourceSizeValue) int {
   363  	b := 0
   364  
   365  	v.Size = ResourceSizeSpec{}
   366  	b += ResourceSizeSpecRead(buf[b:], &v.Size)
   367  
   368  	v.NumCrossReferences = xgb.Get32(buf[b:])
   369  	b += 4
   370  
   371  	v.CrossReferences = make([]ResourceSizeSpec, v.NumCrossReferences)
   372  	b += ResourceSizeSpecReadList(buf[b:], v.CrossReferences)
   373  
   374  	return b
   375  }
   376  
   377  // ResourceSizeValueReadList reads a byte slice into a list of ResourceSizeValue values.
   378  func ResourceSizeValueReadList(buf []byte, dest []ResourceSizeValue) int {
   379  	b := 0
   380  	for i := 0; i < len(dest); i++ {
   381  		dest[i] = ResourceSizeValue{}
   382  		b += ResourceSizeValueRead(buf[b:], &dest[i])
   383  	}
   384  	return xgb.Pad(b)
   385  }
   386  
   387  // Bytes writes a ResourceSizeValue value to a byte slice.
   388  func (v ResourceSizeValue) Bytes() []byte {
   389  	buf := make([]byte, (24 + xgb.Pad((int(v.NumCrossReferences) * 20))))
   390  	b := 0
   391  
   392  	{
   393  		structBytes := v.Size.Bytes()
   394  		copy(buf[b:], structBytes)
   395  		b += len(structBytes)
   396  	}
   397  
   398  	xgb.Put32(buf[b:], v.NumCrossReferences)
   399  	b += 4
   400  
   401  	b += ResourceSizeSpecListBytes(buf[b:], v.CrossReferences)
   402  
   403  	return buf[:b]
   404  }
   405  
   406  // ResourceSizeValueListBytes writes a list of ResourceSizeValue values to a byte slice.
   407  func ResourceSizeValueListBytes(buf []byte, list []ResourceSizeValue) int {
   408  	b := 0
   409  	var structBytes []byte
   410  	for _, item := range list {
   411  		structBytes = item.Bytes()
   412  		copy(buf[b:], structBytes)
   413  		b += len(structBytes)
   414  	}
   415  	return xgb.Pad(b)
   416  }
   417  
   418  // ResourceSizeValueListSize computes the size (bytes) of a list of ResourceSizeValue values.
   419  func ResourceSizeValueListSize(list []ResourceSizeValue) int {
   420  	size := 0
   421  	for _, item := range list {
   422  		size += (24 + xgb.Pad((int(item.NumCrossReferences) * 20)))
   423  	}
   424  	return size
   425  }
   426  
   427  type Type struct {
   428  	ResourceType xproto.Atom
   429  	Count        uint32
   430  }
   431  
   432  // TypeRead reads a byte slice into a Type value.
   433  func TypeRead(buf []byte, v *Type) int {
   434  	b := 0
   435  
   436  	v.ResourceType = xproto.Atom(xgb.Get32(buf[b:]))
   437  	b += 4
   438  
   439  	v.Count = xgb.Get32(buf[b:])
   440  	b += 4
   441  
   442  	return b
   443  }
   444  
   445  // TypeReadList reads a byte slice into a list of Type values.
   446  func TypeReadList(buf []byte, dest []Type) int {
   447  	b := 0
   448  	for i := 0; i < len(dest); i++ {
   449  		dest[i] = Type{}
   450  		b += TypeRead(buf[b:], &dest[i])
   451  	}
   452  	return xgb.Pad(b)
   453  }
   454  
   455  // Bytes writes a Type value to a byte slice.
   456  func (v Type) Bytes() []byte {
   457  	buf := make([]byte, 8)
   458  	b := 0
   459  
   460  	xgb.Put32(buf[b:], uint32(v.ResourceType))
   461  	b += 4
   462  
   463  	xgb.Put32(buf[b:], v.Count)
   464  	b += 4
   465  
   466  	return buf[:b]
   467  }
   468  
   469  // TypeListBytes writes a list of Type values to a byte slice.
   470  func TypeListBytes(buf []byte, list []Type) int {
   471  	b := 0
   472  	var structBytes []byte
   473  	for _, item := range list {
   474  		structBytes = item.Bytes()
   475  		copy(buf[b:], structBytes)
   476  		b += len(structBytes)
   477  	}
   478  	return xgb.Pad(b)
   479  }
   480  
   481  // Skipping definition for base type 'Bool'
   482  
   483  // Skipping definition for base type 'Byte'
   484  
   485  // Skipping definition for base type 'Card8'
   486  
   487  // Skipping definition for base type 'Char'
   488  
   489  // Skipping definition for base type 'Void'
   490  
   491  // Skipping definition for base type 'Double'
   492  
   493  // Skipping definition for base type 'Float'
   494  
   495  // Skipping definition for base type 'Int16'
   496  
   497  // Skipping definition for base type 'Int32'
   498  
   499  // Skipping definition for base type 'Int8'
   500  
   501  // Skipping definition for base type 'Card16'
   502  
   503  // Skipping definition for base type 'Card32'
   504  
   505  // QueryClientIdsCookie is a cookie used only for QueryClientIds requests.
   506  type QueryClientIdsCookie struct {
   507  	*xgb.Cookie
   508  }
   509  
   510  // QueryClientIds sends a checked request.
   511  // If an error occurs, it will be returned with the reply by calling QueryClientIdsCookie.Reply()
   512  func QueryClientIds(c *xgb.Conn, NumSpecs uint32, Specs []ClientIdSpec) QueryClientIdsCookie {
   513  	c.ExtLock.RLock()
   514  	defer c.ExtLock.RUnlock()
   515  	if _, ok := c.Extensions["X-Resource"]; !ok {
   516  		panic("Cannot issue request 'QueryClientIds' using the uninitialized extension 'X-Resource'. res.Init(connObj) must be called first.")
   517  	}
   518  	cookie := c.NewCookie(true, true)
   519  	c.NewRequest(queryClientIdsRequest(c, NumSpecs, Specs), cookie)
   520  	return QueryClientIdsCookie{cookie}
   521  }
   522  
   523  // QueryClientIdsUnchecked sends an unchecked request.
   524  // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
   525  func QueryClientIdsUnchecked(c *xgb.Conn, NumSpecs uint32, Specs []ClientIdSpec) QueryClientIdsCookie {
   526  	c.ExtLock.RLock()
   527  	defer c.ExtLock.RUnlock()
   528  	if _, ok := c.Extensions["X-Resource"]; !ok {
   529  		panic("Cannot issue request 'QueryClientIds' using the uninitialized extension 'X-Resource'. res.Init(connObj) must be called first.")
   530  	}
   531  	cookie := c.NewCookie(false, true)
   532  	c.NewRequest(queryClientIdsRequest(c, NumSpecs, Specs), cookie)
   533  	return QueryClientIdsCookie{cookie}
   534  }
   535  
   536  // QueryClientIdsReply represents the data returned from a QueryClientIds request.
   537  type QueryClientIdsReply struct {
   538  	Sequence uint16 // sequence number of the request for this reply
   539  	Length   uint32 // number of bytes in this reply
   540  	// padding: 1 bytes
   541  	NumIds uint32
   542  	// padding: 20 bytes
   543  	Ids []ClientIdValue // size: ClientIdValueListSize(Ids)
   544  }
   545  
   546  // Reply blocks and returns the reply data for a QueryClientIds request.
   547  func (cook QueryClientIdsCookie) Reply() (*QueryClientIdsReply, error) {
   548  	buf, err := cook.Cookie.Reply()
   549  	if err != nil {
   550  		return nil, err
   551  	}
   552  	if buf == nil {
   553  		return nil, nil
   554  	}
   555  	return queryClientIdsReply(buf), nil
   556  }
   557  
   558  // queryClientIdsReply reads a byte slice into a QueryClientIdsReply value.
   559  func queryClientIdsReply(buf []byte) *QueryClientIdsReply {
   560  	v := new(QueryClientIdsReply)
   561  	b := 1 // skip reply determinant
   562  
   563  	b += 1 // padding
   564  
   565  	v.Sequence = xgb.Get16(buf[b:])
   566  	b += 2
   567  
   568  	v.Length = xgb.Get32(buf[b:]) // 4-byte units
   569  	b += 4
   570  
   571  	v.NumIds = xgb.Get32(buf[b:])
   572  	b += 4
   573  
   574  	b += 20 // padding
   575  
   576  	v.Ids = make([]ClientIdValue, v.NumIds)
   577  	b += ClientIdValueReadList(buf[b:], v.Ids)
   578  
   579  	return v
   580  }
   581  
   582  // Write request to wire for QueryClientIds
   583  // queryClientIdsRequest writes a QueryClientIds request to a byte slice.
   584  func queryClientIdsRequest(c *xgb.Conn, NumSpecs uint32, Specs []ClientIdSpec) []byte {
   585  	size := xgb.Pad((8 + xgb.Pad((int(NumSpecs) * 8))))
   586  	b := 0
   587  	buf := make([]byte, size)
   588  
   589  	c.ExtLock.RLock()
   590  	buf[b] = c.Extensions["X-Resource"]
   591  	c.ExtLock.RUnlock()
   592  	b += 1
   593  
   594  	buf[b] = 4 // request opcode
   595  	b += 1
   596  
   597  	xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
   598  	b += 2
   599  
   600  	xgb.Put32(buf[b:], NumSpecs)
   601  	b += 4
   602  
   603  	b += ClientIdSpecListBytes(buf[b:], Specs)
   604  
   605  	return buf
   606  }
   607  
   608  // QueryClientPixmapBytesCookie is a cookie used only for QueryClientPixmapBytes requests.
   609  type QueryClientPixmapBytesCookie struct {
   610  	*xgb.Cookie
   611  }
   612  
   613  // QueryClientPixmapBytes sends a checked request.
   614  // If an error occurs, it will be returned with the reply by calling QueryClientPixmapBytesCookie.Reply()
   615  func QueryClientPixmapBytes(c *xgb.Conn, Xid uint32) QueryClientPixmapBytesCookie {
   616  	c.ExtLock.RLock()
   617  	defer c.ExtLock.RUnlock()
   618  	if _, ok := c.Extensions["X-Resource"]; !ok {
   619  		panic("Cannot issue request 'QueryClientPixmapBytes' using the uninitialized extension 'X-Resource'. res.Init(connObj) must be called first.")
   620  	}
   621  	cookie := c.NewCookie(true, true)
   622  	c.NewRequest(queryClientPixmapBytesRequest(c, Xid), cookie)
   623  	return QueryClientPixmapBytesCookie{cookie}
   624  }
   625  
   626  // QueryClientPixmapBytesUnchecked sends an unchecked request.
   627  // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
   628  func QueryClientPixmapBytesUnchecked(c *xgb.Conn, Xid uint32) QueryClientPixmapBytesCookie {
   629  	c.ExtLock.RLock()
   630  	defer c.ExtLock.RUnlock()
   631  	if _, ok := c.Extensions["X-Resource"]; !ok {
   632  		panic("Cannot issue request 'QueryClientPixmapBytes' using the uninitialized extension 'X-Resource'. res.Init(connObj) must be called first.")
   633  	}
   634  	cookie := c.NewCookie(false, true)
   635  	c.NewRequest(queryClientPixmapBytesRequest(c, Xid), cookie)
   636  	return QueryClientPixmapBytesCookie{cookie}
   637  }
   638  
   639  // QueryClientPixmapBytesReply represents the data returned from a QueryClientPixmapBytes request.
   640  type QueryClientPixmapBytesReply struct {
   641  	Sequence uint16 // sequence number of the request for this reply
   642  	Length   uint32 // number of bytes in this reply
   643  	// padding: 1 bytes
   644  	Bytes_        uint32
   645  	BytesOverflow uint32
   646  }
   647  
   648  // Reply blocks and returns the reply data for a QueryClientPixmapBytes request.
   649  func (cook QueryClientPixmapBytesCookie) Reply() (*QueryClientPixmapBytesReply, error) {
   650  	buf, err := cook.Cookie.Reply()
   651  	if err != nil {
   652  		return nil, err
   653  	}
   654  	if buf == nil {
   655  		return nil, nil
   656  	}
   657  	return queryClientPixmapBytesReply(buf), nil
   658  }
   659  
   660  // queryClientPixmapBytesReply reads a byte slice into a QueryClientPixmapBytesReply value.
   661  func queryClientPixmapBytesReply(buf []byte) *QueryClientPixmapBytesReply {
   662  	v := new(QueryClientPixmapBytesReply)
   663  	b := 1 // skip reply determinant
   664  
   665  	b += 1 // padding
   666  
   667  	v.Sequence = xgb.Get16(buf[b:])
   668  	b += 2
   669  
   670  	v.Length = xgb.Get32(buf[b:]) // 4-byte units
   671  	b += 4
   672  
   673  	v.Bytes_ = xgb.Get32(buf[b:])
   674  	b += 4
   675  
   676  	v.BytesOverflow = xgb.Get32(buf[b:])
   677  	b += 4
   678  
   679  	return v
   680  }
   681  
   682  // Write request to wire for QueryClientPixmapBytes
   683  // queryClientPixmapBytesRequest writes a QueryClientPixmapBytes request to a byte slice.
   684  func queryClientPixmapBytesRequest(c *xgb.Conn, Xid uint32) []byte {
   685  	size := 8
   686  	b := 0
   687  	buf := make([]byte, size)
   688  
   689  	c.ExtLock.RLock()
   690  	buf[b] = c.Extensions["X-Resource"]
   691  	c.ExtLock.RUnlock()
   692  	b += 1
   693  
   694  	buf[b] = 3 // request opcode
   695  	b += 1
   696  
   697  	xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
   698  	b += 2
   699  
   700  	xgb.Put32(buf[b:], Xid)
   701  	b += 4
   702  
   703  	return buf
   704  }
   705  
   706  // QueryClientResourcesCookie is a cookie used only for QueryClientResources requests.
   707  type QueryClientResourcesCookie struct {
   708  	*xgb.Cookie
   709  }
   710  
   711  // QueryClientResources sends a checked request.
   712  // If an error occurs, it will be returned with the reply by calling QueryClientResourcesCookie.Reply()
   713  func QueryClientResources(c *xgb.Conn, Xid uint32) QueryClientResourcesCookie {
   714  	c.ExtLock.RLock()
   715  	defer c.ExtLock.RUnlock()
   716  	if _, ok := c.Extensions["X-Resource"]; !ok {
   717  		panic("Cannot issue request 'QueryClientResources' using the uninitialized extension 'X-Resource'. res.Init(connObj) must be called first.")
   718  	}
   719  	cookie := c.NewCookie(true, true)
   720  	c.NewRequest(queryClientResourcesRequest(c, Xid), cookie)
   721  	return QueryClientResourcesCookie{cookie}
   722  }
   723  
   724  // QueryClientResourcesUnchecked sends an unchecked request.
   725  // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
   726  func QueryClientResourcesUnchecked(c *xgb.Conn, Xid uint32) QueryClientResourcesCookie {
   727  	c.ExtLock.RLock()
   728  	defer c.ExtLock.RUnlock()
   729  	if _, ok := c.Extensions["X-Resource"]; !ok {
   730  		panic("Cannot issue request 'QueryClientResources' using the uninitialized extension 'X-Resource'. res.Init(connObj) must be called first.")
   731  	}
   732  	cookie := c.NewCookie(false, true)
   733  	c.NewRequest(queryClientResourcesRequest(c, Xid), cookie)
   734  	return QueryClientResourcesCookie{cookie}
   735  }
   736  
   737  // QueryClientResourcesReply represents the data returned from a QueryClientResources request.
   738  type QueryClientResourcesReply struct {
   739  	Sequence uint16 // sequence number of the request for this reply
   740  	Length   uint32 // number of bytes in this reply
   741  	// padding: 1 bytes
   742  	NumTypes uint32
   743  	// padding: 20 bytes
   744  	Types []Type // size: xgb.Pad((int(NumTypes) * 8))
   745  }
   746  
   747  // Reply blocks and returns the reply data for a QueryClientResources request.
   748  func (cook QueryClientResourcesCookie) Reply() (*QueryClientResourcesReply, error) {
   749  	buf, err := cook.Cookie.Reply()
   750  	if err != nil {
   751  		return nil, err
   752  	}
   753  	if buf == nil {
   754  		return nil, nil
   755  	}
   756  	return queryClientResourcesReply(buf), nil
   757  }
   758  
   759  // queryClientResourcesReply reads a byte slice into a QueryClientResourcesReply value.
   760  func queryClientResourcesReply(buf []byte) *QueryClientResourcesReply {
   761  	v := new(QueryClientResourcesReply)
   762  	b := 1 // skip reply determinant
   763  
   764  	b += 1 // padding
   765  
   766  	v.Sequence = xgb.Get16(buf[b:])
   767  	b += 2
   768  
   769  	v.Length = xgb.Get32(buf[b:]) // 4-byte units
   770  	b += 4
   771  
   772  	v.NumTypes = xgb.Get32(buf[b:])
   773  	b += 4
   774  
   775  	b += 20 // padding
   776  
   777  	v.Types = make([]Type, v.NumTypes)
   778  	b += TypeReadList(buf[b:], v.Types)
   779  
   780  	return v
   781  }
   782  
   783  // Write request to wire for QueryClientResources
   784  // queryClientResourcesRequest writes a QueryClientResources request to a byte slice.
   785  func queryClientResourcesRequest(c *xgb.Conn, Xid uint32) []byte {
   786  	size := 8
   787  	b := 0
   788  	buf := make([]byte, size)
   789  
   790  	c.ExtLock.RLock()
   791  	buf[b] = c.Extensions["X-Resource"]
   792  	c.ExtLock.RUnlock()
   793  	b += 1
   794  
   795  	buf[b] = 2 // request opcode
   796  	b += 1
   797  
   798  	xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
   799  	b += 2
   800  
   801  	xgb.Put32(buf[b:], Xid)
   802  	b += 4
   803  
   804  	return buf
   805  }
   806  
   807  // QueryClientsCookie is a cookie used only for QueryClients requests.
   808  type QueryClientsCookie struct {
   809  	*xgb.Cookie
   810  }
   811  
   812  // QueryClients sends a checked request.
   813  // If an error occurs, it will be returned with the reply by calling QueryClientsCookie.Reply()
   814  func QueryClients(c *xgb.Conn) QueryClientsCookie {
   815  	c.ExtLock.RLock()
   816  	defer c.ExtLock.RUnlock()
   817  	if _, ok := c.Extensions["X-Resource"]; !ok {
   818  		panic("Cannot issue request 'QueryClients' using the uninitialized extension 'X-Resource'. res.Init(connObj) must be called first.")
   819  	}
   820  	cookie := c.NewCookie(true, true)
   821  	c.NewRequest(queryClientsRequest(c), cookie)
   822  	return QueryClientsCookie{cookie}
   823  }
   824  
   825  // QueryClientsUnchecked sends an unchecked request.
   826  // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
   827  func QueryClientsUnchecked(c *xgb.Conn) QueryClientsCookie {
   828  	c.ExtLock.RLock()
   829  	defer c.ExtLock.RUnlock()
   830  	if _, ok := c.Extensions["X-Resource"]; !ok {
   831  		panic("Cannot issue request 'QueryClients' using the uninitialized extension 'X-Resource'. res.Init(connObj) must be called first.")
   832  	}
   833  	cookie := c.NewCookie(false, true)
   834  	c.NewRequest(queryClientsRequest(c), cookie)
   835  	return QueryClientsCookie{cookie}
   836  }
   837  
   838  // QueryClientsReply represents the data returned from a QueryClients request.
   839  type QueryClientsReply struct {
   840  	Sequence uint16 // sequence number of the request for this reply
   841  	Length   uint32 // number of bytes in this reply
   842  	// padding: 1 bytes
   843  	NumClients uint32
   844  	// padding: 20 bytes
   845  	Clients []Client // size: xgb.Pad((int(NumClients) * 8))
   846  }
   847  
   848  // Reply blocks and returns the reply data for a QueryClients request.
   849  func (cook QueryClientsCookie) Reply() (*QueryClientsReply, error) {
   850  	buf, err := cook.Cookie.Reply()
   851  	if err != nil {
   852  		return nil, err
   853  	}
   854  	if buf == nil {
   855  		return nil, nil
   856  	}
   857  	return queryClientsReply(buf), nil
   858  }
   859  
   860  // queryClientsReply reads a byte slice into a QueryClientsReply value.
   861  func queryClientsReply(buf []byte) *QueryClientsReply {
   862  	v := new(QueryClientsReply)
   863  	b := 1 // skip reply determinant
   864  
   865  	b += 1 // padding
   866  
   867  	v.Sequence = xgb.Get16(buf[b:])
   868  	b += 2
   869  
   870  	v.Length = xgb.Get32(buf[b:]) // 4-byte units
   871  	b += 4
   872  
   873  	v.NumClients = xgb.Get32(buf[b:])
   874  	b += 4
   875  
   876  	b += 20 // padding
   877  
   878  	v.Clients = make([]Client, v.NumClients)
   879  	b += ClientReadList(buf[b:], v.Clients)
   880  
   881  	return v
   882  }
   883  
   884  // Write request to wire for QueryClients
   885  // queryClientsRequest writes a QueryClients request to a byte slice.
   886  func queryClientsRequest(c *xgb.Conn) []byte {
   887  	size := 4
   888  	b := 0
   889  	buf := make([]byte, size)
   890  
   891  	c.ExtLock.RLock()
   892  	buf[b] = c.Extensions["X-Resource"]
   893  	c.ExtLock.RUnlock()
   894  	b += 1
   895  
   896  	buf[b] = 1 // request opcode
   897  	b += 1
   898  
   899  	xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
   900  	b += 2
   901  
   902  	return buf
   903  }
   904  
   905  // QueryResourceBytesCookie is a cookie used only for QueryResourceBytes requests.
   906  type QueryResourceBytesCookie struct {
   907  	*xgb.Cookie
   908  }
   909  
   910  // QueryResourceBytes sends a checked request.
   911  // If an error occurs, it will be returned with the reply by calling QueryResourceBytesCookie.Reply()
   912  func QueryResourceBytes(c *xgb.Conn, Client uint32, NumSpecs uint32, Specs []ResourceIdSpec) QueryResourceBytesCookie {
   913  	c.ExtLock.RLock()
   914  	defer c.ExtLock.RUnlock()
   915  	if _, ok := c.Extensions["X-Resource"]; !ok {
   916  		panic("Cannot issue request 'QueryResourceBytes' using the uninitialized extension 'X-Resource'. res.Init(connObj) must be called first.")
   917  	}
   918  	cookie := c.NewCookie(true, true)
   919  	c.NewRequest(queryResourceBytesRequest(c, Client, NumSpecs, Specs), cookie)
   920  	return QueryResourceBytesCookie{cookie}
   921  }
   922  
   923  // QueryResourceBytesUnchecked sends an unchecked request.
   924  // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
   925  func QueryResourceBytesUnchecked(c *xgb.Conn, Client uint32, NumSpecs uint32, Specs []ResourceIdSpec) QueryResourceBytesCookie {
   926  	c.ExtLock.RLock()
   927  	defer c.ExtLock.RUnlock()
   928  	if _, ok := c.Extensions["X-Resource"]; !ok {
   929  		panic("Cannot issue request 'QueryResourceBytes' using the uninitialized extension 'X-Resource'. res.Init(connObj) must be called first.")
   930  	}
   931  	cookie := c.NewCookie(false, true)
   932  	c.NewRequest(queryResourceBytesRequest(c, Client, NumSpecs, Specs), cookie)
   933  	return QueryResourceBytesCookie{cookie}
   934  }
   935  
   936  // QueryResourceBytesReply represents the data returned from a QueryResourceBytes request.
   937  type QueryResourceBytesReply struct {
   938  	Sequence uint16 // sequence number of the request for this reply
   939  	Length   uint32 // number of bytes in this reply
   940  	// padding: 1 bytes
   941  	NumSizes uint32
   942  	// padding: 20 bytes
   943  	Sizes []ResourceSizeValue // size: ResourceSizeValueListSize(Sizes)
   944  }
   945  
   946  // Reply blocks and returns the reply data for a QueryResourceBytes request.
   947  func (cook QueryResourceBytesCookie) Reply() (*QueryResourceBytesReply, error) {
   948  	buf, err := cook.Cookie.Reply()
   949  	if err != nil {
   950  		return nil, err
   951  	}
   952  	if buf == nil {
   953  		return nil, nil
   954  	}
   955  	return queryResourceBytesReply(buf), nil
   956  }
   957  
   958  // queryResourceBytesReply reads a byte slice into a QueryResourceBytesReply value.
   959  func queryResourceBytesReply(buf []byte) *QueryResourceBytesReply {
   960  	v := new(QueryResourceBytesReply)
   961  	b := 1 // skip reply determinant
   962  
   963  	b += 1 // padding
   964  
   965  	v.Sequence = xgb.Get16(buf[b:])
   966  	b += 2
   967  
   968  	v.Length = xgb.Get32(buf[b:]) // 4-byte units
   969  	b += 4
   970  
   971  	v.NumSizes = xgb.Get32(buf[b:])
   972  	b += 4
   973  
   974  	b += 20 // padding
   975  
   976  	v.Sizes = make([]ResourceSizeValue, v.NumSizes)
   977  	b += ResourceSizeValueReadList(buf[b:], v.Sizes)
   978  
   979  	return v
   980  }
   981  
   982  // Write request to wire for QueryResourceBytes
   983  // queryResourceBytesRequest writes a QueryResourceBytes request to a byte slice.
   984  func queryResourceBytesRequest(c *xgb.Conn, Client uint32, NumSpecs uint32, Specs []ResourceIdSpec) []byte {
   985  	size := xgb.Pad((12 + xgb.Pad((int(NumSpecs) * 8))))
   986  	b := 0
   987  	buf := make([]byte, size)
   988  
   989  	c.ExtLock.RLock()
   990  	buf[b] = c.Extensions["X-Resource"]
   991  	c.ExtLock.RUnlock()
   992  	b += 1
   993  
   994  	buf[b] = 5 // request opcode
   995  	b += 1
   996  
   997  	xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
   998  	b += 2
   999  
  1000  	xgb.Put32(buf[b:], Client)
  1001  	b += 4
  1002  
  1003  	xgb.Put32(buf[b:], NumSpecs)
  1004  	b += 4
  1005  
  1006  	b += ResourceIdSpecListBytes(buf[b:], Specs)
  1007  
  1008  	return buf
  1009  }
  1010  
  1011  // QueryVersionCookie is a cookie used only for QueryVersion requests.
  1012  type QueryVersionCookie struct {
  1013  	*xgb.Cookie
  1014  }
  1015  
  1016  // QueryVersion sends a checked request.
  1017  // If an error occurs, it will be returned with the reply by calling QueryVersionCookie.Reply()
  1018  func QueryVersion(c *xgb.Conn, ClientMajor byte, ClientMinor byte) QueryVersionCookie {
  1019  	c.ExtLock.RLock()
  1020  	defer c.ExtLock.RUnlock()
  1021  	if _, ok := c.Extensions["X-Resource"]; !ok {
  1022  		panic("Cannot issue request 'QueryVersion' using the uninitialized extension 'X-Resource'. res.Init(connObj) must be called first.")
  1023  	}
  1024  	cookie := c.NewCookie(true, true)
  1025  	c.NewRequest(queryVersionRequest(c, ClientMajor, ClientMinor), cookie)
  1026  	return QueryVersionCookie{cookie}
  1027  }
  1028  
  1029  // QueryVersionUnchecked sends an unchecked request.
  1030  // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
  1031  func QueryVersionUnchecked(c *xgb.Conn, ClientMajor byte, ClientMinor byte) QueryVersionCookie {
  1032  	c.ExtLock.RLock()
  1033  	defer c.ExtLock.RUnlock()
  1034  	if _, ok := c.Extensions["X-Resource"]; !ok {
  1035  		panic("Cannot issue request 'QueryVersion' using the uninitialized extension 'X-Resource'. res.Init(connObj) must be called first.")
  1036  	}
  1037  	cookie := c.NewCookie(false, true)
  1038  	c.NewRequest(queryVersionRequest(c, ClientMajor, ClientMinor), cookie)
  1039  	return QueryVersionCookie{cookie}
  1040  }
  1041  
  1042  // QueryVersionReply represents the data returned from a QueryVersion request.
  1043  type QueryVersionReply struct {
  1044  	Sequence uint16 // sequence number of the request for this reply
  1045  	Length   uint32 // number of bytes in this reply
  1046  	// padding: 1 bytes
  1047  	ServerMajor uint16
  1048  	ServerMinor uint16
  1049  }
  1050  
  1051  // Reply blocks and returns the reply data for a QueryVersion request.
  1052  func (cook QueryVersionCookie) Reply() (*QueryVersionReply, error) {
  1053  	buf, err := cook.Cookie.Reply()
  1054  	if err != nil {
  1055  		return nil, err
  1056  	}
  1057  	if buf == nil {
  1058  		return nil, nil
  1059  	}
  1060  	return queryVersionReply(buf), nil
  1061  }
  1062  
  1063  // queryVersionReply reads a byte slice into a QueryVersionReply value.
  1064  func queryVersionReply(buf []byte) *QueryVersionReply {
  1065  	v := new(QueryVersionReply)
  1066  	b := 1 // skip reply determinant
  1067  
  1068  	b += 1 // padding
  1069  
  1070  	v.Sequence = xgb.Get16(buf[b:])
  1071  	b += 2
  1072  
  1073  	v.Length = xgb.Get32(buf[b:]) // 4-byte units
  1074  	b += 4
  1075  
  1076  	v.ServerMajor = xgb.Get16(buf[b:])
  1077  	b += 2
  1078  
  1079  	v.ServerMinor = xgb.Get16(buf[b:])
  1080  	b += 2
  1081  
  1082  	return v
  1083  }
  1084  
  1085  // Write request to wire for QueryVersion
  1086  // queryVersionRequest writes a QueryVersion request to a byte slice.
  1087  func queryVersionRequest(c *xgb.Conn, ClientMajor byte, ClientMinor byte) []byte {
  1088  	size := 8
  1089  	b := 0
  1090  	buf := make([]byte, size)
  1091  
  1092  	c.ExtLock.RLock()
  1093  	buf[b] = c.Extensions["X-Resource"]
  1094  	c.ExtLock.RUnlock()
  1095  	b += 1
  1096  
  1097  	buf[b] = 0 // request opcode
  1098  	b += 1
  1099  
  1100  	xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
  1101  	b += 2
  1102  
  1103  	buf[b] = ClientMajor
  1104  	b += 1
  1105  
  1106  	buf[b] = ClientMinor
  1107  	b += 1
  1108  
  1109  	return buf
  1110  }