summaryrefslogtreecommitdiff
path: root/xgb.go
diff options
context:
space:
mode:
authorAndrew Gallant <[email protected]>2015-02-22 11:34:23 -0500
committerAndrew Gallant <[email protected]>2015-02-22 11:34:23 -0500
commite4ac47f3a521f0bdc30fbd5e263b14d0218bbf62 (patch)
treee8de870e83fa106e70a08d9b9c472cd642f6f82a /xgb.go
parenteabb7feb995f0d542f1972909a69f4ab02c8f210 (diff)
parent5d8118d8abc94eff8e9723a5b5ad15e8310560a3 (diff)
Merge pull request #27 from fangyuanziti/master
add a new api: NewConnNet. So we can init a xgb.Conn from a net.Conn
Diffstat (limited to 'xgb.go')
-rw-r--r--xgb.go20
1 files changed, 20 insertions, 0 deletions
diff --git a/xgb.go b/xgb.go
index 3c7964c..4403ea0 100644
--- a/xgb.go
+++ b/xgb.go
@@ -98,6 +98,26 @@ func NewConnDisplay(display string) (*Conn, error) {
return nil, err
}
+ return postNewConn(conn)
+}
+
+// NewConnDisplay is just like NewConn, but allows a specific net.Conn
+// to be used.
+func NewConnNet(netConn net.Conn) (*Conn, error) {
+ conn := &Conn{}
+
+ // First connect. This reads authority, checks DISPLAY environment
+ // variable, and loads the initial Setup info.
+ err := conn.connectNet(netConn)
+
+ if err != nil {
+ return nil, err
+ }
+
+ return postNewConn(conn)
+}
+
+func postNewConn(conn *Conn) (*Conn, error) {
conn.Extensions = make(map[string]byte)
conn.cookieChan = make(chan *Cookie, cookieBuffer)