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

     1  // Package xfixes is the X client API for the XFIXES extension.
     2  package xfixes
     3  
     4  // This file is automatically generated from xfixes.xml. Edit at your peril!
     5  
     6  import (
     7  	"github.com/BurntSushi/xgb"
     8  
     9  	"github.com/BurntSushi/xgb/render"
    10  	"github.com/BurntSushi/xgb/shape"
    11  	"github.com/BurntSushi/xgb/xproto"
    12  )
    13  
    14  // Init must be called before using the XFIXES extension.
    15  func Init(c *xgb.Conn) error {
    16  	reply, err := xproto.QueryExtension(c, 6, "XFIXES").Reply()
    17  	switch {
    18  	case err != nil:
    19  		return err
    20  	case !reply.Present:
    21  		return xgb.Errorf("No extension named XFIXES could be found on on the server.")
    22  	}
    23  
    24  	c.ExtLock.Lock()
    25  	c.Extensions["XFIXES"] = reply.MajorOpcode
    26  	c.ExtLock.Unlock()
    27  	for evNum, fun := range xgb.NewExtEventFuncs["XFIXES"] {
    28  		xgb.NewEventFuncs[int(reply.FirstEvent)+evNum] = fun
    29  	}
    30  	for errNum, fun := range xgb.NewExtErrorFuncs["XFIXES"] {
    31  		xgb.NewErrorFuncs[int(reply.FirstError)+errNum] = fun
    32  	}
    33  	return nil
    34  }
    35  
    36  func init() {
    37  	xgb.NewExtEventFuncs["XFIXES"] = make(map[int]xgb.NewEventFun)
    38  	xgb.NewExtErrorFuncs["XFIXES"] = make(map[int]xgb.NewErrorFun)
    39  }
    40  
    41  // BadBadRegion is the error number for a BadBadRegion.
    42  const BadBadRegion = 0
    43  
    44  type BadRegionError struct {
    45  	Sequence uint16
    46  	NiceName string
    47  }
    48  
    49  // BadRegionErrorNew constructs a BadRegionError value that implements xgb.Error from a byte slice.
    50  func BadRegionErrorNew(buf []byte) xgb.Error {
    51  	v := BadRegionError{}
    52  	v.NiceName = "BadRegion"
    53  
    54  	b := 1 // skip error determinant
    55  	b += 1 // don't read error number
    56  
    57  	v.Sequence = xgb.Get16(buf[b:])
    58  	b += 2
    59  
    60  	return v
    61  }
    62  
    63  // SequenceId returns the sequence id attached to the BadBadRegion error.
    64  // This is mostly used internally.
    65  func (err BadRegionError) SequenceId() uint16 {
    66  	return err.Sequence
    67  }
    68  
    69  // BadId returns the 'BadValue' number if one exists for the BadBadRegion error. If no bad value exists, 0 is returned.
    70  func (err BadRegionError) BadId() uint32 {
    71  	return 0
    72  }
    73  
    74  // Error returns a rudimentary string representation of the BadBadRegion error.
    75  
    76  func (err BadRegionError) Error() string {
    77  	fieldVals := make([]string, 0, 0)
    78  	fieldVals = append(fieldVals, "NiceName: "+err.NiceName)
    79  	fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence))
    80  	return "BadBadRegion {" + xgb.StringsJoin(fieldVals, ", ") + "}"
    81  }
    82  
    83  func init() {
    84  	xgb.NewExtErrorFuncs["XFIXES"][0] = BadRegionErrorNew
    85  }
    86  
    87  type Barrier uint32
    88  
    89  func NewBarrierId(c *xgb.Conn) (Barrier, error) {
    90  	id, err := c.NewId()
    91  	if err != nil {
    92  		return 0, err
    93  	}
    94  	return Barrier(id), nil
    95  }
    96  
    97  const (
    98  	BarrierDirectionsPositiveX = 1
    99  	BarrierDirectionsPositiveY = 2
   100  	BarrierDirectionsNegativeX = 4
   101  	BarrierDirectionsNegativeY = 8
   102  )
   103  
   104  // CursorNotify is the event number for a CursorNotifyEvent.
   105  const CursorNotify = 1
   106  
   107  type CursorNotifyEvent struct {
   108  	Sequence     uint16
   109  	Subtype      byte
   110  	Window       xproto.Window
   111  	CursorSerial uint32
   112  	Timestamp    xproto.Timestamp
   113  	Name         xproto.Atom
   114  	// padding: 12 bytes
   115  }
   116  
   117  // CursorNotifyEventNew constructs a CursorNotifyEvent value that implements xgb.Event from a byte slice.
   118  func CursorNotifyEventNew(buf []byte) xgb.Event {
   119  	v := CursorNotifyEvent{}
   120  	b := 1 // don't read event number
   121  
   122  	v.Subtype = buf[b]
   123  	b += 1
   124  
   125  	v.Sequence = xgb.Get16(buf[b:])
   126  	b += 2
   127  
   128  	v.Window = xproto.Window(xgb.Get32(buf[b:]))
   129  	b += 4
   130  
   131  	v.CursorSerial = xgb.Get32(buf[b:])
   132  	b += 4
   133  
   134  	v.Timestamp = xproto.Timestamp(xgb.Get32(buf[b:]))
   135  	b += 4
   136  
   137  	v.Name = xproto.Atom(xgb.Get32(buf[b:]))
   138  	b += 4
   139  
   140  	b += 12 // padding
   141  
   142  	return v
   143  }
   144  
   145  // Bytes writes a CursorNotifyEvent value to a byte slice.
   146  func (v CursorNotifyEvent) Bytes() []byte {
   147  	buf := make([]byte, 32)
   148  	b := 0
   149  
   150  	// write event number
   151  	buf[b] = 1
   152  	b += 1
   153  
   154  	buf[b] = v.Subtype
   155  	b += 1
   156  
   157  	b += 2 // skip sequence number
   158  
   159  	xgb.Put32(buf[b:], uint32(v.Window))
   160  	b += 4
   161  
   162  	xgb.Put32(buf[b:], v.CursorSerial)
   163  	b += 4
   164  
   165  	xgb.Put32(buf[b:], uint32(v.Timestamp))
   166  	b += 4
   167  
   168  	xgb.Put32(buf[b:], uint32(v.Name))
   169  	b += 4
   170  
   171  	b += 12 // padding
   172  
   173  	return buf
   174  }
   175  
   176  // SequenceId returns the sequence id attached to the CursorNotify event.
   177  // Events without a sequence number (KeymapNotify) return 0.
   178  // This is mostly used internally.
   179  func (v CursorNotifyEvent) SequenceId() uint16 {
   180  	return v.Sequence
   181  }
   182  
   183  // String is a rudimentary string representation of CursorNotifyEvent.
   184  func (v CursorNotifyEvent) String() string {
   185  	fieldVals := make([]string, 0, 6)
   186  	fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence))
   187  	fieldVals = append(fieldVals, xgb.Sprintf("Subtype: %d", v.Subtype))
   188  	fieldVals = append(fieldVals, xgb.Sprintf("Window: %d", v.Window))
   189  	fieldVals = append(fieldVals, xgb.Sprintf("CursorSerial: %d", v.CursorSerial))
   190  	fieldVals = append(fieldVals, xgb.Sprintf("Timestamp: %d", v.Timestamp))
   191  	fieldVals = append(fieldVals, xgb.Sprintf("Name: %d", v.Name))
   192  	return "CursorNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}"
   193  }
   194  
   195  func init() {
   196  	xgb.NewExtEventFuncs["XFIXES"][1] = CursorNotifyEventNew
   197  }
   198  
   199  const (
   200  	CursorNotifyDisplayCursor = 0
   201  )
   202  
   203  const (
   204  	CursorNotifyMaskDisplayCursor = 1
   205  )
   206  
   207  type Region uint32
   208  
   209  func NewRegionId(c *xgb.Conn) (Region, error) {
   210  	id, err := c.NewId()
   211  	if err != nil {
   212  		return 0, err
   213  	}
   214  	return Region(id), nil
   215  }
   216  
   217  const (
   218  	RegionNone = 0
   219  )
   220  
   221  const (
   222  	SaveSetMappingMap   = 0
   223  	SaveSetMappingUnmap = 1
   224  )
   225  
   226  const (
   227  	SaveSetModeInsert = 0
   228  	SaveSetModeDelete = 1
   229  )
   230  
   231  const (
   232  	SaveSetTargetNearest = 0
   233  	SaveSetTargetRoot    = 1
   234  )
   235  
   236  const (
   237  	SelectionEventSetSelectionOwner      = 0
   238  	SelectionEventSelectionWindowDestroy = 1
   239  	SelectionEventSelectionClientClose   = 2
   240  )
   241  
   242  const (
   243  	SelectionEventMaskSetSelectionOwner      = 1
   244  	SelectionEventMaskSelectionWindowDestroy = 2
   245  	SelectionEventMaskSelectionClientClose   = 4
   246  )
   247  
   248  // SelectionNotify is the event number for a SelectionNotifyEvent.
   249  const SelectionNotify = 0
   250  
   251  type SelectionNotifyEvent struct {
   252  	Sequence           uint16
   253  	Subtype            byte
   254  	Window             xproto.Window
   255  	Owner              xproto.Window
   256  	Selection          xproto.Atom
   257  	Timestamp          xproto.Timestamp
   258  	SelectionTimestamp xproto.Timestamp
   259  	// padding: 8 bytes
   260  }
   261  
   262  // SelectionNotifyEventNew constructs a SelectionNotifyEvent value that implements xgb.Event from a byte slice.
   263  func SelectionNotifyEventNew(buf []byte) xgb.Event {
   264  	v := SelectionNotifyEvent{}
   265  	b := 1 // don't read event number
   266  
   267  	v.Subtype = buf[b]
   268  	b += 1
   269  
   270  	v.Sequence = xgb.Get16(buf[b:])
   271  	b += 2
   272  
   273  	v.Window = xproto.Window(xgb.Get32(buf[b:]))
   274  	b += 4
   275  
   276  	v.Owner = xproto.Window(xgb.Get32(buf[b:]))
   277  	b += 4
   278  
   279  	v.Selection = xproto.Atom(xgb.Get32(buf[b:]))
   280  	b += 4
   281  
   282  	v.Timestamp = xproto.Timestamp(xgb.Get32(buf[b:]))
   283  	b += 4
   284  
   285  	v.SelectionTimestamp = xproto.Timestamp(xgb.Get32(buf[b:]))
   286  	b += 4
   287  
   288  	b += 8 // padding
   289  
   290  	return v
   291  }
   292  
   293  // Bytes writes a SelectionNotifyEvent value to a byte slice.
   294  func (v SelectionNotifyEvent) Bytes() []byte {
   295  	buf := make([]byte, 32)
   296  	b := 0
   297  
   298  	// write event number
   299  	buf[b] = 0
   300  	b += 1
   301  
   302  	buf[b] = v.Subtype
   303  	b += 1
   304  
   305  	b += 2 // skip sequence number
   306  
   307  	xgb.Put32(buf[b:], uint32(v.Window))
   308  	b += 4
   309  
   310  	xgb.Put32(buf[b:], uint32(v.Owner))
   311  	b += 4
   312  
   313  	xgb.Put32(buf[b:], uint32(v.Selection))
   314  	b += 4
   315  
   316  	xgb.Put32(buf[b:], uint32(v.Timestamp))
   317  	b += 4
   318  
   319  	xgb.Put32(buf[b:], uint32(v.SelectionTimestamp))
   320  	b += 4
   321  
   322  	b += 8 // padding
   323  
   324  	return buf
   325  }
   326  
   327  // SequenceId returns the sequence id attached to the SelectionNotify event.
   328  // Events without a sequence number (KeymapNotify) return 0.
   329  // This is mostly used internally.
   330  func (v SelectionNotifyEvent) SequenceId() uint16 {
   331  	return v.Sequence
   332  }
   333  
   334  // String is a rudimentary string representation of SelectionNotifyEvent.
   335  func (v SelectionNotifyEvent) String() string {
   336  	fieldVals := make([]string, 0, 7)
   337  	fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence))
   338  	fieldVals = append(fieldVals, xgb.Sprintf("Subtype: %d", v.Subtype))
   339  	fieldVals = append(fieldVals, xgb.Sprintf("Window: %d", v.Window))
   340  	fieldVals = append(fieldVals, xgb.Sprintf("Owner: %d", v.Owner))
   341  	fieldVals = append(fieldVals, xgb.Sprintf("Selection: %d", v.Selection))
   342  	fieldVals = append(fieldVals, xgb.Sprintf("Timestamp: %d", v.Timestamp))
   343  	fieldVals = append(fieldVals, xgb.Sprintf("SelectionTimestamp: %d", v.SelectionTimestamp))
   344  	return "SelectionNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}"
   345  }
   346  
   347  func init() {
   348  	xgb.NewExtEventFuncs["XFIXES"][0] = SelectionNotifyEventNew
   349  }
   350  
   351  // Skipping definition for base type 'Bool'
   352  
   353  // Skipping definition for base type 'Byte'
   354  
   355  // Skipping definition for base type 'Card8'
   356  
   357  // Skipping definition for base type 'Char'
   358  
   359  // Skipping definition for base type 'Void'
   360  
   361  // Skipping definition for base type 'Double'
   362  
   363  // Skipping definition for base type 'Float'
   364  
   365  // Skipping definition for base type 'Int16'
   366  
   367  // Skipping definition for base type 'Int32'
   368  
   369  // Skipping definition for base type 'Int8'
   370  
   371  // Skipping definition for base type 'Card16'
   372  
   373  // Skipping definition for base type 'Card32'
   374  
   375  // ChangeCursorCookie is a cookie used only for ChangeCursor requests.
   376  type ChangeCursorCookie struct {
   377  	*xgb.Cookie
   378  }
   379  
   380  // ChangeCursor sends an unchecked request.
   381  // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
   382  func ChangeCursor(c *xgb.Conn, Source xproto.Cursor, Destination xproto.Cursor) ChangeCursorCookie {
   383  	c.ExtLock.RLock()
   384  	defer c.ExtLock.RUnlock()
   385  	if _, ok := c.Extensions["XFIXES"]; !ok {
   386  		panic("Cannot issue request 'ChangeCursor' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.")
   387  	}
   388  	cookie := c.NewCookie(false, false)
   389  	c.NewRequest(changeCursorRequest(c, Source, Destination), cookie)
   390  	return ChangeCursorCookie{cookie}
   391  }
   392  
   393  // ChangeCursorChecked sends a checked request.
   394  // If an error occurs, it can be retrieved using ChangeCursorCookie.Check()
   395  func ChangeCursorChecked(c *xgb.Conn, Source xproto.Cursor, Destination xproto.Cursor) ChangeCursorCookie {
   396  	c.ExtLock.RLock()
   397  	defer c.ExtLock.RUnlock()
   398  	if _, ok := c.Extensions["XFIXES"]; !ok {
   399  		panic("Cannot issue request 'ChangeCursor' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.")
   400  	}
   401  	cookie := c.NewCookie(true, false)
   402  	c.NewRequest(changeCursorRequest(c, Source, Destination), cookie)
   403  	return ChangeCursorCookie{cookie}
   404  }
   405  
   406  // Check returns an error if one occurred for checked requests that are not expecting a reply.
   407  // This cannot be called for requests expecting a reply, nor for unchecked requests.
   408  func (cook ChangeCursorCookie) Check() error {
   409  	return cook.Cookie.Check()
   410  }
   411  
   412  // Write request to wire for ChangeCursor
   413  // changeCursorRequest writes a ChangeCursor request to a byte slice.
   414  func changeCursorRequest(c *xgb.Conn, Source xproto.Cursor, Destination xproto.Cursor) []byte {
   415  	size := 12
   416  	b := 0
   417  	buf := make([]byte, size)
   418  
   419  	c.ExtLock.RLock()
   420  	buf[b] = c.Extensions["XFIXES"]
   421  	c.ExtLock.RUnlock()
   422  	b += 1
   423  
   424  	buf[b] = 26 // request opcode
   425  	b += 1
   426  
   427  	xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
   428  	b += 2
   429  
   430  	xgb.Put32(buf[b:], uint32(Source))
   431  	b += 4
   432  
   433  	xgb.Put32(buf[b:], uint32(Destination))
   434  	b += 4
   435  
   436  	return buf
   437  }
   438  
   439  // ChangeCursorByNameCookie is a cookie used only for ChangeCursorByName requests.
   440  type ChangeCursorByNameCookie struct {
   441  	*xgb.Cookie
   442  }
   443  
   444  // ChangeCursorByName sends an unchecked request.
   445  // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
   446  func ChangeCursorByName(c *xgb.Conn, Src xproto.Cursor, Nbytes uint16, Name string) ChangeCursorByNameCookie {
   447  	c.ExtLock.RLock()
   448  	defer c.ExtLock.RUnlock()
   449  	if _, ok := c.Extensions["XFIXES"]; !ok {
   450  		panic("Cannot issue request 'ChangeCursorByName' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.")
   451  	}
   452  	cookie := c.NewCookie(false, false)
   453  	c.NewRequest(changeCursorByNameRequest(c, Src, Nbytes, Name), cookie)
   454  	return ChangeCursorByNameCookie{cookie}
   455  }
   456  
   457  // ChangeCursorByNameChecked sends a checked request.
   458  // If an error occurs, it can be retrieved using ChangeCursorByNameCookie.Check()
   459  func ChangeCursorByNameChecked(c *xgb.Conn, Src xproto.Cursor, Nbytes uint16, Name string) ChangeCursorByNameCookie {
   460  	c.ExtLock.RLock()
   461  	defer c.ExtLock.RUnlock()
   462  	if _, ok := c.Extensions["XFIXES"]; !ok {
   463  		panic("Cannot issue request 'ChangeCursorByName' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.")
   464  	}
   465  	cookie := c.NewCookie(true, false)
   466  	c.NewRequest(changeCursorByNameRequest(c, Src, Nbytes, Name), cookie)
   467  	return ChangeCursorByNameCookie{cookie}
   468  }
   469  
   470  // Check returns an error if one occurred for checked requests that are not expecting a reply.
   471  // This cannot be called for requests expecting a reply, nor for unchecked requests.
   472  func (cook ChangeCursorByNameCookie) Check() error {
   473  	return cook.Cookie.Check()
   474  }
   475  
   476  // Write request to wire for ChangeCursorByName
   477  // changeCursorByNameRequest writes a ChangeCursorByName request to a byte slice.
   478  func changeCursorByNameRequest(c *xgb.Conn, Src xproto.Cursor, Nbytes uint16, Name string) []byte {
   479  	size := xgb.Pad((12 + xgb.Pad((int(Nbytes) * 1))))
   480  	b := 0
   481  	buf := make([]byte, size)
   482  
   483  	c.ExtLock.RLock()
   484  	buf[b] = c.Extensions["XFIXES"]
   485  	c.ExtLock.RUnlock()
   486  	b += 1
   487  
   488  	buf[b] = 27 // request opcode
   489  	b += 1
   490  
   491  	xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
   492  	b += 2
   493  
   494  	xgb.Put32(buf[b:], uint32(Src))
   495  	b += 4
   496  
   497  	xgb.Put16(buf[b:], Nbytes)
   498  	b += 2
   499  
   500  	b += 2 // padding
   501  
   502  	copy(buf[b:], Name[:Nbytes])
   503  	b += int(Nbytes)
   504  
   505  	return buf
   506  }
   507  
   508  // ChangeSaveSetCookie is a cookie used only for ChangeSaveSet requests.
   509  type ChangeSaveSetCookie struct {
   510  	*xgb.Cookie
   511  }
   512  
   513  // ChangeSaveSet sends an unchecked request.
   514  // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
   515  func ChangeSaveSet(c *xgb.Conn, Mode byte, Target byte, Map byte, Window xproto.Window) ChangeSaveSetCookie {
   516  	c.ExtLock.RLock()
   517  	defer c.ExtLock.RUnlock()
   518  	if _, ok := c.Extensions["XFIXES"]; !ok {
   519  		panic("Cannot issue request 'ChangeSaveSet' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.")
   520  	}
   521  	cookie := c.NewCookie(false, false)
   522  	c.NewRequest(changeSaveSetRequest(c, Mode, Target, Map, Window), cookie)
   523  	return ChangeSaveSetCookie{cookie}
   524  }
   525  
   526  // ChangeSaveSetChecked sends a checked request.
   527  // If an error occurs, it can be retrieved using ChangeSaveSetCookie.Check()
   528  func ChangeSaveSetChecked(c *xgb.Conn, Mode byte, Target byte, Map byte, Window xproto.Window) ChangeSaveSetCookie {
   529  	c.ExtLock.RLock()
   530  	defer c.ExtLock.RUnlock()
   531  	if _, ok := c.Extensions["XFIXES"]; !ok {
   532  		panic("Cannot issue request 'ChangeSaveSet' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.")
   533  	}
   534  	cookie := c.NewCookie(true, false)
   535  	c.NewRequest(changeSaveSetRequest(c, Mode, Target, Map, Window), cookie)
   536  	return ChangeSaveSetCookie{cookie}
   537  }
   538  
   539  // Check returns an error if one occurred for checked requests that are not expecting a reply.
   540  // This cannot be called for requests expecting a reply, nor for unchecked requests.
   541  func (cook ChangeSaveSetCookie) Check() error {
   542  	return cook.Cookie.Check()
   543  }
   544  
   545  // Write request to wire for ChangeSaveSet
   546  // changeSaveSetRequest writes a ChangeSaveSet request to a byte slice.
   547  func changeSaveSetRequest(c *xgb.Conn, Mode byte, Target byte, Map byte, Window xproto.Window) []byte {
   548  	size := 12
   549  	b := 0
   550  	buf := make([]byte, size)
   551  
   552  	c.ExtLock.RLock()
   553  	buf[b] = c.Extensions["XFIXES"]
   554  	c.ExtLock.RUnlock()
   555  	b += 1
   556  
   557  	buf[b] = 1 // request opcode
   558  	b += 1
   559  
   560  	xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
   561  	b += 2
   562  
   563  	buf[b] = Mode
   564  	b += 1
   565  
   566  	buf[b] = Target
   567  	b += 1
   568  
   569  	buf[b] = Map
   570  	b += 1
   571  
   572  	b += 1 // padding
   573  
   574  	xgb.Put32(buf[b:], uint32(Window))
   575  	b += 4
   576  
   577  	return buf
   578  }
   579  
   580  // CopyRegionCookie is a cookie used only for CopyRegion requests.
   581  type CopyRegionCookie struct {
   582  	*xgb.Cookie
   583  }
   584  
   585  // CopyRegion sends an unchecked request.
   586  // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
   587  func CopyRegion(c *xgb.Conn, Source Region, Destination Region) CopyRegionCookie {
   588  	c.ExtLock.RLock()
   589  	defer c.ExtLock.RUnlock()
   590  	if _, ok := c.Extensions["XFIXES"]; !ok {
   591  		panic("Cannot issue request 'CopyRegion' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.")
   592  	}
   593  	cookie := c.NewCookie(false, false)
   594  	c.NewRequest(copyRegionRequest(c, Source, Destination), cookie)
   595  	return CopyRegionCookie{cookie}
   596  }
   597  
   598  // CopyRegionChecked sends a checked request.
   599  // If an error occurs, it can be retrieved using CopyRegionCookie.Check()
   600  func CopyRegionChecked(c *xgb.Conn, Source Region, Destination Region) CopyRegionCookie {
   601  	c.ExtLock.RLock()
   602  	defer c.ExtLock.RUnlock()
   603  	if _, ok := c.Extensions["XFIXES"]; !ok {
   604  		panic("Cannot issue request 'CopyRegion' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.")
   605  	}
   606  	cookie := c.NewCookie(true, false)
   607  	c.NewRequest(copyRegionRequest(c, Source, Destination), cookie)
   608  	return CopyRegionCookie{cookie}
   609  }
   610  
   611  // Check returns an error if one occurred for checked requests that are not expecting a reply.
   612  // This cannot be called for requests expecting a reply, nor for unchecked requests.
   613  func (cook CopyRegionCookie) Check() error {
   614  	return cook.Cookie.Check()
   615  }
   616  
   617  // Write request to wire for CopyRegion
   618  // copyRegionRequest writes a CopyRegion request to a byte slice.
   619  func copyRegionRequest(c *xgb.Conn, Source Region, Destination Region) []byte {
   620  	size := 12
   621  	b := 0
   622  	buf := make([]byte, size)
   623  
   624  	c.ExtLock.RLock()
   625  	buf[b] = c.Extensions["XFIXES"]
   626  	c.ExtLock.RUnlock()
   627  	b += 1
   628  
   629  	buf[b] = 12 // request opcode
   630  	b += 1
   631  
   632  	xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
   633  	b += 2
   634  
   635  	xgb.Put32(buf[b:], uint32(Source))
   636  	b += 4
   637  
   638  	xgb.Put32(buf[b:], uint32(Destination))
   639  	b += 4
   640  
   641  	return buf
   642  }
   643  
   644  // CreatePointerBarrierCookie is a cookie used only for CreatePointerBarrier requests.
   645  type CreatePointerBarrierCookie struct {
   646  	*xgb.Cookie
   647  }
   648  
   649  // CreatePointerBarrier sends an unchecked request.
   650  // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
   651  func CreatePointerBarrier(c *xgb.Conn, Barrier Barrier, Window xproto.Window, X1 uint16, Y1 uint16, X2 uint16, Y2 uint16, Directions uint32, NumDevices uint16, Devices []uint16) CreatePointerBarrierCookie {
   652  	c.ExtLock.RLock()
   653  	defer c.ExtLock.RUnlock()
   654  	if _, ok := c.Extensions["XFIXES"]; !ok {
   655  		panic("Cannot issue request 'CreatePointerBarrier' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.")
   656  	}
   657  	cookie := c.NewCookie(false, false)
   658  	c.NewRequest(createPointerBarrierRequest(c, Barrier, Window, X1, Y1, X2, Y2, Directions, NumDevices, Devices), cookie)
   659  	return CreatePointerBarrierCookie{cookie}
   660  }
   661  
   662  // CreatePointerBarrierChecked sends a checked request.
   663  // If an error occurs, it can be retrieved using CreatePointerBarrierCookie.Check()
   664  func CreatePointerBarrierChecked(c *xgb.Conn, Barrier Barrier, Window xproto.Window, X1 uint16, Y1 uint16, X2 uint16, Y2 uint16, Directions uint32, NumDevices uint16, Devices []uint16) CreatePointerBarrierCookie {
   665  	c.ExtLock.RLock()
   666  	defer c.ExtLock.RUnlock()
   667  	if _, ok := c.Extensions["XFIXES"]; !ok {
   668  		panic("Cannot issue request 'CreatePointerBarrier' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.")
   669  	}
   670  	cookie := c.NewCookie(true, false)
   671  	c.NewRequest(createPointerBarrierRequest(c, Barrier, Window, X1, Y1, X2, Y2, Directions, NumDevices, Devices), cookie)
   672  	return CreatePointerBarrierCookie{cookie}
   673  }
   674  
   675  // Check returns an error if one occurred for checked requests that are not expecting a reply.
   676  // This cannot be called for requests expecting a reply, nor for unchecked requests.
   677  func (cook CreatePointerBarrierCookie) Check() error {
   678  	return cook.Cookie.Check()
   679  }
   680  
   681  // Write request to wire for CreatePointerBarrier
   682  // createPointerBarrierRequest writes a CreatePointerBarrier request to a byte slice.
   683  func createPointerBarrierRequest(c *xgb.Conn, Barrier Barrier, Window xproto.Window, X1 uint16, Y1 uint16, X2 uint16, Y2 uint16, Directions uint32, NumDevices uint16, Devices []uint16) []byte {
   684  	size := xgb.Pad((28 + xgb.Pad((int(NumDevices) * 2))))
   685  	b := 0
   686  	buf := make([]byte, size)
   687  
   688  	c.ExtLock.RLock()
   689  	buf[b] = c.Extensions["XFIXES"]
   690  	c.ExtLock.RUnlock()
   691  	b += 1
   692  
   693  	buf[b] = 31 // request opcode
   694  	b += 1
   695  
   696  	xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
   697  	b += 2
   698  
   699  	xgb.Put32(buf[b:], uint32(Barrier))
   700  	b += 4
   701  
   702  	xgb.Put32(buf[b:], uint32(Window))
   703  	b += 4
   704  
   705  	xgb.Put16(buf[b:], X1)
   706  	b += 2
   707  
   708  	xgb.Put16(buf[b:], Y1)
   709  	b += 2
   710  
   711  	xgb.Put16(buf[b:], X2)
   712  	b += 2
   713  
   714  	xgb.Put16(buf[b:], Y2)
   715  	b += 2
   716  
   717  	xgb.Put32(buf[b:], Directions)
   718  	b += 4
   719  
   720  	b += 2 // padding
   721  
   722  	xgb.Put16(buf[b:], NumDevices)
   723  	b += 2
   724  
   725  	for i := 0; i < int(NumDevices); i++ {
   726  		xgb.Put16(buf[b:], Devices[i])
   727  		b += 2
   728  	}
   729  
   730  	return buf
   731  }
   732  
   733  // CreateRegionCookie is a cookie used only for CreateRegion requests.
   734  type CreateRegionCookie struct {
   735  	*xgb.Cookie
   736  }
   737  
   738  // CreateRegion sends an unchecked request.
   739  // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
   740  func CreateRegion(c *xgb.Conn, Region Region, Rectangles []xproto.Rectangle) CreateRegionCookie {
   741  	c.ExtLock.RLock()
   742  	defer c.ExtLock.RUnlock()
   743  	if _, ok := c.Extensions["XFIXES"]; !ok {
   744  		panic("Cannot issue request 'CreateRegion' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.")
   745  	}
   746  	cookie := c.NewCookie(false, false)
   747  	c.NewRequest(createRegionRequest(c, Region, Rectangles), cookie)
   748  	return CreateRegionCookie{cookie}
   749  }
   750  
   751  // CreateRegionChecked sends a checked request.
   752  // If an error occurs, it can be retrieved using CreateRegionCookie.Check()
   753  func CreateRegionChecked(c *xgb.Conn, Region Region, Rectangles []xproto.Rectangle) CreateRegionCookie {
   754  	c.ExtLock.RLock()
   755  	defer c.ExtLock.RUnlock()
   756  	if _, ok := c.Extensions["XFIXES"]; !ok {
   757  		panic("Cannot issue request 'CreateRegion' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.")
   758  	}
   759  	cookie := c.NewCookie(true, false)
   760  	c.NewRequest(createRegionRequest(c, Region, Rectangles), cookie)
   761  	return CreateRegionCookie{cookie}
   762  }
   763  
   764  // Check returns an error if one occurred for checked requests that are not expecting a reply.
   765  // This cannot be called for requests expecting a reply, nor for unchecked requests.
   766  func (cook CreateRegionCookie) Check() error {
   767  	return cook.Cookie.Check()
   768  }
   769  
   770  // Write request to wire for CreateRegion
   771  // createRegionRequest writes a CreateRegion request to a byte slice.
   772  func createRegionRequest(c *xgb.Conn, Region Region, Rectangles []xproto.Rectangle) []byte {
   773  	size := xgb.Pad((8 + xgb.Pad((len(Rectangles) * 8))))
   774  	b := 0
   775  	buf := make([]byte, size)
   776  
   777  	c.ExtLock.RLock()
   778  	buf[b] = c.Extensions["XFIXES"]
   779  	c.ExtLock.RUnlock()
   780  	b += 1
   781  
   782  	buf[b] = 5 // request opcode
   783  	b += 1
   784  
   785  	xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
   786  	b += 2
   787  
   788  	xgb.Put32(buf[b:], uint32(Region))
   789  	b += 4
   790  
   791  	b += xproto.RectangleListBytes(buf[b:], Rectangles)
   792  
   793  	return buf
   794  }
   795  
   796  // CreateRegionFromBitmapCookie is a cookie used only for CreateRegionFromBitmap requests.
   797  type CreateRegionFromBitmapCookie struct {
   798  	*xgb.Cookie
   799  }
   800  
   801  // CreateRegionFromBitmap sends an unchecked request.
   802  // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
   803  func CreateRegionFromBitmap(c *xgb.Conn, Region Region, Bitmap xproto.Pixmap) CreateRegionFromBitmapCookie {
   804  	c.ExtLock.RLock()
   805  	defer c.ExtLock.RUnlock()
   806  	if _, ok := c.Extensions["XFIXES"]; !ok {
   807  		panic("Cannot issue request 'CreateRegionFromBitmap' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.")
   808  	}
   809  	cookie := c.NewCookie(false, false)
   810  	c.NewRequest(createRegionFromBitmapRequest(c, Region, Bitmap), cookie)
   811  	return CreateRegionFromBitmapCookie{cookie}
   812  }
   813  
   814  // CreateRegionFromBitmapChecked sends a checked request.
   815  // If an error occurs, it can be retrieved using CreateRegionFromBitmapCookie.Check()
   816  func CreateRegionFromBitmapChecked(c *xgb.Conn, Region Region, Bitmap xproto.Pixmap) CreateRegionFromBitmapCookie {
   817  	c.ExtLock.RLock()
   818  	defer c.ExtLock.RUnlock()
   819  	if _, ok := c.Extensions["XFIXES"]; !ok {
   820  		panic("Cannot issue request 'CreateRegionFromBitmap' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.")
   821  	}
   822  	cookie := c.NewCookie(true, false)
   823  	c.NewRequest(createRegionFromBitmapRequest(c, Region, Bitmap), cookie)
   824  	return CreateRegionFromBitmapCookie{cookie}
   825  }
   826  
   827  // Check returns an error if one occurred for checked requests that are not expecting a reply.
   828  // This cannot be called for requests expecting a reply, nor for unchecked requests.
   829  func (cook CreateRegionFromBitmapCookie) Check() error {
   830  	return cook.Cookie.Check()
   831  }
   832  
   833  // Write request to wire for CreateRegionFromBitmap
   834  // createRegionFromBitmapRequest writes a CreateRegionFromBitmap request to a byte slice.
   835  func createRegionFromBitmapRequest(c *xgb.Conn, Region Region, Bitmap xproto.Pixmap) []byte {
   836  	size := 12
   837  	b := 0
   838  	buf := make([]byte, size)
   839  
   840  	c.ExtLock.RLock()
   841  	buf[b] = c.Extensions["XFIXES"]
   842  	c.ExtLock.RUnlock()
   843  	b += 1
   844  
   845  	buf[b] = 6 // request opcode
   846  	b += 1
   847  
   848  	xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
   849  	b += 2
   850  
   851  	xgb.Put32(buf[b:], uint32(Region))
   852  	b += 4
   853  
   854  	xgb.Put32(buf[b:], uint32(Bitmap))
   855  	b += 4
   856  
   857  	return buf
   858  }
   859  
   860  // CreateRegionFromGCCookie is a cookie used only for CreateRegionFromGC requests.
   861  type CreateRegionFromGCCookie struct {
   862  	*xgb.Cookie
   863  }
   864  
   865  // CreateRegionFromGC sends an unchecked request.
   866  // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
   867  func CreateRegionFromGC(c *xgb.Conn, Region Region, Gc xproto.Gcontext) CreateRegionFromGCCookie {
   868  	c.ExtLock.RLock()
   869  	defer c.ExtLock.RUnlock()
   870  	if _, ok := c.Extensions["XFIXES"]; !ok {
   871  		panic("Cannot issue request 'CreateRegionFromGC' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.")
   872  	}
   873  	cookie := c.NewCookie(false, false)
   874  	c.NewRequest(createRegionFromGCRequest(c, Region, Gc), cookie)
   875  	return CreateRegionFromGCCookie{cookie}
   876  }
   877  
   878  // CreateRegionFromGCChecked sends a checked request.
   879  // If an error occurs, it can be retrieved using CreateRegionFromGCCookie.Check()
   880  func CreateRegionFromGCChecked(c *xgb.Conn, Region Region, Gc xproto.Gcontext) CreateRegionFromGCCookie {
   881  	c.ExtLock.RLock()
   882  	defer c.ExtLock.RUnlock()
   883  	if _, ok := c.Extensions["XFIXES"]; !ok {
   884  		panic("Cannot issue request 'CreateRegionFromGC' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.")
   885  	}
   886  	cookie := c.NewCookie(true, false)
   887  	c.NewRequest(createRegionFromGCRequest(c, Region, Gc), cookie)
   888  	return CreateRegionFromGCCookie{cookie}
   889  }
   890  
   891  // Check returns an error if one occurred for checked requests that are not expecting a reply.
   892  // This cannot be called for requests expecting a reply, nor for unchecked requests.
   893  func (cook CreateRegionFromGCCookie) Check() error {
   894  	return cook.Cookie.Check()
   895  }
   896  
   897  // Write request to wire for CreateRegionFromGC
   898  // createRegionFromGCRequest writes a CreateRegionFromGC request to a byte slice.
   899  func createRegionFromGCRequest(c *xgb.Conn, Region Region, Gc xproto.Gcontext) []byte {
   900  	size := 12
   901  	b := 0
   902  	buf := make([]byte, size)
   903  
   904  	c.ExtLock.RLock()
   905  	buf[b] = c.Extensions["XFIXES"]
   906  	c.ExtLock.RUnlock()
   907  	b += 1
   908  
   909  	buf[b] = 8 // request opcode
   910  	b += 1
   911  
   912  	xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
   913  	b += 2
   914  
   915  	xgb.Put32(buf[b:], uint32(Region))
   916  	b += 4
   917  
   918  	xgb.Put32(buf[b:], uint32(Gc))
   919  	b += 4
   920  
   921  	return buf
   922  }
   923  
   924  // CreateRegionFromPictureCookie is a cookie used only for CreateRegionFromPicture requests.
   925  type CreateRegionFromPictureCookie struct {
   926  	*xgb.Cookie
   927  }
   928  
   929  // CreateRegionFromPicture sends an unchecked request.
   930  // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
   931  func CreateRegionFromPicture(c *xgb.Conn, Region Region, Picture render.Picture) CreateRegionFromPictureCookie {
   932  	c.ExtLock.RLock()
   933  	defer c.ExtLock.RUnlock()
   934  	if _, ok := c.Extensions["XFIXES"]; !ok {
   935  		panic("Cannot issue request 'CreateRegionFromPicture' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.")
   936  	}
   937  	cookie := c.NewCookie(false, false)
   938  	c.NewRequest(createRegionFromPictureRequest(c, Region, Picture), cookie)
   939  	return CreateRegionFromPictureCookie{cookie}
   940  }
   941  
   942  // CreateRegionFromPictureChecked sends a checked request.
   943  // If an error occurs, it can be retrieved using CreateRegionFromPictureCookie.Check()
   944  func CreateRegionFromPictureChecked(c *xgb.Conn, Region Region, Picture render.Picture) CreateRegionFromPictureCookie {
   945  	c.ExtLock.RLock()
   946  	defer c.ExtLock.RUnlock()
   947  	if _, ok := c.Extensions["XFIXES"]; !ok {
   948  		panic("Cannot issue request 'CreateRegionFromPicture' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.")
   949  	}
   950  	cookie := c.NewCookie(true, false)
   951  	c.NewRequest(createRegionFromPictureRequest(c, Region, Picture), cookie)
   952  	return CreateRegionFromPictureCookie{cookie}
   953  }
   954  
   955  // Check returns an error if one occurred for checked requests that are not expecting a reply.
   956  // This cannot be called for requests expecting a reply, nor for unchecked requests.
   957  func (cook CreateRegionFromPictureCookie) Check() error {
   958  	return cook.Cookie.Check()
   959  }
   960  
   961  // Write request to wire for CreateRegionFromPicture
   962  // createRegionFromPictureRequest writes a CreateRegionFromPicture request to a byte slice.
   963  func createRegionFromPictureRequest(c *xgb.Conn, Region Region, Picture render.Picture) []byte {
   964  	size := 12
   965  	b := 0
   966  	buf := make([]byte, size)
   967  
   968  	c.ExtLock.RLock()
   969  	buf[b] = c.Extensions["XFIXES"]
   970  	c.ExtLock.RUnlock()
   971  	b += 1
   972  
   973  	buf[b] = 9 // request opcode
   974  	b += 1
   975  
   976  	xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
   977  	b += 2
   978  
   979  	xgb.Put32(buf[b:], uint32(Region))
   980  	b += 4
   981  
   982  	xgb.Put32(buf[b:], uint32(Picture))
   983  	b += 4
   984  
   985  	return buf
   986  }
   987  
   988  // CreateRegionFromWindowCookie is a cookie used only for CreateRegionFromWindow requests.
   989  type CreateRegionFromWindowCookie struct {
   990  	*xgb.Cookie
   991  }
   992  
   993  // CreateRegionFromWindow sends an unchecked request.
   994  // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
   995  func CreateRegionFromWindow(c *xgb.Conn, Region Region, Window xproto.Window, Kind shape.Kind) CreateRegionFromWindowCookie {
   996  	c.ExtLock.RLock()
   997  	defer c.ExtLock.RUnlock()
   998  	if _, ok := c.Extensions["XFIXES"]; !ok {
   999  		panic("Cannot issue request 'CreateRegionFromWindow' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.")
  1000  	}
  1001  	cookie := c.NewCookie(false, false)
  1002  	c.NewRequest(createRegionFromWindowRequest(c, Region, Window, Kind), cookie)
  1003  	return CreateRegionFromWindowCookie{cookie}
  1004  }
  1005  
  1006  // CreateRegionFromWindowChecked sends a checked request.
  1007  // If an error occurs, it can be retrieved using CreateRegionFromWindowCookie.Check()
  1008  func CreateRegionFromWindowChecked(c *xgb.Conn, Region Region, Window xproto.Window, Kind shape.Kind) CreateRegionFromWindowCookie {
  1009  	c.ExtLock.RLock()
  1010  	defer c.ExtLock.RUnlock()
  1011  	if _, ok := c.Extensions["XFIXES"]; !ok {
  1012  		panic("Cannot issue request 'CreateRegionFromWindow' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.")
  1013  	}
  1014  	cookie := c.NewCookie(true, false)
  1015  	c.NewRequest(createRegionFromWindowRequest(c, Region, Window, Kind), cookie)
  1016  	return CreateRegionFromWindowCookie{cookie}
  1017  }
  1018  
  1019  // Check returns an error if one occurred for checked requests that are not expecting a reply.
  1020  // This cannot be called for requests expecting a reply, nor for unchecked requests.
  1021  func (cook CreateRegionFromWindowCookie) Check() error {
  1022  	return cook.Cookie.Check()
  1023  }
  1024  
  1025  // Write request to wire for CreateRegionFromWindow
  1026  // createRegionFromWindowRequest writes a CreateRegionFromWindow request to a byte slice.
  1027  func createRegionFromWindowRequest(c *xgb.Conn, Region Region, Window xproto.Window, Kind shape.Kind) []byte {
  1028  	size := 16
  1029  	b := 0
  1030  	buf := make([]byte, size)
  1031  
  1032  	c.ExtLock.RLock()
  1033  	buf[b] = c.Extensions["XFIXES"]
  1034  	c.ExtLock.RUnlock()
  1035  	b += 1
  1036  
  1037  	buf[b] = 7 // request opcode
  1038  	b += 1
  1039  
  1040  	xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
  1041  	b += 2
  1042  
  1043  	xgb.Put32(buf[b:], uint32(Region))
  1044  	b += 4
  1045  
  1046  	xgb.Put32(buf[b:], uint32(Window))
  1047  	b += 4
  1048  
  1049  	buf[b] = byte(Kind)
  1050  	b += 1
  1051  
  1052  	b += 3 // padding
  1053  
  1054  	return buf
  1055  }
  1056  
  1057  // DeletePointerBarrierCookie is a cookie used only for DeletePointerBarrier requests.
  1058  type DeletePointerBarrierCookie struct {
  1059  	*xgb.Cookie
  1060  }
  1061  
  1062  // DeletePointerBarrier sends an unchecked request.
  1063  // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
  1064  func DeletePointerBarrier(c *xgb.Conn, Barrier Barrier) DeletePointerBarrierCookie {
  1065  	c.ExtLock.RLock()
  1066  	defer c.ExtLock.RUnlock()
  1067  	if _, ok := c.Extensions["XFIXES"]; !ok {
  1068  		panic("Cannot issue request 'DeletePointerBarrier' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.")
  1069  	}
  1070  	cookie := c.NewCookie(false, false)
  1071  	c.NewRequest(deletePointerBarrierRequest(c, Barrier), cookie)
  1072  	return DeletePointerBarrierCookie{cookie}
  1073  }
  1074  
  1075  // DeletePointerBarrierChecked sends a checked request.
  1076  // If an error occurs, it can be retrieved using DeletePointerBarrierCookie.Check()
  1077  func DeletePointerBarrierChecked(c *xgb.Conn, Barrier Barrier) DeletePointerBarrierCookie {
  1078  	c.ExtLock.RLock()
  1079  	defer c.ExtLock.RUnlock()
  1080  	if _, ok := c.Extensions["XFIXES"]; !ok {
  1081  		panic("Cannot issue request 'DeletePointerBarrier' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.")
  1082  	}
  1083  	cookie := c.NewCookie(true, false)
  1084  	c.NewRequest(deletePointerBarrierRequest(c, Barrier), cookie)
  1085  	return DeletePointerBarrierCookie{cookie}
  1086  }
  1087  
  1088  // Check returns an error if one occurred for checked requests that are not expecting a reply.
  1089  // This cannot be called for requests expecting a reply, nor for unchecked requests.
  1090  func (cook DeletePointerBarrierCookie) Check() error {
  1091  	return cook.Cookie.Check()
  1092  }
  1093  
  1094  // Write request to wire for DeletePointerBarrier
  1095  // deletePointerBarrierRequest writes a DeletePointerBarrier request to a byte slice.
  1096  func deletePointerBarrierRequest(c *xgb.Conn, Barrier Barrier) []byte {
  1097  	size := 8
  1098  	b := 0
  1099  	buf := make([]byte, size)
  1100  
  1101  	c.ExtLock.RLock()
  1102  	buf[b] = c.Extensions["XFIXES"]
  1103  	c.ExtLock.RUnlock()
  1104  	b += 1
  1105  
  1106  	buf[b] = 32 // request opcode
  1107  	b += 1
  1108  
  1109  	xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
  1110  	b += 2
  1111  
  1112  	xgb.Put32(buf[b:], uint32(Barrier))
  1113  	b += 4
  1114  
  1115  	return buf
  1116  }
  1117  
  1118  // DestroyRegionCookie is a cookie used only for DestroyRegion requests.
  1119  type DestroyRegionCookie struct {
  1120  	*xgb.Cookie
  1121  }
  1122  
  1123  // DestroyRegion sends an unchecked request.
  1124  // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
  1125  func DestroyRegion(c *xgb.Conn, Region Region) DestroyRegionCookie {
  1126  	c.ExtLock.RLock()
  1127  	defer c.ExtLock.RUnlock()
  1128  	if _, ok := c.Extensions["XFIXES"]; !ok {
  1129  		panic("Cannot issue request 'DestroyRegion' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.")
  1130  	}
  1131  	cookie := c.NewCookie(false, false)
  1132  	c.NewRequest(destroyRegionRequest(c, Region), cookie)
  1133  	return DestroyRegionCookie{cookie}
  1134  }
  1135  
  1136  // DestroyRegionChecked sends a checked request.
  1137  // If an error occurs, it can be retrieved using DestroyRegionCookie.Check()
  1138  func DestroyRegionChecked(c *xgb.Conn, Region Region) DestroyRegionCookie {
  1139  	c.ExtLock.RLock()
  1140  	defer c.ExtLock.RUnlock()
  1141  	if _, ok := c.Extensions["XFIXES"]; !ok {
  1142  		panic("Cannot issue request 'DestroyRegion' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.")
  1143  	}
  1144  	cookie := c.NewCookie(true, false)
  1145  	c.NewRequest(destroyRegionRequest(c, Region), cookie)
  1146  	return DestroyRegionCookie{cookie}
  1147  }
  1148  
  1149  // Check returns an error if one occurred for checked requests that are not expecting a reply.
  1150  // This cannot be called for requests expecting a reply, nor for unchecked requests.
  1151  func (cook DestroyRegionCookie) Check() error {
  1152  	return cook.Cookie.Check()
  1153  }
  1154  
  1155  // Write request to wire for DestroyRegion
  1156  // destroyRegionRequest writes a DestroyRegion request to a byte slice.
  1157  func destroyRegionRequest(c *xgb.Conn, Region Region) []byte {
  1158  	size := 8
  1159  	b := 0
  1160  	buf := make([]byte, size)
  1161  
  1162  	c.ExtLock.RLock()
  1163  	buf[b] = c.Extensions["XFIXES"]
  1164  	c.ExtLock.RUnlock()
  1165  	b += 1
  1166  
  1167  	buf[b] = 10 // request opcode
  1168  	b += 1
  1169  
  1170  	xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
  1171  	b += 2
  1172  
  1173  	xgb.Put32(buf[b:], uint32(Region))
  1174  	b += 4
  1175  
  1176  	return buf
  1177  }
  1178  
  1179  // ExpandRegionCookie is a cookie used only for ExpandRegion requests.
  1180  type ExpandRegionCookie struct {
  1181  	*xgb.Cookie
  1182  }
  1183  
  1184  // ExpandRegion sends an unchecked request.
  1185  // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
  1186  func ExpandRegion(c *xgb.Conn, Source Region, Destination Region, Left uint16, Right uint16, Top uint16, Bottom uint16) ExpandRegionCookie {
  1187  	c.ExtLock.RLock()
  1188  	defer c.ExtLock.RUnlock()
  1189  	if _, ok := c.Extensions["XFIXES"]; !ok {
  1190  		panic("Cannot issue request 'ExpandRegion' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.")
  1191  	}
  1192  	cookie := c.NewCookie(false, false)
  1193  	c.NewRequest(expandRegionRequest(c, Source, Destination, Left, Right, Top, Bottom), cookie)
  1194  	return ExpandRegionCookie{cookie}
  1195  }
  1196  
  1197  // ExpandRegionChecked sends a checked request.
  1198  // If an error occurs, it can be retrieved using ExpandRegionCookie.Check()
  1199  func ExpandRegionChecked(c *xgb.Conn, Source Region, Destination Region, Left uint16, Right uint16, Top uint16, Bottom uint16) ExpandRegionCookie {
  1200  	c.ExtLock.RLock()
  1201  	defer c.ExtLock.RUnlock()
  1202  	if _, ok := c.Extensions["XFIXES"]; !ok {
  1203  		panic("Cannot issue request 'ExpandRegion' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.")
  1204  	}
  1205  	cookie := c.NewCookie(true, false)
  1206  	c.NewRequest(expandRegionRequest(c, Source, Destination, Left, Right, Top, Bottom), cookie)
  1207  	return ExpandRegionCookie{cookie}
  1208  }
  1209  
  1210  // Check returns an error if one occurred for checked requests that are not expecting a reply.
  1211  // This cannot be called for requests expecting a reply, nor for unchecked requests.
  1212  func (cook ExpandRegionCookie) Check() error {
  1213  	return cook.Cookie.Check()
  1214  }
  1215  
  1216  // Write request to wire for ExpandRegion
  1217  // expandRegionRequest writes a ExpandRegion request to a byte slice.
  1218  func expandRegionRequest(c *xgb.Conn, Source Region, Destination Region, Left uint16, Right uint16, Top uint16, Bottom uint16) []byte {
  1219  	size := 20
  1220  	b := 0
  1221  	buf := make([]byte, size)
  1222  
  1223  	c.ExtLock.RLock()
  1224  	buf[b] = c.Extensions["XFIXES"]
  1225  	c.ExtLock.RUnlock()
  1226  	b += 1
  1227  
  1228  	buf[b] = 28 // request opcode
  1229  	b += 1
  1230  
  1231  	xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
  1232  	b += 2
  1233  
  1234  	xgb.Put32(buf[b:], uint32(Source))
  1235  	b += 4
  1236  
  1237  	xgb.Put32(buf[b:], uint32(Destination))
  1238  	b += 4
  1239  
  1240  	xgb.Put16(buf[b:], Left)
  1241  	b += 2
  1242  
  1243  	xgb.Put16(buf[b:], Right)
  1244  	b += 2
  1245  
  1246  	xgb.Put16(buf[b:], Top)
  1247  	b += 2
  1248  
  1249  	xgb.Put16(buf[b:], Bottom)
  1250  	b += 2
  1251  
  1252  	return buf
  1253  }
  1254  
  1255  // FetchRegionCookie is a cookie used only for FetchRegion requests.
  1256  type FetchRegionCookie struct {
  1257  	*xgb.Cookie
  1258  }
  1259  
  1260  // FetchRegion sends a checked request.
  1261  // If an error occurs, it will be returned with the reply by calling FetchRegionCookie.Reply()
  1262  func FetchRegion(c *xgb.Conn, Region Region) FetchRegionCookie {
  1263  	c.ExtLock.RLock()
  1264  	defer c.ExtLock.RUnlock()
  1265  	if _, ok := c.Extensions["XFIXES"]; !ok {
  1266  		panic("Cannot issue request 'FetchRegion' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.")
  1267  	}
  1268  	cookie := c.NewCookie(true, true)
  1269  	c.NewRequest(fetchRegionRequest(c, Region), cookie)
  1270  	return FetchRegionCookie{cookie}
  1271  }
  1272  
  1273  // FetchRegionUnchecked sends an unchecked request.
  1274  // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
  1275  func FetchRegionUnchecked(c *xgb.Conn, Region Region) FetchRegionCookie {
  1276  	c.ExtLock.RLock()
  1277  	defer c.ExtLock.RUnlock()
  1278  	if _, ok := c.Extensions["XFIXES"]; !ok {
  1279  		panic("Cannot issue request 'FetchRegion' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.")
  1280  	}
  1281  	cookie := c.NewCookie(false, true)
  1282  	c.NewRequest(fetchRegionRequest(c, Region), cookie)
  1283  	return FetchRegionCookie{cookie}
  1284  }
  1285  
  1286  // FetchRegionReply represents the data returned from a FetchRegion request.
  1287  type FetchRegionReply struct {
  1288  	Sequence uint16 // sequence number of the request for this reply
  1289  	Length   uint32 // number of bytes in this reply
  1290  	// padding: 1 bytes
  1291  	Extents xproto.Rectangle
  1292  	// padding: 16 bytes
  1293  	Rectangles []xproto.Rectangle // size: xgb.Pad(((int(Length) / 2) * 8))
  1294  }
  1295  
  1296  // Reply blocks and returns the reply data for a FetchRegion request.
  1297  func (cook FetchRegionCookie) Reply() (*FetchRegionReply, error) {
  1298  	buf, err := cook.Cookie.Reply()
  1299  	if err != nil {
  1300  		return nil, err
  1301  	}
  1302  	if buf == nil {
  1303  		return nil, nil
  1304  	}
  1305  	return fetchRegionReply(buf), nil
  1306  }
  1307  
  1308  // fetchRegionReply reads a byte slice into a FetchRegionReply value.
  1309  func fetchRegionReply(buf []byte) *FetchRegionReply {
  1310  	v := new(FetchRegionReply)
  1311  	b := 1 // skip reply determinant
  1312  
  1313  	b += 1 // padding
  1314  
  1315  	v.Sequence = xgb.Get16(buf[b:])
  1316  	b += 2
  1317  
  1318  	v.Length = xgb.Get32(buf[b:]) // 4-byte units
  1319  	b += 4
  1320  
  1321  	v.Extents = xproto.Rectangle{}
  1322  	b += xproto.RectangleRead(buf[b:], &v.Extents)
  1323  
  1324  	b += 16 // padding
  1325  
  1326  	v.Rectangles = make([]xproto.Rectangle, (int(v.Length) / 2))
  1327  	b += xproto.RectangleReadList(buf[b:], v.Rectangles)
  1328  
  1329  	return v
  1330  }
  1331  
  1332  // Write request to wire for FetchRegion
  1333  // fetchRegionRequest writes a FetchRegion request to a byte slice.
  1334  func fetchRegionRequest(c *xgb.Conn, Region Region) []byte {
  1335  	size := 8
  1336  	b := 0
  1337  	buf := make([]byte, size)
  1338  
  1339  	c.ExtLock.RLock()
  1340  	buf[b] = c.Extensions["XFIXES"]
  1341  	c.ExtLock.RUnlock()
  1342  	b += 1
  1343  
  1344  	buf[b] = 19 // request opcode
  1345  	b += 1
  1346  
  1347  	xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
  1348  	b += 2
  1349  
  1350  	xgb.Put32(buf[b:], uint32(Region))
  1351  	b += 4
  1352  
  1353  	return buf
  1354  }
  1355  
  1356  // GetCursorImageCookie is a cookie used only for GetCursorImage requests.
  1357  type GetCursorImageCookie struct {
  1358  	*xgb.Cookie
  1359  }
  1360  
  1361  // GetCursorImage sends a checked request.
  1362  // If an error occurs, it will be returned with the reply by calling GetCursorImageCookie.Reply()
  1363  func GetCursorImage(c *xgb.Conn) GetCursorImageCookie {
  1364  	c.ExtLock.RLock()
  1365  	defer c.ExtLock.RUnlock()
  1366  	if _, ok := c.Extensions["XFIXES"]; !ok {
  1367  		panic("Cannot issue request 'GetCursorImage' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.")
  1368  	}
  1369  	cookie := c.NewCookie(true, true)
  1370  	c.NewRequest(getCursorImageRequest(c), cookie)
  1371  	return GetCursorImageCookie{cookie}
  1372  }
  1373  
  1374  // GetCursorImageUnchecked sends an unchecked request.
  1375  // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
  1376  func GetCursorImageUnchecked(c *xgb.Conn) GetCursorImageCookie {
  1377  	c.ExtLock.RLock()
  1378  	defer c.ExtLock.RUnlock()
  1379  	if _, ok := c.Extensions["XFIXES"]; !ok {
  1380  		panic("Cannot issue request 'GetCursorImage' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.")
  1381  	}
  1382  	cookie := c.NewCookie(false, true)
  1383  	c.NewRequest(getCursorImageRequest(c), cookie)
  1384  	return GetCursorImageCookie{cookie}
  1385  }
  1386  
  1387  // GetCursorImageReply represents the data returned from a GetCursorImage request.
  1388  type GetCursorImageReply struct {
  1389  	Sequence uint16 // sequence number of the request for this reply
  1390  	Length   uint32 // number of bytes in this reply
  1391  	// padding: 1 bytes
  1392  	X            int16
  1393  	Y            int16
  1394  	Width        uint16
  1395  	Height       uint16
  1396  	Xhot         uint16
  1397  	Yhot         uint16
  1398  	CursorSerial uint32
  1399  	// padding: 8 bytes
  1400  	CursorImage []uint32 // size: xgb.Pad(((int(Width) * int(Height)) * 4))
  1401  }
  1402  
  1403  // Reply blocks and returns the reply data for a GetCursorImage request.
  1404  func (cook GetCursorImageCookie) Reply() (*GetCursorImageReply, error) {
  1405  	buf, err := cook.Cookie.Reply()
  1406  	if err != nil {
  1407  		return nil, err
  1408  	}
  1409  	if buf == nil {
  1410  		return nil, nil
  1411  	}
  1412  	return getCursorImageReply(buf), nil
  1413  }
  1414  
  1415  // getCursorImageReply reads a byte slice into a GetCursorImageReply value.
  1416  func getCursorImageReply(buf []byte) *GetCursorImageReply {
  1417  	v := new(GetCursorImageReply)
  1418  	b := 1 // skip reply determinant
  1419  
  1420  	b += 1 // padding
  1421  
  1422  	v.Sequence = xgb.Get16(buf[b:])
  1423  	b += 2
  1424  
  1425  	v.Length = xgb.Get32(buf[b:]) // 4-byte units
  1426  	b += 4
  1427  
  1428  	v.X = int16(xgb.Get16(buf[b:]))
  1429  	b += 2
  1430  
  1431  	v.Y = int16(xgb.Get16(buf[b:]))
  1432  	b += 2
  1433  
  1434  	v.Width = xgb.Get16(buf[b:])
  1435  	b += 2
  1436  
  1437  	v.Height = xgb.Get16(buf[b:])
  1438  	b += 2
  1439  
  1440  	v.Xhot = xgb.Get16(buf[b:])
  1441  	b += 2
  1442  
  1443  	v.Yhot = xgb.Get16(buf[b:])
  1444  	b += 2
  1445  
  1446  	v.CursorSerial = xgb.Get32(buf[b:])
  1447  	b += 4
  1448  
  1449  	b += 8 // padding
  1450  
  1451  	v.CursorImage = make([]uint32, (int(v.Width) * int(v.Height)))
  1452  	for i := 0; i < int((int(v.Width) * int(v.Height))); i++ {
  1453  		v.CursorImage[i] = xgb.Get32(buf[b:])
  1454  		b += 4
  1455  	}
  1456  
  1457  	return v
  1458  }
  1459  
  1460  // Write request to wire for GetCursorImage
  1461  // getCursorImageRequest writes a GetCursorImage request to a byte slice.
  1462  func getCursorImageRequest(c *xgb.Conn) []byte {
  1463  	size := 4
  1464  	b := 0
  1465  	buf := make([]byte, size)
  1466  
  1467  	c.ExtLock.RLock()
  1468  	buf[b] = c.Extensions["XFIXES"]
  1469  	c.ExtLock.RUnlock()
  1470  	b += 1
  1471  
  1472  	buf[b] = 4 // request opcode
  1473  	b += 1
  1474  
  1475  	xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
  1476  	b += 2
  1477  
  1478  	return buf
  1479  }
  1480  
  1481  // GetCursorImageAndNameCookie is a cookie used only for GetCursorImageAndName requests.
  1482  type GetCursorImageAndNameCookie struct {
  1483  	*xgb.Cookie
  1484  }
  1485  
  1486  // GetCursorImageAndName sends a checked request.
  1487  // If an error occurs, it will be returned with the reply by calling GetCursorImageAndNameCookie.Reply()
  1488  func GetCursorImageAndName(c *xgb.Conn) GetCursorImageAndNameCookie {
  1489  	c.ExtLock.RLock()
  1490  	defer c.ExtLock.RUnlock()
  1491  	if _, ok := c.Extensions["XFIXES"]; !ok {
  1492  		panic("Cannot issue request 'GetCursorImageAndName' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.")
  1493  	}
  1494  	cookie := c.NewCookie(true, true)
  1495  	c.NewRequest(getCursorImageAndNameRequest(c), cookie)
  1496  	return GetCursorImageAndNameCookie{cookie}
  1497  }
  1498  
  1499  // GetCursorImageAndNameUnchecked sends an unchecked request.
  1500  // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
  1501  func GetCursorImageAndNameUnchecked(c *xgb.Conn) GetCursorImageAndNameCookie {
  1502  	c.ExtLock.RLock()
  1503  	defer c.ExtLock.RUnlock()
  1504  	if _, ok := c.Extensions["XFIXES"]; !ok {
  1505  		panic("Cannot issue request 'GetCursorImageAndName' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.")
  1506  	}
  1507  	cookie := c.NewCookie(false, true)
  1508  	c.NewRequest(getCursorImageAndNameRequest(c), cookie)
  1509  	return GetCursorImageAndNameCookie{cookie}
  1510  }
  1511  
  1512  // GetCursorImageAndNameReply represents the data returned from a GetCursorImageAndName request.
  1513  type GetCursorImageAndNameReply struct {
  1514  	Sequence uint16 // sequence number of the request for this reply
  1515  	Length   uint32 // number of bytes in this reply
  1516  	// padding: 1 bytes
  1517  	X            int16
  1518  	Y            int16
  1519  	Width        uint16
  1520  	Height       uint16
  1521  	Xhot         uint16
  1522  	Yhot         uint16
  1523  	CursorSerial uint32
  1524  	CursorAtom   xproto.Atom
  1525  	Nbytes       uint16
  1526  	// padding: 2 bytes
  1527  	Name string // size: xgb.Pad((int(Nbytes) * 1))
  1528  	// alignment gap to multiple of 4
  1529  	CursorImage []uint32 // size: xgb.Pad(((int(Width) * int(Height)) * 4))
  1530  }
  1531  
  1532  // Reply blocks and returns the reply data for a GetCursorImageAndName request.
  1533  func (cook GetCursorImageAndNameCookie) Reply() (*GetCursorImageAndNameReply, error) {
  1534  	buf, err := cook.Cookie.Reply()
  1535  	if err != nil {
  1536  		return nil, err
  1537  	}
  1538  	if buf == nil {
  1539  		return nil, nil
  1540  	}
  1541  	return getCursorImageAndNameReply(buf), nil
  1542  }
  1543  
  1544  // getCursorImageAndNameReply reads a byte slice into a GetCursorImageAndNameReply value.
  1545  func getCursorImageAndNameReply(buf []byte) *GetCursorImageAndNameReply {
  1546  	v := new(GetCursorImageAndNameReply)
  1547  	b := 1 // skip reply determinant
  1548  
  1549  	b += 1 // padding
  1550  
  1551  	v.Sequence = xgb.Get16(buf[b:])
  1552  	b += 2
  1553  
  1554  	v.Length = xgb.Get32(buf[b:]) // 4-byte units
  1555  	b += 4
  1556  
  1557  	v.X = int16(xgb.Get16(buf[b:]))
  1558  	b += 2
  1559  
  1560  	v.Y = int16(xgb.Get16(buf[b:]))
  1561  	b += 2
  1562  
  1563  	v.Width = xgb.Get16(buf[b:])
  1564  	b += 2
  1565  
  1566  	v.Height = xgb.Get16(buf[b:])
  1567  	b += 2
  1568  
  1569  	v.Xhot = xgb.Get16(buf[b:])
  1570  	b += 2
  1571  
  1572  	v.Yhot = xgb.Get16(buf[b:])
  1573  	b += 2
  1574  
  1575  	v.CursorSerial = xgb.Get32(buf[b:])
  1576  	b += 4
  1577  
  1578  	v.CursorAtom = xproto.Atom(xgb.Get32(buf[b:]))
  1579  	b += 4
  1580  
  1581  	v.Nbytes = xgb.Get16(buf[b:])
  1582  	b += 2
  1583  
  1584  	b += 2 // padding
  1585  
  1586  	{
  1587  		byteString := make([]byte, v.Nbytes)
  1588  		copy(byteString[:v.Nbytes], buf[b:])
  1589  		v.Name = string(byteString)
  1590  		b += int(v.Nbytes)
  1591  	}
  1592  
  1593  	b = (b + 3) & ^3 // alignment gap
  1594  
  1595  	v.CursorImage = make([]uint32, (int(v.Width) * int(v.Height)))
  1596  	for i := 0; i < int((int(v.Width) * int(v.Height))); i++ {
  1597  		v.CursorImage[i] = xgb.Get32(buf[b:])
  1598  		b += 4
  1599  	}
  1600  
  1601  	return v
  1602  }
  1603  
  1604  // Write request to wire for GetCursorImageAndName
  1605  // getCursorImageAndNameRequest writes a GetCursorImageAndName request to a byte slice.
  1606  func getCursorImageAndNameRequest(c *xgb.Conn) []byte {
  1607  	size := 4
  1608  	b := 0
  1609  	buf := make([]byte, size)
  1610  
  1611  	c.ExtLock.RLock()
  1612  	buf[b] = c.Extensions["XFIXES"]
  1613  	c.ExtLock.RUnlock()
  1614  	b += 1
  1615  
  1616  	buf[b] = 25 // request opcode
  1617  	b += 1
  1618  
  1619  	xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
  1620  	b += 2
  1621  
  1622  	return buf
  1623  }
  1624  
  1625  // GetCursorNameCookie is a cookie used only for GetCursorName requests.
  1626  type GetCursorNameCookie struct {
  1627  	*xgb.Cookie
  1628  }
  1629  
  1630  // GetCursorName sends a checked request.
  1631  // If an error occurs, it will be returned with the reply by calling GetCursorNameCookie.Reply()
  1632  func GetCursorName(c *xgb.Conn, Cursor xproto.Cursor) GetCursorNameCookie {
  1633  	c.ExtLock.RLock()
  1634  	defer c.ExtLock.RUnlock()
  1635  	if _, ok := c.Extensions["XFIXES"]; !ok {
  1636  		panic("Cannot issue request 'GetCursorName' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.")
  1637  	}
  1638  	cookie := c.NewCookie(true, true)
  1639  	c.NewRequest(getCursorNameRequest(c, Cursor), cookie)
  1640  	return GetCursorNameCookie{cookie}
  1641  }
  1642  
  1643  // GetCursorNameUnchecked sends an unchecked request.
  1644  // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
  1645  func GetCursorNameUnchecked(c *xgb.Conn, Cursor xproto.Cursor) GetCursorNameCookie {
  1646  	c.ExtLock.RLock()
  1647  	defer c.ExtLock.RUnlock()
  1648  	if _, ok := c.Extensions["XFIXES"]; !ok {
  1649  		panic("Cannot issue request 'GetCursorName' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.")
  1650  	}
  1651  	cookie := c.NewCookie(false, true)
  1652  	c.NewRequest(getCursorNameRequest(c, Cursor), cookie)
  1653  	return GetCursorNameCookie{cookie}
  1654  }
  1655  
  1656  // GetCursorNameReply represents the data returned from a GetCursorName request.
  1657  type GetCursorNameReply struct {
  1658  	Sequence uint16 // sequence number of the request for this reply
  1659  	Length   uint32 // number of bytes in this reply
  1660  	// padding: 1 bytes
  1661  	Atom   xproto.Atom
  1662  	Nbytes uint16
  1663  	// padding: 18 bytes
  1664  	Name string // size: xgb.Pad((int(Nbytes) * 1))
  1665  }
  1666  
  1667  // Reply blocks and returns the reply data for a GetCursorName request.
  1668  func (cook GetCursorNameCookie) Reply() (*GetCursorNameReply, error) {
  1669  	buf, err := cook.Cookie.Reply()
  1670  	if err != nil {
  1671  		return nil, err
  1672  	}
  1673  	if buf == nil {
  1674  		return nil, nil
  1675  	}
  1676  	return getCursorNameReply(buf), nil
  1677  }
  1678  
  1679  // getCursorNameReply reads a byte slice into a GetCursorNameReply value.
  1680  func getCursorNameReply(buf []byte) *GetCursorNameReply {
  1681  	v := new(GetCursorNameReply)
  1682  	b := 1 // skip reply determinant
  1683  
  1684  	b += 1 // padding
  1685  
  1686  	v.Sequence = xgb.Get16(buf[b:])
  1687  	b += 2
  1688  
  1689  	v.Length = xgb.Get32(buf[b:]) // 4-byte units
  1690  	b += 4
  1691  
  1692  	v.Atom = xproto.Atom(xgb.Get32(buf[b:]))
  1693  	b += 4
  1694  
  1695  	v.Nbytes = xgb.Get16(buf[b:])
  1696  	b += 2
  1697  
  1698  	b += 18 // padding
  1699  
  1700  	{
  1701  		byteString := make([]byte, v.Nbytes)
  1702  		copy(byteString[:v.Nbytes], buf[b:])
  1703  		v.Name = string(byteString)
  1704  		b += int(v.Nbytes)
  1705  	}
  1706  
  1707  	return v
  1708  }
  1709  
  1710  // Write request to wire for GetCursorName
  1711  // getCursorNameRequest writes a GetCursorName request to a byte slice.
  1712  func getCursorNameRequest(c *xgb.Conn, Cursor xproto.Cursor) []byte {
  1713  	size := 8
  1714  	b := 0
  1715  	buf := make([]byte, size)
  1716  
  1717  	c.ExtLock.RLock()
  1718  	buf[b] = c.Extensions["XFIXES"]
  1719  	c.ExtLock.RUnlock()
  1720  	b += 1
  1721  
  1722  	buf[b] = 24 // request opcode
  1723  	b += 1
  1724  
  1725  	xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
  1726  	b += 2
  1727  
  1728  	xgb.Put32(buf[b:], uint32(Cursor))
  1729  	b += 4
  1730  
  1731  	return buf
  1732  }
  1733  
  1734  // HideCursorCookie is a cookie used only for HideCursor requests.
  1735  type HideCursorCookie struct {
  1736  	*xgb.Cookie
  1737  }
  1738  
  1739  // HideCursor sends an unchecked request.
  1740  // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
  1741  func HideCursor(c *xgb.Conn, Window xproto.Window) HideCursorCookie {
  1742  	c.ExtLock.RLock()
  1743  	defer c.ExtLock.RUnlock()
  1744  	if _, ok := c.Extensions["XFIXES"]; !ok {
  1745  		panic("Cannot issue request 'HideCursor' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.")
  1746  	}
  1747  	cookie := c.NewCookie(false, false)
  1748  	c.NewRequest(hideCursorRequest(c, Window), cookie)
  1749  	return HideCursorCookie{cookie}
  1750  }
  1751  
  1752  // HideCursorChecked sends a checked request.
  1753  // If an error occurs, it can be retrieved using HideCursorCookie.Check()
  1754  func HideCursorChecked(c *xgb.Conn, Window xproto.Window) HideCursorCookie {
  1755  	c.ExtLock.RLock()
  1756  	defer c.ExtLock.RUnlock()
  1757  	if _, ok := c.Extensions["XFIXES"]; !ok {
  1758  		panic("Cannot issue request 'HideCursor' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.")
  1759  	}
  1760  	cookie := c.NewCookie(true, false)
  1761  	c.NewRequest(hideCursorRequest(c, Window), cookie)
  1762  	return HideCursorCookie{cookie}
  1763  }
  1764  
  1765  // Check returns an error if one occurred for checked requests that are not expecting a reply.
  1766  // This cannot be called for requests expecting a reply, nor for unchecked requests.
  1767  func (cook HideCursorCookie) Check() error {
  1768  	return cook.Cookie.Check()
  1769  }
  1770  
  1771  // Write request to wire for HideCursor
  1772  // hideCursorRequest writes a HideCursor request to a byte slice.
  1773  func hideCursorRequest(c *xgb.Conn, Window xproto.Window) []byte {
  1774  	size := 8
  1775  	b := 0
  1776  	buf := make([]byte, size)
  1777  
  1778  	c.ExtLock.RLock()
  1779  	buf[b] = c.Extensions["XFIXES"]
  1780  	c.ExtLock.RUnlock()
  1781  	b += 1
  1782  
  1783  	buf[b] = 29 // request opcode
  1784  	b += 1
  1785  
  1786  	xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
  1787  	b += 2
  1788  
  1789  	xgb.Put32(buf[b:], uint32(Window))
  1790  	b += 4
  1791  
  1792  	return buf
  1793  }
  1794  
  1795  // IntersectRegionCookie is a cookie used only for IntersectRegion requests.
  1796  type IntersectRegionCookie struct {
  1797  	*xgb.Cookie
  1798  }
  1799  
  1800  // IntersectRegion sends an unchecked request.
  1801  // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
  1802  func IntersectRegion(c *xgb.Conn, Source1 Region, Source2 Region, Destination Region) IntersectRegionCookie {
  1803  	c.ExtLock.RLock()
  1804  	defer c.ExtLock.RUnlock()
  1805  	if _, ok := c.Extensions["XFIXES"]; !ok {
  1806  		panic("Cannot issue request 'IntersectRegion' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.")
  1807  	}
  1808  	cookie := c.NewCookie(false, false)
  1809  	c.NewRequest(intersectRegionRequest(c, Source1, Source2, Destination), cookie)
  1810  	return IntersectRegionCookie{cookie}
  1811  }
  1812  
  1813  // IntersectRegionChecked sends a checked request.
  1814  // If an error occurs, it can be retrieved using IntersectRegionCookie.Check()
  1815  func IntersectRegionChecked(c *xgb.Conn, Source1 Region, Source2 Region, Destination Region) IntersectRegionCookie {
  1816  	c.ExtLock.RLock()
  1817  	defer c.ExtLock.RUnlock()
  1818  	if _, ok := c.Extensions["XFIXES"]; !ok {
  1819  		panic("Cannot issue request 'IntersectRegion' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.")
  1820  	}
  1821  	cookie := c.NewCookie(true, false)
  1822  	c.NewRequest(intersectRegionRequest(c, Source1, Source2, Destination), cookie)
  1823  	return IntersectRegionCookie{cookie}
  1824  }
  1825  
  1826  // Check returns an error if one occurred for checked requests that are not expecting a reply.
  1827  // This cannot be called for requests expecting a reply, nor for unchecked requests.
  1828  func (cook IntersectRegionCookie) Check() error {
  1829  	return cook.Cookie.Check()
  1830  }
  1831  
  1832  // Write request to wire for IntersectRegion
  1833  // intersectRegionRequest writes a IntersectRegion request to a byte slice.
  1834  func intersectRegionRequest(c *xgb.Conn, Source1 Region, Source2 Region, Destination Region) []byte {
  1835  	size := 16
  1836  	b := 0
  1837  	buf := make([]byte, size)
  1838  
  1839  	c.ExtLock.RLock()
  1840  	buf[b] = c.Extensions["XFIXES"]
  1841  	c.ExtLock.RUnlock()
  1842  	b += 1
  1843  
  1844  	buf[b] = 14 // request opcode
  1845  	b += 1
  1846  
  1847  	xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
  1848  	b += 2
  1849  
  1850  	xgb.Put32(buf[b:], uint32(Source1))
  1851  	b += 4
  1852  
  1853  	xgb.Put32(buf[b:], uint32(Source2))
  1854  	b += 4
  1855  
  1856  	xgb.Put32(buf[b:], uint32(Destination))
  1857  	b += 4
  1858  
  1859  	return buf
  1860  }
  1861  
  1862  // InvertRegionCookie is a cookie used only for InvertRegion requests.
  1863  type InvertRegionCookie struct {
  1864  	*xgb.Cookie
  1865  }
  1866  
  1867  // InvertRegion sends an unchecked request.
  1868  // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
  1869  func InvertRegion(c *xgb.Conn, Source Region, Bounds xproto.Rectangle, Destination Region) InvertRegionCookie {
  1870  	c.ExtLock.RLock()
  1871  	defer c.ExtLock.RUnlock()
  1872  	if _, ok := c.Extensions["XFIXES"]; !ok {
  1873  		panic("Cannot issue request 'InvertRegion' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.")
  1874  	}
  1875  	cookie := c.NewCookie(false, false)
  1876  	c.NewRequest(invertRegionRequest(c, Source, Bounds, Destination), cookie)
  1877  	return InvertRegionCookie{cookie}
  1878  }
  1879  
  1880  // InvertRegionChecked sends a checked request.
  1881  // If an error occurs, it can be retrieved using InvertRegionCookie.Check()
  1882  func InvertRegionChecked(c *xgb.Conn, Source Region, Bounds xproto.Rectangle, Destination Region) InvertRegionCookie {
  1883  	c.ExtLock.RLock()
  1884  	defer c.ExtLock.RUnlock()
  1885  	if _, ok := c.Extensions["XFIXES"]; !ok {
  1886  		panic("Cannot issue request 'InvertRegion' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.")
  1887  	}
  1888  	cookie := c.NewCookie(true, false)
  1889  	c.NewRequest(invertRegionRequest(c, Source, Bounds, Destination), cookie)
  1890  	return InvertRegionCookie{cookie}
  1891  }
  1892  
  1893  // Check returns an error if one occurred for checked requests that are not expecting a reply.
  1894  // This cannot be called for requests expecting a reply, nor for unchecked requests.
  1895  func (cook InvertRegionCookie) Check() error {
  1896  	return cook.Cookie.Check()
  1897  }
  1898  
  1899  // Write request to wire for InvertRegion
  1900  // invertRegionRequest writes a InvertRegion request to a byte slice.
  1901  func invertRegionRequest(c *xgb.Conn, Source Region, Bounds xproto.Rectangle, Destination Region) []byte {
  1902  	size := 20
  1903  	b := 0
  1904  	buf := make([]byte, size)
  1905  
  1906  	c.ExtLock.RLock()
  1907  	buf[b] = c.Extensions["XFIXES"]
  1908  	c.ExtLock.RUnlock()
  1909  	b += 1
  1910  
  1911  	buf[b] = 16 // request opcode
  1912  	b += 1
  1913  
  1914  	xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
  1915  	b += 2
  1916  
  1917  	xgb.Put32(buf[b:], uint32(Source))
  1918  	b += 4
  1919  
  1920  	{
  1921  		structBytes := Bounds.Bytes()
  1922  		copy(buf[b:], structBytes)
  1923  		b += len(structBytes)
  1924  	}
  1925  
  1926  	xgb.Put32(buf[b:], uint32(Destination))
  1927  	b += 4
  1928  
  1929  	return buf
  1930  }
  1931  
  1932  // QueryVersionCookie is a cookie used only for QueryVersion requests.
  1933  type QueryVersionCookie struct {
  1934  	*xgb.Cookie
  1935  }
  1936  
  1937  // QueryVersion sends a checked request.
  1938  // If an error occurs, it will be returned with the reply by calling QueryVersionCookie.Reply()
  1939  func QueryVersion(c *xgb.Conn, ClientMajorVersion uint32, ClientMinorVersion uint32) QueryVersionCookie {
  1940  	c.ExtLock.RLock()
  1941  	defer c.ExtLock.RUnlock()
  1942  	if _, ok := c.Extensions["XFIXES"]; !ok {
  1943  		panic("Cannot issue request 'QueryVersion' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.")
  1944  	}
  1945  	cookie := c.NewCookie(true, true)
  1946  	c.NewRequest(queryVersionRequest(c, ClientMajorVersion, ClientMinorVersion), cookie)
  1947  	return QueryVersionCookie{cookie}
  1948  }
  1949  
  1950  // QueryVersionUnchecked sends an unchecked request.
  1951  // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
  1952  func QueryVersionUnchecked(c *xgb.Conn, ClientMajorVersion uint32, ClientMinorVersion uint32) QueryVersionCookie {
  1953  	c.ExtLock.RLock()
  1954  	defer c.ExtLock.RUnlock()
  1955  	if _, ok := c.Extensions["XFIXES"]; !ok {
  1956  		panic("Cannot issue request 'QueryVersion' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.")
  1957  	}
  1958  	cookie := c.NewCookie(false, true)
  1959  	c.NewRequest(queryVersionRequest(c, ClientMajorVersion, ClientMinorVersion), cookie)
  1960  	return QueryVersionCookie{cookie}
  1961  }
  1962  
  1963  // QueryVersionReply represents the data returned from a QueryVersion request.
  1964  type QueryVersionReply struct {
  1965  	Sequence uint16 // sequence number of the request for this reply
  1966  	Length   uint32 // number of bytes in this reply
  1967  	// padding: 1 bytes
  1968  	MajorVersion uint32
  1969  	MinorVersion uint32
  1970  	// padding: 16 bytes
  1971  }
  1972  
  1973  // Reply blocks and returns the reply data for a QueryVersion request.
  1974  func (cook QueryVersionCookie) Reply() (*QueryVersionReply, error) {
  1975  	buf, err := cook.Cookie.Reply()
  1976  	if err != nil {
  1977  		return nil, err
  1978  	}
  1979  	if buf == nil {
  1980  		return nil, nil
  1981  	}
  1982  	return queryVersionReply(buf), nil
  1983  }
  1984  
  1985  // queryVersionReply reads a byte slice into a QueryVersionReply value.
  1986  func queryVersionReply(buf []byte) *QueryVersionReply {
  1987  	v := new(QueryVersionReply)
  1988  	b := 1 // skip reply determinant
  1989  
  1990  	b += 1 // padding
  1991  
  1992  	v.Sequence = xgb.Get16(buf[b:])
  1993  	b += 2
  1994  
  1995  	v.Length = xgb.Get32(buf[b:]) // 4-byte units
  1996  	b += 4
  1997  
  1998  	v.MajorVersion = xgb.Get32(buf[b:])
  1999  	b += 4
  2000  
  2001  	v.MinorVersion = xgb.Get32(buf[b:])
  2002  	b += 4
  2003  
  2004  	b += 16 // padding
  2005  
  2006  	return v
  2007  }
  2008  
  2009  // Write request to wire for QueryVersion
  2010  // queryVersionRequest writes a QueryVersion request to a byte slice.
  2011  func queryVersionRequest(c *xgb.Conn, ClientMajorVersion uint32, ClientMinorVersion uint32) []byte {
  2012  	size := 12
  2013  	b := 0
  2014  	buf := make([]byte, size)
  2015  
  2016  	c.ExtLock.RLock()
  2017  	buf[b] = c.Extensions["XFIXES"]
  2018  	c.ExtLock.RUnlock()
  2019  	b += 1
  2020  
  2021  	buf[b] = 0 // request opcode
  2022  	b += 1
  2023  
  2024  	xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
  2025  	b += 2
  2026  
  2027  	xgb.Put32(buf[b:], ClientMajorVersion)
  2028  	b += 4
  2029  
  2030  	xgb.Put32(buf[b:], ClientMinorVersion)
  2031  	b += 4
  2032  
  2033  	return buf
  2034  }
  2035  
  2036  // RegionExtentsCookie is a cookie used only for RegionExtents requests.
  2037  type RegionExtentsCookie struct {
  2038  	*xgb.Cookie
  2039  }
  2040  
  2041  // RegionExtents sends an unchecked request.
  2042  // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
  2043  func RegionExtents(c *xgb.Conn, Source Region, Destination Region) RegionExtentsCookie {
  2044  	c.ExtLock.RLock()
  2045  	defer c.ExtLock.RUnlock()
  2046  	if _, ok := c.Extensions["XFIXES"]; !ok {
  2047  		panic("Cannot issue request 'RegionExtents' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.")
  2048  	}
  2049  	cookie := c.NewCookie(false, false)
  2050  	c.NewRequest(regionExtentsRequest(c, Source, Destination), cookie)
  2051  	return RegionExtentsCookie{cookie}
  2052  }
  2053  
  2054  // RegionExtentsChecked sends a checked request.
  2055  // If an error occurs, it can be retrieved using RegionExtentsCookie.Check()
  2056  func RegionExtentsChecked(c *xgb.Conn, Source Region, Destination Region) RegionExtentsCookie {
  2057  	c.ExtLock.RLock()
  2058  	defer c.ExtLock.RUnlock()
  2059  	if _, ok := c.Extensions["XFIXES"]; !ok {
  2060  		panic("Cannot issue request 'RegionExtents' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.")
  2061  	}
  2062  	cookie := c.NewCookie(true, false)
  2063  	c.NewRequest(regionExtentsRequest(c, Source, Destination), cookie)
  2064  	return RegionExtentsCookie{cookie}
  2065  }
  2066  
  2067  // Check returns an error if one occurred for checked requests that are not expecting a reply.
  2068  // This cannot be called for requests expecting a reply, nor for unchecked requests.
  2069  func (cook RegionExtentsCookie) Check() error {
  2070  	return cook.Cookie.Check()
  2071  }
  2072  
  2073  // Write request to wire for RegionExtents
  2074  // regionExtentsRequest writes a RegionExtents request to a byte slice.
  2075  func regionExtentsRequest(c *xgb.Conn, Source Region, Destination Region) []byte {
  2076  	size := 12
  2077  	b := 0
  2078  	buf := make([]byte, size)
  2079  
  2080  	c.ExtLock.RLock()
  2081  	buf[b] = c.Extensions["XFIXES"]
  2082  	c.ExtLock.RUnlock()
  2083  	b += 1
  2084  
  2085  	buf[b] = 18 // request opcode
  2086  	b += 1
  2087  
  2088  	xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
  2089  	b += 2
  2090  
  2091  	xgb.Put32(buf[b:], uint32(Source))
  2092  	b += 4
  2093  
  2094  	xgb.Put32(buf[b:], uint32(Destination))
  2095  	b += 4
  2096  
  2097  	return buf
  2098  }
  2099  
  2100  // SelectCursorInputCookie is a cookie used only for SelectCursorInput requests.
  2101  type SelectCursorInputCookie struct {
  2102  	*xgb.Cookie
  2103  }
  2104  
  2105  // SelectCursorInput sends an unchecked request.
  2106  // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
  2107  func SelectCursorInput(c *xgb.Conn, Window xproto.Window, EventMask uint32) SelectCursorInputCookie {
  2108  	c.ExtLock.RLock()
  2109  	defer c.ExtLock.RUnlock()
  2110  	if _, ok := c.Extensions["XFIXES"]; !ok {
  2111  		panic("Cannot issue request 'SelectCursorInput' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.")
  2112  	}
  2113  	cookie := c.NewCookie(false, false)
  2114  	c.NewRequest(selectCursorInputRequest(c, Window, EventMask), cookie)
  2115  	return SelectCursorInputCookie{cookie}
  2116  }
  2117  
  2118  // SelectCursorInputChecked sends a checked request.
  2119  // If an error occurs, it can be retrieved using SelectCursorInputCookie.Check()
  2120  func SelectCursorInputChecked(c *xgb.Conn, Window xproto.Window, EventMask uint32) SelectCursorInputCookie {
  2121  	c.ExtLock.RLock()
  2122  	defer c.ExtLock.RUnlock()
  2123  	if _, ok := c.Extensions["XFIXES"]; !ok {
  2124  		panic("Cannot issue request 'SelectCursorInput' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.")
  2125  	}
  2126  	cookie := c.NewCookie(true, false)
  2127  	c.NewRequest(selectCursorInputRequest(c, Window, EventMask), cookie)
  2128  	return SelectCursorInputCookie{cookie}
  2129  }
  2130  
  2131  // Check returns an error if one occurred for checked requests that are not expecting a reply.
  2132  // This cannot be called for requests expecting a reply, nor for unchecked requests.
  2133  func (cook SelectCursorInputCookie) Check() error {
  2134  	return cook.Cookie.Check()
  2135  }
  2136  
  2137  // Write request to wire for SelectCursorInput
  2138  // selectCursorInputRequest writes a SelectCursorInput request to a byte slice.
  2139  func selectCursorInputRequest(c *xgb.Conn, Window xproto.Window, EventMask uint32) []byte {
  2140  	size := 12
  2141  	b := 0
  2142  	buf := make([]byte, size)
  2143  
  2144  	c.ExtLock.RLock()
  2145  	buf[b] = c.Extensions["XFIXES"]
  2146  	c.ExtLock.RUnlock()
  2147  	b += 1
  2148  
  2149  	buf[b] = 3 // request opcode
  2150  	b += 1
  2151  
  2152  	xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
  2153  	b += 2
  2154  
  2155  	xgb.Put32(buf[b:], uint32(Window))
  2156  	b += 4
  2157  
  2158  	xgb.Put32(buf[b:], EventMask)
  2159  	b += 4
  2160  
  2161  	return buf
  2162  }
  2163  
  2164  // SelectSelectionInputCookie is a cookie used only for SelectSelectionInput requests.
  2165  type SelectSelectionInputCookie struct {
  2166  	*xgb.Cookie
  2167  }
  2168  
  2169  // SelectSelectionInput sends an unchecked request.
  2170  // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
  2171  func SelectSelectionInput(c *xgb.Conn, Window xproto.Window, Selection xproto.Atom, EventMask uint32) SelectSelectionInputCookie {
  2172  	c.ExtLock.RLock()
  2173  	defer c.ExtLock.RUnlock()
  2174  	if _, ok := c.Extensions["XFIXES"]; !ok {
  2175  		panic("Cannot issue request 'SelectSelectionInput' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.")
  2176  	}
  2177  	cookie := c.NewCookie(false, false)
  2178  	c.NewRequest(selectSelectionInputRequest(c, Window, Selection, EventMask), cookie)
  2179  	return SelectSelectionInputCookie{cookie}
  2180  }
  2181  
  2182  // SelectSelectionInputChecked sends a checked request.
  2183  // If an error occurs, it can be retrieved using SelectSelectionInputCookie.Check()
  2184  func SelectSelectionInputChecked(c *xgb.Conn, Window xproto.Window, Selection xproto.Atom, EventMask uint32) SelectSelectionInputCookie {
  2185  	c.ExtLock.RLock()
  2186  	defer c.ExtLock.RUnlock()
  2187  	if _, ok := c.Extensions["XFIXES"]; !ok {
  2188  		panic("Cannot issue request 'SelectSelectionInput' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.")
  2189  	}
  2190  	cookie := c.NewCookie(true, false)
  2191  	c.NewRequest(selectSelectionInputRequest(c, Window, Selection, EventMask), cookie)
  2192  	return SelectSelectionInputCookie{cookie}
  2193  }
  2194  
  2195  // Check returns an error if one occurred for checked requests that are not expecting a reply.
  2196  // This cannot be called for requests expecting a reply, nor for unchecked requests.
  2197  func (cook SelectSelectionInputCookie) Check() error {
  2198  	return cook.Cookie.Check()
  2199  }
  2200  
  2201  // Write request to wire for SelectSelectionInput
  2202  // selectSelectionInputRequest writes a SelectSelectionInput request to a byte slice.
  2203  func selectSelectionInputRequest(c *xgb.Conn, Window xproto.Window, Selection xproto.Atom, EventMask uint32) []byte {
  2204  	size := 16
  2205  	b := 0
  2206  	buf := make([]byte, size)
  2207  
  2208  	c.ExtLock.RLock()
  2209  	buf[b] = c.Extensions["XFIXES"]
  2210  	c.ExtLock.RUnlock()
  2211  	b += 1
  2212  
  2213  	buf[b] = 2 // request opcode
  2214  	b += 1
  2215  
  2216  	xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
  2217  	b += 2
  2218  
  2219  	xgb.Put32(buf[b:], uint32(Window))
  2220  	b += 4
  2221  
  2222  	xgb.Put32(buf[b:], uint32(Selection))
  2223  	b += 4
  2224  
  2225  	xgb.Put32(buf[b:], EventMask)
  2226  	b += 4
  2227  
  2228  	return buf
  2229  }
  2230  
  2231  // SetCursorNameCookie is a cookie used only for SetCursorName requests.
  2232  type SetCursorNameCookie struct {
  2233  	*xgb.Cookie
  2234  }
  2235  
  2236  // SetCursorName sends an unchecked request.
  2237  // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
  2238  func SetCursorName(c *xgb.Conn, Cursor xproto.Cursor, Nbytes uint16, Name string) SetCursorNameCookie {
  2239  	c.ExtLock.RLock()
  2240  	defer c.ExtLock.RUnlock()
  2241  	if _, ok := c.Extensions["XFIXES"]; !ok {
  2242  		panic("Cannot issue request 'SetCursorName' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.")
  2243  	}
  2244  	cookie := c.NewCookie(false, false)
  2245  	c.NewRequest(setCursorNameRequest(c, Cursor, Nbytes, Name), cookie)
  2246  	return SetCursorNameCookie{cookie}
  2247  }
  2248  
  2249  // SetCursorNameChecked sends a checked request.
  2250  // If an error occurs, it can be retrieved using SetCursorNameCookie.Check()
  2251  func SetCursorNameChecked(c *xgb.Conn, Cursor xproto.Cursor, Nbytes uint16, Name string) SetCursorNameCookie {
  2252  	c.ExtLock.RLock()
  2253  	defer c.ExtLock.RUnlock()
  2254  	if _, ok := c.Extensions["XFIXES"]; !ok {
  2255  		panic("Cannot issue request 'SetCursorName' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.")
  2256  	}
  2257  	cookie := c.NewCookie(true, false)
  2258  	c.NewRequest(setCursorNameRequest(c, Cursor, Nbytes, Name), cookie)
  2259  	return SetCursorNameCookie{cookie}
  2260  }
  2261  
  2262  // Check returns an error if one occurred for checked requests that are not expecting a reply.
  2263  // This cannot be called for requests expecting a reply, nor for unchecked requests.
  2264  func (cook SetCursorNameCookie) Check() error {
  2265  	return cook.Cookie.Check()
  2266  }
  2267  
  2268  // Write request to wire for SetCursorName
  2269  // setCursorNameRequest writes a SetCursorName request to a byte slice.
  2270  func setCursorNameRequest(c *xgb.Conn, Cursor xproto.Cursor, Nbytes uint16, Name string) []byte {
  2271  	size := xgb.Pad((12 + xgb.Pad((int(Nbytes) * 1))))
  2272  	b := 0
  2273  	buf := make([]byte, size)
  2274  
  2275  	c.ExtLock.RLock()
  2276  	buf[b] = c.Extensions["XFIXES"]
  2277  	c.ExtLock.RUnlock()
  2278  	b += 1
  2279  
  2280  	buf[b] = 23 // request opcode
  2281  	b += 1
  2282  
  2283  	xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
  2284  	b += 2
  2285  
  2286  	xgb.Put32(buf[b:], uint32(Cursor))
  2287  	b += 4
  2288  
  2289  	xgb.Put16(buf[b:], Nbytes)
  2290  	b += 2
  2291  
  2292  	b += 2 // padding
  2293  
  2294  	copy(buf[b:], Name[:Nbytes])
  2295  	b += int(Nbytes)
  2296  
  2297  	return buf
  2298  }
  2299  
  2300  // SetGCClipRegionCookie is a cookie used only for SetGCClipRegion requests.
  2301  type SetGCClipRegionCookie struct {
  2302  	*xgb.Cookie
  2303  }
  2304  
  2305  // SetGCClipRegion sends an unchecked request.
  2306  // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
  2307  func SetGCClipRegion(c *xgb.Conn, Gc xproto.Gcontext, Region Region, XOrigin int16, YOrigin int16) SetGCClipRegionCookie {
  2308  	c.ExtLock.RLock()
  2309  	defer c.ExtLock.RUnlock()
  2310  	if _, ok := c.Extensions["XFIXES"]; !ok {
  2311  		panic("Cannot issue request 'SetGCClipRegion' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.")
  2312  	}
  2313  	cookie := c.NewCookie(false, false)
  2314  	c.NewRequest(setGCClipRegionRequest(c, Gc, Region, XOrigin, YOrigin), cookie)
  2315  	return SetGCClipRegionCookie{cookie}
  2316  }
  2317  
  2318  // SetGCClipRegionChecked sends a checked request.
  2319  // If an error occurs, it can be retrieved using SetGCClipRegionCookie.Check()
  2320  func SetGCClipRegionChecked(c *xgb.Conn, Gc xproto.Gcontext, Region Region, XOrigin int16, YOrigin int16) SetGCClipRegionCookie {
  2321  	c.ExtLock.RLock()
  2322  	defer c.ExtLock.RUnlock()
  2323  	if _, ok := c.Extensions["XFIXES"]; !ok {
  2324  		panic("Cannot issue request 'SetGCClipRegion' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.")
  2325  	}
  2326  	cookie := c.NewCookie(true, false)
  2327  	c.NewRequest(setGCClipRegionRequest(c, Gc, Region, XOrigin, YOrigin), cookie)
  2328  	return SetGCClipRegionCookie{cookie}
  2329  }
  2330  
  2331  // Check returns an error if one occurred for checked requests that are not expecting a reply.
  2332  // This cannot be called for requests expecting a reply, nor for unchecked requests.
  2333  func (cook SetGCClipRegionCookie) Check() error {
  2334  	return cook.Cookie.Check()
  2335  }
  2336  
  2337  // Write request to wire for SetGCClipRegion
  2338  // setGCClipRegionRequest writes a SetGCClipRegion request to a byte slice.
  2339  func setGCClipRegionRequest(c *xgb.Conn, Gc xproto.Gcontext, Region Region, XOrigin int16, YOrigin int16) []byte {
  2340  	size := 16
  2341  	b := 0
  2342  	buf := make([]byte, size)
  2343  
  2344  	c.ExtLock.RLock()
  2345  	buf[b] = c.Extensions["XFIXES"]
  2346  	c.ExtLock.RUnlock()
  2347  	b += 1
  2348  
  2349  	buf[b] = 20 // request opcode
  2350  	b += 1
  2351  
  2352  	xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
  2353  	b += 2
  2354  
  2355  	xgb.Put32(buf[b:], uint32(Gc))
  2356  	b += 4
  2357  
  2358  	xgb.Put32(buf[b:], uint32(Region))
  2359  	b += 4
  2360  
  2361  	xgb.Put16(buf[b:], uint16(XOrigin))
  2362  	b += 2
  2363  
  2364  	xgb.Put16(buf[b:], uint16(YOrigin))
  2365  	b += 2
  2366  
  2367  	return buf
  2368  }
  2369  
  2370  // SetPictureClipRegionCookie is a cookie used only for SetPictureClipRegion requests.
  2371  type SetPictureClipRegionCookie struct {
  2372  	*xgb.Cookie
  2373  }
  2374  
  2375  // SetPictureClipRegion sends an unchecked request.
  2376  // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
  2377  func SetPictureClipRegion(c *xgb.Conn, Picture render.Picture, Region Region, XOrigin int16, YOrigin int16) SetPictureClipRegionCookie {
  2378  	c.ExtLock.RLock()
  2379  	defer c.ExtLock.RUnlock()
  2380  	if _, ok := c.Extensions["XFIXES"]; !ok {
  2381  		panic("Cannot issue request 'SetPictureClipRegion' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.")
  2382  	}
  2383  	cookie := c.NewCookie(false, false)
  2384  	c.NewRequest(setPictureClipRegionRequest(c, Picture, Region, XOrigin, YOrigin), cookie)
  2385  	return SetPictureClipRegionCookie{cookie}
  2386  }
  2387  
  2388  // SetPictureClipRegionChecked sends a checked request.
  2389  // If an error occurs, it can be retrieved using SetPictureClipRegionCookie.Check()
  2390  func SetPictureClipRegionChecked(c *xgb.Conn, Picture render.Picture, Region Region, XOrigin int16, YOrigin int16) SetPictureClipRegionCookie {
  2391  	c.ExtLock.RLock()
  2392  	defer c.ExtLock.RUnlock()
  2393  	if _, ok := c.Extensions["XFIXES"]; !ok {
  2394  		panic("Cannot issue request 'SetPictureClipRegion' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.")
  2395  	}
  2396  	cookie := c.NewCookie(true, false)
  2397  	c.NewRequest(setPictureClipRegionRequest(c, Picture, Region, XOrigin, YOrigin), cookie)
  2398  	return SetPictureClipRegionCookie{cookie}
  2399  }
  2400  
  2401  // Check returns an error if one occurred for checked requests that are not expecting a reply.
  2402  // This cannot be called for requests expecting a reply, nor for unchecked requests.
  2403  func (cook SetPictureClipRegionCookie) Check() error {
  2404  	return cook.Cookie.Check()
  2405  }
  2406  
  2407  // Write request to wire for SetPictureClipRegion
  2408  // setPictureClipRegionRequest writes a SetPictureClipRegion request to a byte slice.
  2409  func setPictureClipRegionRequest(c *xgb.Conn, Picture render.Picture, Region Region, XOrigin int16, YOrigin int16) []byte {
  2410  	size := 16
  2411  	b := 0
  2412  	buf := make([]byte, size)
  2413  
  2414  	c.ExtLock.RLock()
  2415  	buf[b] = c.Extensions["XFIXES"]
  2416  	c.ExtLock.RUnlock()
  2417  	b += 1
  2418  
  2419  	buf[b] = 22 // request opcode
  2420  	b += 1
  2421  
  2422  	xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
  2423  	b += 2
  2424  
  2425  	xgb.Put32(buf[b:], uint32(Picture))
  2426  	b += 4
  2427  
  2428  	xgb.Put32(buf[b:], uint32(Region))
  2429  	b += 4
  2430  
  2431  	xgb.Put16(buf[b:], uint16(XOrigin))
  2432  	b += 2
  2433  
  2434  	xgb.Put16(buf[b:], uint16(YOrigin))
  2435  	b += 2
  2436  
  2437  	return buf
  2438  }
  2439  
  2440  // SetRegionCookie is a cookie used only for SetRegion requests.
  2441  type SetRegionCookie struct {
  2442  	*xgb.Cookie
  2443  }
  2444  
  2445  // SetRegion sends an unchecked request.
  2446  // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
  2447  func SetRegion(c *xgb.Conn, Region Region, Rectangles []xproto.Rectangle) SetRegionCookie {
  2448  	c.ExtLock.RLock()
  2449  	defer c.ExtLock.RUnlock()
  2450  	if _, ok := c.Extensions["XFIXES"]; !ok {
  2451  		panic("Cannot issue request 'SetRegion' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.")
  2452  	}
  2453  	cookie := c.NewCookie(false, false)
  2454  	c.NewRequest(setRegionRequest(c, Region, Rectangles), cookie)
  2455  	return SetRegionCookie{cookie}
  2456  }
  2457  
  2458  // SetRegionChecked sends a checked request.
  2459  // If an error occurs, it can be retrieved using SetRegionCookie.Check()
  2460  func SetRegionChecked(c *xgb.Conn, Region Region, Rectangles []xproto.Rectangle) SetRegionCookie {
  2461  	c.ExtLock.RLock()
  2462  	defer c.ExtLock.RUnlock()
  2463  	if _, ok := c.Extensions["XFIXES"]; !ok {
  2464  		panic("Cannot issue request 'SetRegion' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.")
  2465  	}
  2466  	cookie := c.NewCookie(true, false)
  2467  	c.NewRequest(setRegionRequest(c, Region, Rectangles), cookie)
  2468  	return SetRegionCookie{cookie}
  2469  }
  2470  
  2471  // Check returns an error if one occurred for checked requests that are not expecting a reply.
  2472  // This cannot be called for requests expecting a reply, nor for unchecked requests.
  2473  func (cook SetRegionCookie) Check() error {
  2474  	return cook.Cookie.Check()
  2475  }
  2476  
  2477  // Write request to wire for SetRegion
  2478  // setRegionRequest writes a SetRegion request to a byte slice.
  2479  func setRegionRequest(c *xgb.Conn, Region Region, Rectangles []xproto.Rectangle) []byte {
  2480  	size := xgb.Pad((8 + xgb.Pad((len(Rectangles) * 8))))
  2481  	b := 0
  2482  	buf := make([]byte, size)
  2483  
  2484  	c.ExtLock.RLock()
  2485  	buf[b] = c.Extensions["XFIXES"]
  2486  	c.ExtLock.RUnlock()
  2487  	b += 1
  2488  
  2489  	buf[b] = 11 // request opcode
  2490  	b += 1
  2491  
  2492  	xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
  2493  	b += 2
  2494  
  2495  	xgb.Put32(buf[b:], uint32(Region))
  2496  	b += 4
  2497  
  2498  	b += xproto.RectangleListBytes(buf[b:], Rectangles)
  2499  
  2500  	return buf
  2501  }
  2502  
  2503  // SetWindowShapeRegionCookie is a cookie used only for SetWindowShapeRegion requests.
  2504  type SetWindowShapeRegionCookie struct {
  2505  	*xgb.Cookie
  2506  }
  2507  
  2508  // SetWindowShapeRegion sends an unchecked request.
  2509  // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
  2510  func SetWindowShapeRegion(c *xgb.Conn, Dest xproto.Window, DestKind shape.Kind, XOffset int16, YOffset int16, Region Region) SetWindowShapeRegionCookie {
  2511  	c.ExtLock.RLock()
  2512  	defer c.ExtLock.RUnlock()
  2513  	if _, ok := c.Extensions["XFIXES"]; !ok {
  2514  		panic("Cannot issue request 'SetWindowShapeRegion' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.")
  2515  	}
  2516  	cookie := c.NewCookie(false, false)
  2517  	c.NewRequest(setWindowShapeRegionRequest(c, Dest, DestKind, XOffset, YOffset, Region), cookie)
  2518  	return SetWindowShapeRegionCookie{cookie}
  2519  }
  2520  
  2521  // SetWindowShapeRegionChecked sends a checked request.
  2522  // If an error occurs, it can be retrieved using SetWindowShapeRegionCookie.Check()
  2523  func SetWindowShapeRegionChecked(c *xgb.Conn, Dest xproto.Window, DestKind shape.Kind, XOffset int16, YOffset int16, Region Region) SetWindowShapeRegionCookie {
  2524  	c.ExtLock.RLock()
  2525  	defer c.ExtLock.RUnlock()
  2526  	if _, ok := c.Extensions["XFIXES"]; !ok {
  2527  		panic("Cannot issue request 'SetWindowShapeRegion' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.")
  2528  	}
  2529  	cookie := c.NewCookie(true, false)
  2530  	c.NewRequest(setWindowShapeRegionRequest(c, Dest, DestKind, XOffset, YOffset, Region), cookie)
  2531  	return SetWindowShapeRegionCookie{cookie}
  2532  }
  2533  
  2534  // Check returns an error if one occurred for checked requests that are not expecting a reply.
  2535  // This cannot be called for requests expecting a reply, nor for unchecked requests.
  2536  func (cook SetWindowShapeRegionCookie) Check() error {
  2537  	return cook.Cookie.Check()
  2538  }
  2539  
  2540  // Write request to wire for SetWindowShapeRegion
  2541  // setWindowShapeRegionRequest writes a SetWindowShapeRegion request to a byte slice.
  2542  func setWindowShapeRegionRequest(c *xgb.Conn, Dest xproto.Window, DestKind shape.Kind, XOffset int16, YOffset int16, Region Region) []byte {
  2543  	size := 20
  2544  	b := 0
  2545  	buf := make([]byte, size)
  2546  
  2547  	c.ExtLock.RLock()
  2548  	buf[b] = c.Extensions["XFIXES"]
  2549  	c.ExtLock.RUnlock()
  2550  	b += 1
  2551  
  2552  	buf[b] = 21 // request opcode
  2553  	b += 1
  2554  
  2555  	xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
  2556  	b += 2
  2557  
  2558  	xgb.Put32(buf[b:], uint32(Dest))
  2559  	b += 4
  2560  
  2561  	buf[b] = byte(DestKind)
  2562  	b += 1
  2563  
  2564  	b += 3 // padding
  2565  
  2566  	xgb.Put16(buf[b:], uint16(XOffset))
  2567  	b += 2
  2568  
  2569  	xgb.Put16(buf[b:], uint16(YOffset))
  2570  	b += 2
  2571  
  2572  	xgb.Put32(buf[b:], uint32(Region))
  2573  	b += 4
  2574  
  2575  	return buf
  2576  }
  2577  
  2578  // ShowCursorCookie is a cookie used only for ShowCursor requests.
  2579  type ShowCursorCookie struct {
  2580  	*xgb.Cookie
  2581  }
  2582  
  2583  // ShowCursor sends an unchecked request.
  2584  // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
  2585  func ShowCursor(c *xgb.Conn, Window xproto.Window) ShowCursorCookie {
  2586  	c.ExtLock.RLock()
  2587  	defer c.ExtLock.RUnlock()
  2588  	if _, ok := c.Extensions["XFIXES"]; !ok {
  2589  		panic("Cannot issue request 'ShowCursor' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.")
  2590  	}
  2591  	cookie := c.NewCookie(false, false)
  2592  	c.NewRequest(showCursorRequest(c, Window), cookie)
  2593  	return ShowCursorCookie{cookie}
  2594  }
  2595  
  2596  // ShowCursorChecked sends a checked request.
  2597  // If an error occurs, it can be retrieved using ShowCursorCookie.Check()
  2598  func ShowCursorChecked(c *xgb.Conn, Window xproto.Window) ShowCursorCookie {
  2599  	c.ExtLock.RLock()
  2600  	defer c.ExtLock.RUnlock()
  2601  	if _, ok := c.Extensions["XFIXES"]; !ok {
  2602  		panic("Cannot issue request 'ShowCursor' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.")
  2603  	}
  2604  	cookie := c.NewCookie(true, false)
  2605  	c.NewRequest(showCursorRequest(c, Window), cookie)
  2606  	return ShowCursorCookie{cookie}
  2607  }
  2608  
  2609  // Check returns an error if one occurred for checked requests that are not expecting a reply.
  2610  // This cannot be called for requests expecting a reply, nor for unchecked requests.
  2611  func (cook ShowCursorCookie) Check() error {
  2612  	return cook.Cookie.Check()
  2613  }
  2614  
  2615  // Write request to wire for ShowCursor
  2616  // showCursorRequest writes a ShowCursor request to a byte slice.
  2617  func showCursorRequest(c *xgb.Conn, Window xproto.Window) []byte {
  2618  	size := 8
  2619  	b := 0
  2620  	buf := make([]byte, size)
  2621  
  2622  	c.ExtLock.RLock()
  2623  	buf[b] = c.Extensions["XFIXES"]
  2624  	c.ExtLock.RUnlock()
  2625  	b += 1
  2626  
  2627  	buf[b] = 30 // request opcode
  2628  	b += 1
  2629  
  2630  	xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
  2631  	b += 2
  2632  
  2633  	xgb.Put32(buf[b:], uint32(Window))
  2634  	b += 4
  2635  
  2636  	return buf
  2637  }
  2638  
  2639  // SubtractRegionCookie is a cookie used only for SubtractRegion requests.
  2640  type SubtractRegionCookie struct {
  2641  	*xgb.Cookie
  2642  }
  2643  
  2644  // SubtractRegion sends an unchecked request.
  2645  // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
  2646  func SubtractRegion(c *xgb.Conn, Source1 Region, Source2 Region, Destination Region) SubtractRegionCookie {
  2647  	c.ExtLock.RLock()
  2648  	defer c.ExtLock.RUnlock()
  2649  	if _, ok := c.Extensions["XFIXES"]; !ok {
  2650  		panic("Cannot issue request 'SubtractRegion' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.")
  2651  	}
  2652  	cookie := c.NewCookie(false, false)
  2653  	c.NewRequest(subtractRegionRequest(c, Source1, Source2, Destination), cookie)
  2654  	return SubtractRegionCookie{cookie}
  2655  }
  2656  
  2657  // SubtractRegionChecked sends a checked request.
  2658  // If an error occurs, it can be retrieved using SubtractRegionCookie.Check()
  2659  func SubtractRegionChecked(c *xgb.Conn, Source1 Region, Source2 Region, Destination Region) SubtractRegionCookie {
  2660  	c.ExtLock.RLock()
  2661  	defer c.ExtLock.RUnlock()
  2662  	if _, ok := c.Extensions["XFIXES"]; !ok {
  2663  		panic("Cannot issue request 'SubtractRegion' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.")
  2664  	}
  2665  	cookie := c.NewCookie(true, false)
  2666  	c.NewRequest(subtractRegionRequest(c, Source1, Source2, Destination), cookie)
  2667  	return SubtractRegionCookie{cookie}
  2668  }
  2669  
  2670  // Check returns an error if one occurred for checked requests that are not expecting a reply.
  2671  // This cannot be called for requests expecting a reply, nor for unchecked requests.
  2672  func (cook SubtractRegionCookie) Check() error {
  2673  	return cook.Cookie.Check()
  2674  }
  2675  
  2676  // Write request to wire for SubtractRegion
  2677  // subtractRegionRequest writes a SubtractRegion request to a byte slice.
  2678  func subtractRegionRequest(c *xgb.Conn, Source1 Region, Source2 Region, Destination Region) []byte {
  2679  	size := 16
  2680  	b := 0
  2681  	buf := make([]byte, size)
  2682  
  2683  	c.ExtLock.RLock()
  2684  	buf[b] = c.Extensions["XFIXES"]
  2685  	c.ExtLock.RUnlock()
  2686  	b += 1
  2687  
  2688  	buf[b] = 15 // request opcode
  2689  	b += 1
  2690  
  2691  	xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
  2692  	b += 2
  2693  
  2694  	xgb.Put32(buf[b:], uint32(Source1))
  2695  	b += 4
  2696  
  2697  	xgb.Put32(buf[b:], uint32(Source2))
  2698  	b += 4
  2699  
  2700  	xgb.Put32(buf[b:], uint32(Destination))
  2701  	b += 4
  2702  
  2703  	return buf
  2704  }
  2705  
  2706  // TranslateRegionCookie is a cookie used only for TranslateRegion requests.
  2707  type TranslateRegionCookie struct {
  2708  	*xgb.Cookie
  2709  }
  2710  
  2711  // TranslateRegion sends an unchecked request.
  2712  // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
  2713  func TranslateRegion(c *xgb.Conn, Region Region, Dx int16, Dy int16) TranslateRegionCookie {
  2714  	c.ExtLock.RLock()
  2715  	defer c.ExtLock.RUnlock()
  2716  	if _, ok := c.Extensions["XFIXES"]; !ok {
  2717  		panic("Cannot issue request 'TranslateRegion' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.")
  2718  	}
  2719  	cookie := c.NewCookie(false, false)
  2720  	c.NewRequest(translateRegionRequest(c, Region, Dx, Dy), cookie)
  2721  	return TranslateRegionCookie{cookie}
  2722  }
  2723  
  2724  // TranslateRegionChecked sends a checked request.
  2725  // If an error occurs, it can be retrieved using TranslateRegionCookie.Check()
  2726  func TranslateRegionChecked(c *xgb.Conn, Region Region, Dx int16, Dy int16) TranslateRegionCookie {
  2727  	c.ExtLock.RLock()
  2728  	defer c.ExtLock.RUnlock()
  2729  	if _, ok := c.Extensions["XFIXES"]; !ok {
  2730  		panic("Cannot issue request 'TranslateRegion' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.")
  2731  	}
  2732  	cookie := c.NewCookie(true, false)
  2733  	c.NewRequest(translateRegionRequest(c, Region, Dx, Dy), cookie)
  2734  	return TranslateRegionCookie{cookie}
  2735  }
  2736  
  2737  // Check returns an error if one occurred for checked requests that are not expecting a reply.
  2738  // This cannot be called for requests expecting a reply, nor for unchecked requests.
  2739  func (cook TranslateRegionCookie) Check() error {
  2740  	return cook.Cookie.Check()
  2741  }
  2742  
  2743  // Write request to wire for TranslateRegion
  2744  // translateRegionRequest writes a TranslateRegion request to a byte slice.
  2745  func translateRegionRequest(c *xgb.Conn, Region Region, Dx int16, Dy int16) []byte {
  2746  	size := 12
  2747  	b := 0
  2748  	buf := make([]byte, size)
  2749  
  2750  	c.ExtLock.RLock()
  2751  	buf[b] = c.Extensions["XFIXES"]
  2752  	c.ExtLock.RUnlock()
  2753  	b += 1
  2754  
  2755  	buf[b] = 17 // request opcode
  2756  	b += 1
  2757  
  2758  	xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
  2759  	b += 2
  2760  
  2761  	xgb.Put32(buf[b:], uint32(Region))
  2762  	b += 4
  2763  
  2764  	xgb.Put16(buf[b:], uint16(Dx))
  2765  	b += 2
  2766  
  2767  	xgb.Put16(buf[b:], uint16(Dy))
  2768  	b += 2
  2769  
  2770  	return buf
  2771  }
  2772  
  2773  // UnionRegionCookie is a cookie used only for UnionRegion requests.
  2774  type UnionRegionCookie struct {
  2775  	*xgb.Cookie
  2776  }
  2777  
  2778  // UnionRegion sends an unchecked request.
  2779  // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
  2780  func UnionRegion(c *xgb.Conn, Source1 Region, Source2 Region, Destination Region) UnionRegionCookie {
  2781  	c.ExtLock.RLock()
  2782  	defer c.ExtLock.RUnlock()
  2783  	if _, ok := c.Extensions["XFIXES"]; !ok {
  2784  		panic("Cannot issue request 'UnionRegion' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.")
  2785  	}
  2786  	cookie := c.NewCookie(false, false)
  2787  	c.NewRequest(unionRegionRequest(c, Source1, Source2, Destination), cookie)
  2788  	return UnionRegionCookie{cookie}
  2789  }
  2790  
  2791  // UnionRegionChecked sends a checked request.
  2792  // If an error occurs, it can be retrieved using UnionRegionCookie.Check()
  2793  func UnionRegionChecked(c *xgb.Conn, Source1 Region, Source2 Region, Destination Region) UnionRegionCookie {
  2794  	c.ExtLock.RLock()
  2795  	defer c.ExtLock.RUnlock()
  2796  	if _, ok := c.Extensions["XFIXES"]; !ok {
  2797  		panic("Cannot issue request 'UnionRegion' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.")
  2798  	}
  2799  	cookie := c.NewCookie(true, false)
  2800  	c.NewRequest(unionRegionRequest(c, Source1, Source2, Destination), cookie)
  2801  	return UnionRegionCookie{cookie}
  2802  }
  2803  
  2804  // Check returns an error if one occurred for checked requests that are not expecting a reply.
  2805  // This cannot be called for requests expecting a reply, nor for unchecked requests.
  2806  func (cook UnionRegionCookie) Check() error {
  2807  	return cook.Cookie.Check()
  2808  }
  2809  
  2810  // Write request to wire for UnionRegion
  2811  // unionRegionRequest writes a UnionRegion request to a byte slice.
  2812  func unionRegionRequest(c *xgb.Conn, Source1 Region, Source2 Region, Destination Region) []byte {
  2813  	size := 16
  2814  	b := 0
  2815  	buf := make([]byte, size)
  2816  
  2817  	c.ExtLock.RLock()
  2818  	buf[b] = c.Extensions["XFIXES"]
  2819  	c.ExtLock.RUnlock()
  2820  	b += 1
  2821  
  2822  	buf[b] = 13 // request opcode
  2823  	b += 1
  2824  
  2825  	xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
  2826  	b += 2
  2827  
  2828  	xgb.Put32(buf[b:], uint32(Source1))
  2829  	b += 4
  2830  
  2831  	xgb.Put32(buf[b:], uint32(Source2))
  2832  	b += 4
  2833  
  2834  	xgb.Put32(buf[b:], uint32(Destination))
  2835  	b += 4
  2836  
  2837  	return buf
  2838  }