From 95ab1c95ecda369dff5e095f1dfa134dea1c1308 Mon Sep 17 00:00:00 2001 From: snyh Date: Mon, 30 Dec 2013 16:58:14 +0800 Subject: [PATCH 1/2] example/randr: check the GetOutputInfo's mode length (virtual head can have zero mode) --- examples/randr/main.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/examples/randr/main.go b/examples/randr/main.go index ad575ee..427aed6 100644 --- a/examples/randr/main.go +++ b/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) + } } } } From f96506e570f53aa7e93e2a14dec6f9e0717a4fd7 Mon Sep 17 00:00:00 2001 From: snyh Date: Tue, 31 Dec 2013 09:20:13 +0800 Subject: [PATCH 2/2] examples:randr use info.Connection to detect whether there has any Randr.Modes --- examples/randr/main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/randr/main.go b/examples/randr/main.go index 427aed6..414ef8d 100644 --- a/examples/randr/main.go +++ b/examples/randr/main.go @@ -45,7 +45,7 @@ func main() { log.Fatal(err) } - if len(info.Modes) > 0 { + if info.Connection == randr.ConnectionConnected { bestMode := info.Modes[0] for _, mode := range resources.Modes { if mode.Id == uint32(bestMode) {