diff options
Diffstat (limited to 'xgob/xproto.go')
-rw-r--r-- | xgob/xproto.go | 54 |
1 files changed, 27 insertions, 27 deletions
diff --git a/xgob/xproto.go b/xgob/xproto.go index 895ba3b..3791ae2 100644 --- a/xgob/xproto.go +++ b/xgob/xproto.go @@ -8,35 +8,35 @@ type Atom uint32 type Window uint32 type QueryTreeReply struct { - Error *xgob.Error + Error *xgob.Error Root, Parent Window - Children []Window + Children []Window } type InternAtomReply struct { Error *xgob.Error - Atom Atom + Atom Atom } type GetPropertyReply struct { - Error *xgob.Error - Format uint8 - Type Atom + Error *xgob.Error + Format uint8 + Type Atom BytesAfter uint32 - Value []byte + Value []byte } func appendUint16(buf []byte, val uint16) []byte { - buf = append(buf, uint8(val >> 8)) - buf = append(buf, uint8(val & 0xFF)) + buf = append(buf, uint8(val>>8)) + buf = append(buf, uint8(val&0xFF)) return buf } func appendUint32(buf []byte, val uint32) []byte { - buf = append(buf, uint8(val >> 24)) - buf = append(buf, uint8(val >> 16)) - buf = append(buf, uint8(val >> 8)) - buf = append(buf, uint8(val & 0xFF)) + buf = append(buf, uint8(val>>24)) + buf = append(buf, uint8(val>>16)) + buf = append(buf, uint8(val>>8)) + buf = append(buf, uint8(val&0xFF)) return buf } @@ -71,8 +71,8 @@ func queryTreeReply(data interface{}, out chan QueryTreeReply) { children_len := getUint16(rep) rep = rep[2:] rv.Children = make([]Window, 0, children_len) - rep = rep[14:] // Pad - + rep = rep[14:] // Pad + for i := uint16(0); i < children_len; i++ { rv.Children = append(rv.Children, Window(getUint32(rep))) rep = rep[4:] @@ -84,13 +84,13 @@ func queryTreeReply(data interface{}, out chan QueryTreeReply) { func QueryTree(c *xgob.Connection, window Window) chan QueryTreeReply { req := make([]byte, 0, 8) - req = append(req, 15) // Opcode - req = append(req, 0) // Pad - req = appendUint16(req, 2) // Length + req = append(req, 15) // Opcode + req = append(req, 0) // Pad + req = appendUint16(req, 2) // Length req = appendUint32(req, uint32(window)) rv := make(chan QueryTreeReply, 1) - c.WriteReplyRequestCallback(req, func (in interface{}) { queryTreeReply(in, rv) }) + c.WriteReplyRequestCallback(req, func(in interface{}) { queryTreeReply(in, rv) }) return rv } @@ -113,7 +113,7 @@ func InternAtom(c *xgob.Connection, only_if_exists bool, name string) chan Inter req := make([]byte, 0, length) - req = append(req, 16) // Opcode + req = append(req, 16) // Opcode if only_if_exists { req = append(req, 1) } else { @@ -121,13 +121,13 @@ func InternAtom(c *xgob.Connection, only_if_exists bool, name string) chan Inter } req = appendUint16(req, uint16(length/4)) req = appendUint16(req, uint16(len(name))) - req = appendUint16(req, 0) // Pad + req = appendUint16(req, 0) // Pad - req = req[0:length] // Expand for name + req = req[0:length] // Expand for name copy(req[8:], name) rv := make(chan InternAtomReply, 1) - c.WriteReplyRequestCallback(req, func (in interface{}) { internAtomReply(in, rv) }) + c.WriteReplyRequestCallback(req, func(in interface{}) { internAtomReply(in, rv) }) return rv } @@ -147,7 +147,7 @@ func getPropertyReply(data interface{}, out chan GetPropertyReply) { rep = rep[4:] value_len := getUint32(rep) rep = rep[4:] - rep = rep[12:] // Pad + rep = rep[12:] // Pad rv.Value = rep[:value_len] rep = rep[value_len:] } @@ -155,9 +155,9 @@ func getPropertyReply(data interface{}, out chan GetPropertyReply) { } func GetProperty(c *xgob.Connection, delete bool, window Window, property Atom, _type Atom, long_offset uint32, long_length uint32) chan GetPropertyReply { - req := make([]byte, 0, 6 * 4) + req := make([]byte, 0, 6*4) - req = append(req, 20) // Opcode + req = append(req, 20) // Opcode if delete { req = append(req, 1) } else { @@ -171,7 +171,7 @@ func GetProperty(c *xgob.Connection, delete bool, window Window, property Atom, req = appendUint32(req, long_length) rv := make(chan GetPropertyReply, 1) - c.WriteReplyRequestCallback(req, func (in interface{}) { getPropertyReply(in, rv) }) + c.WriteReplyRequestCallback(req, func(in interface{}) { getPropertyReply(in, rv) }) return rv } |