zorldo

Goofing around with Ebiten
git clone git://bsandro.tech/zorldo
Log | Files | Refs | README

sync.go (863B)


      1 package xgb
      2 
      3 // Sync sends a round trip request and waits for the response.
      4 // This forces all pending cookies to be dealt with.
      5 // You actually shouldn't need to use this like you might with Xlib. Namely,
      6 // buffers are automatically flushed using Go's channels and round trip requests
      7 // are forced where appropriate automatically.
      8 func (c *Conn) Sync() {
      9 	cookie := c.NewCookie(true, true)
     10 	c.NewRequest(c.getInputFocusRequest(), cookie)
     11 	cookie.Reply() // wait for the buffer to clear
     12 }
     13 
     14 // getInputFocusRequest writes the raw bytes to a buffer.
     15 // It is duplicated from xproto/xproto.go.
     16 func (c *Conn) getInputFocusRequest() []byte {
     17 	size := 4
     18 	b := 0
     19 	buf := make([]byte, size)
     20 
     21 	buf[b] = 43 // request opcode
     22 	b += 1
     23 
     24 	b += 1                         // padding
     25 	Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
     26 	b += 2
     27 
     28 	return buf
     29 }