From e635de5e1d64d5d642c05ad24ebb207846022272 Mon Sep 17 00:00:00 2001 From: Andrew Gallant Date: Sat, 26 Jan 2013 12:51:21 -0500 Subject: Provide access to the X display number in the XGB Conn. --- nexgb/conn.go | 8 +++++--- nexgb/xgb.go | 1 + 2 files changed, 6 insertions(+), 3 deletions(-) (limited to 'nexgb') diff --git a/nexgb/conn.go b/nexgb/conn.go index 9baf86c..bb2f413 100644 --- a/nexgb/conn.go +++ b/nexgb/conn.go @@ -141,8 +141,9 @@ func (c *Conn) dial(display string) error { scr = display[dotIdx+1:] } - dispnum, err := strconv.Atoi(c.display) - if err != nil || dispnum < 0 { + var err error + c.DisplayNumber, err = strconv.Atoi(c.display) + if err != nil || c.DisplayNumber < 0 { return errors.New("bad display string: " + display0) } @@ -160,7 +161,8 @@ func (c *Conn) dial(display string) error { if protocol == "" { protocol = "tcp" } - c.conn, err = net.Dial(protocol, c.host+":"+strconv.Itoa(6000+dispnum)) + c.conn, err = net.Dial(protocol, + c.host+":"+strconv.Itoa(6000+c.DisplayNumber)) } else { c.conn, err = net.Dial("unix", "/tmp/.X11-unix/X"+c.display) } diff --git a/nexgb/xgb.go b/nexgb/xgb.go index 1c6ef93..b123ba1 100644 --- a/nexgb/xgb.go +++ b/nexgb/xgb.go @@ -49,6 +49,7 @@ type Conn struct { host string conn net.Conn display string + DisplayNumber int DefaultScreen int SetupBytes []byte -- cgit v1.2.3-70-g09d2