summaryrefslogtreecommitdiff
path: root/examples/randr/main.go
diff options
context:
space:
mode:
authorsnyh <[email protected]>2013-12-30 16:58:14 +0800
committersnyh <[email protected]>2013-12-30 16:58:14 +0800
commit95ab1c95ecda369dff5e095f1dfa134dea1c1308 (patch)
treef962beb71a8336db61018d1afa01f477beb6739f /examples/randr/main.go
parent9c952b021ced9543d1602e60ba4189e4a2f71414 (diff)
example/randr: check the GetOutputInfo's mode length (virtual head can have zero mode)
Diffstat (limited to 'examples/randr/main.go')
-rw-r--r--examples/randr/main.go10
1 files 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)
+ }
}
}
}