diff --git a/client.go b/client.go index 1049b82..0004b8a 100644 --- a/client.go +++ b/client.go @@ -43,9 +43,6 @@ func Connect(ctx context.Context, c net.Conn, cfg *ClientConfig) (*ClientConn, e } } - canvas := NewVncCanvas(int(conn.Width()), int(conn.Height())) - canvas.DrawCursor = cfg.DrawCursor - conn.Canvas = canvas return conn, nil } diff --git a/example/client/main.go b/example/client/main.go index 85f38b2..377591b 100644 --- a/example/client/main.go +++ b/example/client/main.go @@ -84,15 +84,6 @@ func main() { //go vcodec.Run("C:\\Users\\betzalel\\Dropbox\\go\\src\\vnc2video\\example\\client\\ffmpeg.exe", "output.mp4") //vcodec.Run("./output") - //screenImage := vnc.NewVncCanvas(int(cc.Width()), int(cc.Height())) - - for _, enc := range ccfg.Encodings { - myRenderer, ok := enc.(vnc.Renderer) - - if ok { - myRenderer.SetTargetImage(screenImage) - } - } // var out *os.File logger.Tracef("connected to: %s", os.Args[1]) diff --git a/handlers.go b/handlers.go index d38c328..4a94e3b 100644 --- a/handlers.go +++ b/handlers.go @@ -345,6 +345,21 @@ func (*DefaultClientServerInitHandler) Handle(c Conn) error { // return err // } }*/ + + // set up canvas and init renderer before other + cfg := c.Config().(*ClientConfig) + canvas := NewVncCanvas(int(c.Width()), int(c.Height())) + canvas.DrawCursor = cfg.DrawCursor + c.(*ClientConn).Canvas = canvas + + for _, enc := range cfg.Encodings { + myRenderer, ok := enc.(Renderer) + + if ok { + myRenderer.SetTargetImage(canvas) + } + } + return nil }