aboutsummaryrefslogtreecommitdiff
path: root/nexgb/xgb.go
diff options
context:
space:
mode:
authorAndrew Gallant (Ocelot) <Andrew.Gallant@tufts.edu>2012-04-29 03:38:29 -0400
committerAndrew Gallant (Ocelot) <Andrew.Gallant@tufts.edu>2012-04-29 03:38:29 -0400
commit6bf0191fb01f4c0b65bcd444bb5381013c627f95 (patch)
treef83d00c55a92568e8345849c6753253d17bc393d /nexgb/xgb.go
parent52a21b415ad95b2c4649254447388cb329cee1a4 (diff)
downloadhaven-6bf0191fb01f4c0b65bcd444bb5381013c627f95.tar.gz
haven-6bf0191fb01f4c0b65bcd444bb5381013c627f95.tar.xz
haven-6bf0191fb01f4c0b65bcd444bb5381013c627f95.zip
progress. still not working. this is incredibly difficult.
Diffstat (limited to 'nexgb/xgb.go')
-rw-r--r--nexgb/xgb.go22
1 files changed, 19 insertions, 3 deletions
diff --git a/nexgb/xgb.go b/nexgb/xgb.go
index 7e209a7..ce2cc54 100644
--- a/nexgb/xgb.go
+++ b/nexgb/xgb.go
@@ -87,9 +87,15 @@ func newCookie(id uint16) *Cookie {
}
}
-// Event is an interface that can contain any of the events returned by the server.
-// Use a type assertion switch to extract the Event structs.
-type Event interface{}
+// Event is an interface that can contain any of the events returned by the
+// server. Use a type assertion switch to extract the Event structs.
+type Event interface {
+ ImplementsEvent()
+}
+
+// newEventFuncs is a map from event numbers to functions that create
+// the corresponding event.
+var newEventFuncs map[int]func(buf []byte) Event
// Error contains protocol errors returned to us by the X server.
type Error struct {
@@ -100,6 +106,16 @@ type Error struct {
Id Id
}
+// Error2 is an interface that can contain any of the errors returned by
+// the server. Use a type assertion switch to extract the Error structs.
+type Error2 interface {
+ ImplementsError()
+}
+
+// newErrorFuncs is a map from error numbers to functions that create
+// the corresponding error.
+var newErrorFuncs map[int]func(buf []byte) Error2
+
func (e *Error) Error() string {
return fmt.Sprintf("Bad%s (major=%d minor=%d cookie=%d id=0x%x)",
errorNames[e.Detail], e.Major, e.Minor, e.Cookie, e.Id)