aboutsummaryrefslogtreecommitdiff
path: root/nexgb/xgb_help.go
diff options
context:
space:
mode:
authorAndrew Gallant (Ocelot) <Andrew.Gallant@tufts.edu>2012-05-05 18:22:24 -0400
committerAndrew Gallant (Ocelot) <Andrew.Gallant@tufts.edu>2012-05-05 18:22:24 -0400
commit369ad0d33e51035a3e48436fc85f60130b201437 (patch)
treee3b4bec82f4e21cfc0e8cc3c696f56b58bb30869 /nexgb/xgb_help.go
parentb6715f376f5ea3efb58146c58924dcc7b1536181 (diff)
downloadhaven-369ad0d33e51035a3e48436fc85f60130b201437.tar.gz
haven-369ad0d33e51035a3e48436fc85f60130b201437.tar.xz
haven-369ad0d33e51035a3e48436fc85f60130b201437.zip
extensions are working! extensions are working!
Diffstat (limited to 'nexgb/xgb_help.go')
-rw-r--r--nexgb/xgb_help.go52
1 files changed, 21 insertions, 31 deletions
diff --git a/nexgb/xgb_help.go b/nexgb/xgb_help.go
index f7b4948..b54ab41 100644
--- a/nexgb/xgb_help.go
+++ b/nexgb/xgb_help.go
@@ -5,20 +5,6 @@ import (
"strings"
)
-// getExtensionOpcode retrieves the extension opcode from the extensions map.
-// If one doesn't exist, just return 0. An X error will likely result.
-func (c *Conn) getExtensionOpcode(name string) byte {
- return c.extensions[name]
-}
-
-func (c *Conn) bytesPadding(buf []byte) []byte {
- return append(buf, make([]byte, pad(len(buf))-len(buf))...)
-}
-
-func (c *Conn) bytesString(str string) []byte {
- return c.bytesPadding([]byte(str))
-}
-
// stringsJoin is an alias to strings.Join. It allows us to avoid having to
// import 'strings' in each of the generated Go files.
func stringsJoin(ss []string, sep string) string {
@@ -31,13 +17,29 @@ func sprintf(format string, v ...interface{}) string {
}
// Pad a length to align on 4 bytes.
-func pad(n int) int { return (n + 3) & ^3 }
+func pad(n int) int {
+ return (n + 3) & ^3
+}
+
+// popCount counts the number of bits set in a value list mask.
+func popCount(mask0 int) int {
+ mask := uint32(mask0)
+ n := 0
+ for i := uint32(0); i < 32; i++ {
+ if mask&(1<<i) != 0 {
+ n++
+ }
+ }
+ return n
+}
+// Put16 takes a 16 bit integer and copies it into a byte slice.
func Put16(buf []byte, v uint16) {
buf[0] = byte(v)
buf[1] = byte(v >> 8)
}
+// Put32 takes a 32 bit integer and copies it into a byte slice.
func Put32(buf []byte, v uint32) {
buf[0] = byte(v)
buf[1] = byte(v >> 8)
@@ -45,6 +47,7 @@ func Put32(buf []byte, v uint32) {
buf[3] = byte(v >> 24)
}
+// Put64 takes a 64 bit integer and copies it into a byte slice.
func Put64(buf []byte, v uint64) {
buf[0] = byte(v)
buf[1] = byte(v >> 8)
@@ -56,12 +59,14 @@ func Put64(buf []byte, v uint64) {
buf[7] = byte(v >> 56)
}
+// Get16 constructs a 16 bit integer from the beginning of a byte slice.
func Get16(buf []byte) uint16 {
v := uint16(buf[0])
v |= uint16(buf[1]) << 8
return v
}
+// Get32 constructs a 32 bit integer from the beginning of a byte slice.
func Get32(buf []byte) uint32 {
v := uint32(buf[0])
v |= uint32(buf[1]) << 8
@@ -70,6 +75,7 @@ func Get32(buf []byte) uint32 {
return v
}
+// Get64 constructs a 64 bit integer from the beginning of a byte slice.
func Get64(buf []byte) uint64 {
v := uint64(buf[0])
v |= uint64(buf[1]) << 8
@@ -81,19 +87,3 @@ func Get64(buf []byte) uint64 {
v |= uint64(buf[7]) << 56
return v
}
-
-// Voodoo to count the number of bits set in a value list mask.
-func popCount(mask0 int) int {
- mask := uint32(mask0)
- n := 0
- for i := uint32(0); i < 32; i++ {
- if mask&(1<<i) != 0 {
- n++
- }
- }
- return n
-}
-
-// DefaultScreen returns the Screen info for the default screen, which is
-// 0 or the one given in the display argument to Dial.
-func (c *Conn) DefaultScreen() *ScreenInfo { return &c.Setup.Roots[c.defaultScreen] }