From 64c6e6170d86dd4b18d04c49888a6b8ac472c4d6 Mon Sep 17 00:00:00 2001 From: snyh Date: Mon, 30 Dec 2013 16:58:14 +0800 Subject: example/randr: check the GetOutputInfo's mode length (virtual head can have zero mode) --- nexgb/examples/randr/main.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'nexgb') diff --git a/nexgb/examples/randr/main.go b/nexgb/examples/randr/main.go index ad575ee..427aed6 100644 --- a/nexgb/examples/randr/main.go +++ b/nexgb/examples/randr/main.go @@ -45,10 +45,12 @@ func main() { log.Fatal(err) } - bestMode := info.Modes[0] - for _, mode := range resources.Modes { - if mode.Id == uint32(bestMode) { - fmt.Printf("Width: %d, Height: %d\n", mode.Width, mode.Height) + if len(info.Modes) > 0 { + bestMode := info.Modes[0] + for _, mode := range resources.Modes { + if mode.Id == uint32(bestMode) { + fmt.Printf("Width: %d, Height: %d\n", mode.Width, mode.Height) + } } } } -- cgit v1.2.3-70-g09d2