diff options
author | fangyuanziti <tiziyuanfang@gmail.com> | 2015-02-22 20:22:38 +0800 |
---|---|---|
committer | Přemysl Janouch <p@janouch.name> | 2018-09-08 16:49:23 +0200 |
commit | a1d1151017ada36a0431969e3e05f35f1dd6204f (patch) | |
tree | 0c39192812e08bccc6878dd59353cdc71cee9b9b /nexgb/xgb.go | |
parent | ef8155bf17787473a58f00d54cfc8a7e16ee8708 (diff) | |
download | haven-a1d1151017ada36a0431969e3e05f35f1dd6204f.tar.gz haven-a1d1151017ada36a0431969e3e05f35f1dd6204f.tar.xz haven-a1d1151017ada36a0431969e3e05f35f1dd6204f.zip |
add a new api: NewConnNet
Diffstat (limited to 'nexgb/xgb.go')
-rw-r--r-- | nexgb/xgb.go | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/nexgb/xgb.go b/nexgb/xgb.go index 3c7964c..4403ea0 100644 --- a/nexgb/xgb.go +++ b/nexgb/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) |